Skip to content

Commit 0f61984

Browse files
committed
fix for loops
1 parent d114b19 commit 0f61984

File tree

1 file changed

+22
-112
lines changed

1 file changed

+22
-112
lines changed

apis/fluentd/v1alpha1/tests/helper_test.go

Lines changed: 22 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,11 @@ func Test_Cfg2ES(t *testing.T) {
3434
err = psr.WithCfgResources(*cfgRouter.Label, cfgResources)
3535
g.Expect(err).NotTo(HaveOccurred())
3636

37-
// we should not see any permutations in serialized config
38-
i := 0
39-
for i < maxRuntimes {
37+
for i := 0; i < maxRuntimes; i++ {
4038
config, errs := psr.RenderMainConfig(false)
4139
// fmt.Println(config)
4240
g.Expect(errs).NotTo(HaveOccurred())
4341
g.Expect(string(getExpectedCfg("./expected/fluentd-namespaced-cfg-output-es.cfg"))).To(Equal(config))
44-
45-
i++
4642
}
4743
}
4844

@@ -66,7 +62,6 @@ func Test_ClusterCfgInputTail(t *testing.T) {
6662
g.Expect(errs).NotTo(HaveOccurred())
6763
g.Expect(string(getExpectedCfg("./expected/fluentd-global-cfg-input-tail.cfg"))).To(Equal(config))
6864
}
69-
7065
}
7166

7267
func Test_ClusterCfgInputSample(t *testing.T) {
@@ -127,14 +122,10 @@ func Test_ClusterCfgOutput2ES(t *testing.T) {
127122
err = psr.WithCfgResources(*clustercfgRouter.Label, clustercfgResources)
128123
g.Expect(err).NotTo(HaveOccurred())
129124

130-
// we should not see any permutations in serialized config
131-
i := 0
132-
for i < maxRuntimes {
125+
for i := 0; i < maxRuntimes; i++ {
133126
config, errs := psr.RenderMainConfig(false)
134127
g.Expect(errs).NotTo(HaveOccurred())
135128
g.Expect(string(getExpectedCfg("./expected/fluentd-cluster-cfg-output-es.cfg"))).To(Equal(config))
136-
137-
i++
138129
}
139130
}
140131

@@ -153,14 +144,10 @@ func Test_ClusterCfgOutput2ESDataStream(t *testing.T) {
153144
err = psr.WithCfgResources(*clustercfgRouter.Label, clustercfgResources)
154145
g.Expect(err).NotTo(HaveOccurred())
155146

156-
// we should not see any permutations in serialized config
157-
i := 0
158-
for i < maxRuntimes {
147+
for i := 0; i < maxRuntimes; i++ {
159148
config, errs := psr.RenderMainConfig(false)
160149
g.Expect(errs).NotTo(HaveOccurred())
161150
g.Expect(string(getExpectedCfg("./expected/fluentd-cluster-cfg-output-es-data-stream.cfg"))).To(Equal(config))
162-
163-
i++
164151
}
165152
}
166153

@@ -180,14 +167,10 @@ func Test_ClusterCfgOutput2CopyESDataStream(t *testing.T) {
180167
err = psr.WithCfgResources(*clustercfgRouter.Label, clustercfgResources)
181168
g.Expect(err).NotTo(HaveOccurred())
182169

183-
// we should not see any permutations in serialized config
184-
i := 0
185-
for i < maxRuntimes {
170+
for i := 0; i < maxRuntimes; i++ {
186171
config, errs := psr.RenderMainConfig(false)
187172
g.Expect(errs).NotTo(HaveOccurred())
188173
g.Expect(string(getExpectedCfg("./expected/fluentd-cluster-cfg-output-copy-es-data-stream.cfg"))).To(Equal(config))
189-
190-
i++
191174
}
192175
}
193176

@@ -205,14 +188,10 @@ func Test_Cfg2OpenSearch(t *testing.T) {
205188
err = psr.WithCfgResources(*cfgRouter.Label, cfgResources)
206189
g.Expect(err).NotTo(HaveOccurred())
207190

208-
// we should not see any permutations in serialized config
209-
i := 0
210-
for i < maxRuntimes {
191+
for i := 0; i < maxRuntimes; i++ {
211192
config, errs := psr.RenderMainConfig(false)
212193
g.Expect(errs).NotTo(HaveOccurred())
213194
g.Expect(string(getExpectedCfg("./expected/fluentd-namespaced-cfg-output-opensearch.cfg"))).To(Equal(config))
214-
215-
i++
216195
}
217196
}
218197

@@ -231,15 +210,11 @@ func Test_ClusterCfgOutput2OpenSearch(t *testing.T) {
231210
err = psr.WithCfgResources(*clustercfgRouter.Label, clustercfgResources)
232211
g.Expect(err).NotTo(HaveOccurred())
233212

234-
// we should not see any permutations in serialized config
235-
i := 0
236-
for i < maxRuntimes {
213+
for i := 0; i < maxRuntimes; i++ {
237214
config, errs := psr.RenderMainConfig(false)
238215
//fmt.Println(config)
239216
g.Expect(errs).NotTo(HaveOccurred())
240217
g.Expect(string(getExpectedCfg("./expected/fluentd-cluster-cfg-output-opensearch.cfg"))).To(Equal(config))
241-
242-
i++
243218
}
244219
}
245220

@@ -258,15 +233,11 @@ func Test_ClusterCfgOutput2Kafka(t *testing.T) {
258233
err = psr.WithCfgResources(*clustercfgRouter.Label, clustercfgResources)
259234
g.Expect(err).NotTo(HaveOccurred())
260235

261-
// we should not see any permutations in serialized config
262-
i := 0
263-
for i < maxRuntimes {
236+
for i := 0; i < maxRuntimes; i++ {
264237
config, errs := psr.RenderMainConfig(false)
265238
// fmt.Println(config)
266239
g.Expect(errs).NotTo(HaveOccurred())
267240
g.Expect(string(getExpectedCfg("./expected/fluentd-cluster-cfg-output-kafka.cfg"))).To(Equal(config))
268-
269-
i++
270241
}
271242
}
272243

@@ -285,15 +256,11 @@ func Test_ClusterCfgOutput2Loki(t *testing.T) {
285256
err = psr.WithCfgResources(*clustercfgRouter.Label, clustercfgResources)
286257
g.Expect(err).NotTo(HaveOccurred())
287258

288-
// we should not see any permutations in serialized config
289-
i := 0
290-
for i < maxRuntimes {
259+
for i := 0; i < maxRuntimes; i++ {
291260
config, errs := psr.RenderMainConfig(false)
292261
// fmt.Println(config)
293262
g.Expect(errs).NotTo(HaveOccurred())
294263
g.Expect(string(getExpectedCfg("./expected/fluentd-cluster-cfg-output-loki.cfg"))).To(Equal(config))
295-
296-
i++
297264
}
298265
}
299266

@@ -317,15 +284,11 @@ func Test_MixedCfgs2ES(t *testing.T) {
317284
err = psr.WithCfgResources(*cfgRouter.Label, cfgResources)
318285
g.Expect(err).NotTo(HaveOccurred())
319286

320-
// we should not see any permutations in serialized config
321-
i := 0
322-
for i < maxRuntimes {
287+
for i := 0; i < maxRuntimes; i++ {
323288
config, errs := psr.RenderMainConfig(false)
324289
// fmt.Println(config)
325290
g.Expect(errs).NotTo(HaveOccurred())
326291
g.Expect(string(getExpectedCfg("./expected/fluentd-mixed-cfgs-output-es.cfg"))).To(Equal(config))
327-
328-
i++
329292
}
330293
}
331294

@@ -344,14 +307,10 @@ func Test_ClusterCfgOutput2CloudWatch(t *testing.T) {
344307
err = psr.WithCfgResources(*clustercfgRouter.Label, clustercfgResources)
345308
g.Expect(err).NotTo(HaveOccurred())
346309

347-
// we should not see any permutations in serialized config
348-
i := 0
349-
for i < maxRuntimes {
310+
for i := 0; i < maxRuntimes; i++ {
350311
config, errs := psr.RenderMainConfig(false)
351312
g.Expect(errs).NotTo(HaveOccurred())
352313
g.Expect(strings.TrimSpace(string(getExpectedCfg("./expected/fluentd-cluster-cfg-output-cloudwatch.cfg")))).To(Equal(config))
353-
354-
i++
355314
}
356315
}
357316

@@ -370,14 +329,10 @@ func Test_ClusterCfgOutput2Datadog(t *testing.T) {
370329
err = psr.WithCfgResources(*clustercfgRouter.Label, clustercfgResources)
371330
g.Expect(err).NotTo(HaveOccurred())
372331

373-
// we should not see any permutations in serialized config
374-
i := 0
375-
for i < maxRuntimes {
332+
for i := 0; i < maxRuntimes; i++ {
376333
config, errs := psr.RenderMainConfig(false)
377334
g.Expect(errs).NotTo(HaveOccurred())
378335
g.Expect(strings.TrimSpace(string(getExpectedCfg("./expected/fluentd-cluster-cfg-output-datadog.cfg")))).To(Equal(config))
379-
380-
i++
381336
}
382337
}
383338

@@ -401,7 +356,6 @@ func Test_ClusterCfgOutput2Null(t *testing.T) {
401356
g.Expect(errs).NotTo(HaveOccurred())
402357
g.Expect(strings.TrimSpace(string(getExpectedCfg("./expected/fluentd-cluster-cfg-output-null.cfg")))).To(Equal(config))
403358
}
404-
405359
}
406360

407361
func Test_MixedCfgCopy1(t *testing.T) {
@@ -426,15 +380,11 @@ func Test_MixedCfgCopy1(t *testing.T) {
426380
err = psr.WithCfgResources(*cfgRouter.Label, cfgResources)
427381
g.Expect(err).NotTo(HaveOccurred())
428382

429-
// we should not see any permutations in serialized config
430-
i := 0
431-
for i < maxRuntimes {
383+
for i := 0; i < maxRuntimes; i++ {
432384
config, errs := psr.RenderMainConfig(false)
433385
// fmt.Println(config)
434386
g.Expect(errs).NotTo(HaveOccurred())
435387
g.Expect(string(getExpectedCfg("./expected/fluentd-mixed-cfgs-output-copy-1.cfg"))).To(Equal(config))
436-
437-
i++
438388
}
439389
}
440390

@@ -459,15 +409,11 @@ func Test_MixedCfgCopy2(t *testing.T) {
459409
err = psr.WithCfgResources(*cfgRouter.Label, cfgResources)
460410
g.Expect(err).NotTo(HaveOccurred())
461411

462-
// we should not see any permutations in serialized config
463-
i := 0
464-
for i < maxRuntimes {
412+
for i := 0; i < maxRuntimes; i++ {
465413
config, errs := psr.RenderMainConfig(false)
466414
// fmt.Println(config)
467415
g.Expect(errs).NotTo(HaveOccurred())
468416
g.Expect(string(getExpectedCfg("./expected/fluentd-mixed-cfgs-output-copy-2.cfg"))).To(Equal(config))
469-
470-
i++
471417
}
472418
}
473419

@@ -492,15 +438,11 @@ func Test_MixedCfgCopy3(t *testing.T) {
492438
err = psr.WithCfgResources(*cfgRouter.Label, cfgResources)
493439
g.Expect(err).NotTo(HaveOccurred())
494440

495-
// we should not see any permutations in serialized config
496-
i := 0
497-
for i < maxRuntimes {
441+
for i := 0; i < maxRuntimes; i++ {
498442
config, errs := psr.RenderMainConfig(false)
499443
// fmt.Println(config)
500444
g.Expect(errs).NotTo(HaveOccurred())
501445
g.Expect(string(getExpectedCfg("./expected/fluentd-mixed-cfgs-output-copy-3.cfg"))).To(Equal(config))
502-
503-
i++
504446
}
505447
}
506448

@@ -528,14 +470,10 @@ func Test_MixedCfgCopy4(t *testing.T) {
528470
err = psr.WithCfgResources(*cfgRouter.Label, cfgResources)
529471
g.Expect(err).NotTo(HaveOccurred())
530472

531-
// we should not see any permutations in serialized config
532-
i := 0
533-
for i < maxRuntimes {
473+
for i := 0; i < maxRuntimes; i++ {
534474
config, errs := psr.RenderMainConfig(false)
535475
g.Expect(errs).NotTo(HaveOccurred())
536476
g.Expect(string(getExpectedCfg("./expected/fluentd-mixed-cfgs-output-copy-4.cfg"))).To(Equal(config))
537-
538-
i++
539477
}
540478
}
541479

@@ -557,15 +495,11 @@ func Test_ClusterCfgOutput2StdoutAndLoki(t *testing.T) {
557495
err = psr.WithCfgResources(*clustercfgRouter.Label, clustercfgResources)
558496
g.Expect(err).NotTo(HaveOccurred())
559497

560-
// we should not see any permutations in serialized config
561-
i := 0
562-
for i < maxRuntimes {
498+
for i := 0; i < maxRuntimes; i++ {
563499
config, errs := psr.RenderMainConfig(false)
564500
// fmt.Println(config)
565501
g.Expect(errs).NotTo(HaveOccurred())
566502
g.Expect(string(getExpectedCfg("./expected/fluentd-cluster-cfg-output-stdout-and-loki.cfg"))).To(Equal(config))
567-
568-
i++
569503
}
570504
}
571505

@@ -589,15 +523,11 @@ func Test_MixedCfgs2OpenSearch(t *testing.T) {
589523
err = psr.WithCfgResources(*cfgRouter.Label, cfgResources)
590524
g.Expect(err).NotTo(HaveOccurred())
591525

592-
// we should not see any permutations in serialized config
593-
i := 0
594-
for i < maxRuntimes {
526+
for i := 0; i < maxRuntimes; i++ {
595527
config, errs := psr.RenderMainConfig(false)
596528
// fmt.Println(config)
597529
g.Expect(errs).NotTo(HaveOccurred())
598530
g.Expect(string(getExpectedCfg("./expected/fluentd-mixed-cfgs-output-opensearch.cfg"))).To(Equal(config))
599-
600-
i++
601531
}
602532
}
603533

@@ -626,15 +556,11 @@ func Test_MixedCfgs2MultiTenant(t *testing.T) {
626556
err = psr.WithCfgResources(*cfgRouter.Label, cfgResourcesForUser1)
627557
g.Expect(err).NotTo(HaveOccurred())
628558

629-
// we should not see any permutations in serialized config
630-
i := 0
631-
for i < maxRuntimes {
559+
for i := 0; i < maxRuntimes; i++ {
632560
config, errs := psr.RenderMainConfig(false)
633561
// fmt.Println(config)
634562
g.Expect(errs).NotTo(HaveOccurred())
635563
g.Expect(string(getExpectedCfg("./expected/fluentd-mixed-cfgs-multi-tenant-output.cfg"))).To(Equal(config))
636-
637-
i++
638564
}
639565
}
640566

@@ -653,15 +579,11 @@ func Test_OutputWithBuffer(t *testing.T) {
653579
err = psr.WithCfgResources(*clustercfgRouter.Label, clustercfgResources)
654580
g.Expect(err).NotTo(HaveOccurred())
655581

656-
// we should not see any permutations in serialized config
657-
i := 0
658-
for i < maxRuntimes {
582+
for i := 0; i < maxRuntimes; i++ {
659583
config, errs := psr.RenderMainConfig(false)
660584
// fmt.Println(config)
661585
g.Expect(errs).NotTo(HaveOccurred())
662586
g.Expect(string(getExpectedCfg("./expected/fluentd-cluster-cfg-output-buffer-example.cfg"))).To(Equal(config))
663-
664-
i++
665587
}
666588
}
667589

@@ -680,15 +602,11 @@ func Test_OutputWithMemoryBuffer(t *testing.T) {
680602
err = psr.WithCfgResources(*clustercfgRouter.Label, clustercfgResources)
681603
g.Expect(err).NotTo(HaveOccurred())
682604

683-
// we should not see any permutations in serialized config
684-
i := 0
685-
for i < maxRuntimes {
605+
for i := 0; i < maxRuntimes; i++ {
686606
config, errs := psr.RenderMainConfig(false)
687607
// fmt.Println(config)
688608
g.Expect(errs).NotTo(HaveOccurred())
689609
g.Expect(string(getExpectedCfg("./expected/fluentd-cluster-cfg-output-memory-buffer.cfg"))).To(Equal(config))
690-
691-
i++
692610
}
693611
}
694612

@@ -887,15 +805,11 @@ func Test_DuplicateRemovalCRSpecs(t *testing.T) {
887805
err = psr.WithCfgResources(*cfgRouter.Label, cfgResources)
888806
g.Expect(err).NotTo(HaveOccurred())
889807

890-
// we should not see any permutations in serialized config
891-
i := 0
892-
for i < maxRuntimes {
808+
for i := 0; i < maxRuntimes; i++ {
893809
config, errs := psr.RenderMainConfig(false)
894810
// fmt.Println(config)
895811
g.Expect(errs).NotTo(HaveOccurred())
896812
g.Expect(string(getExpectedCfg("./expected/duplicate-removal-cr-specs.cfg"))).To(Equal(config))
897-
898-
i++
899813
}
900814
}
901815

@@ -914,15 +828,11 @@ func Test_RecordTransformer(t *testing.T) {
914828
err = psr.WithCfgResources(*clustercfgRouter.Label, clustercfgResources)
915829
g.Expect(err).NotTo(HaveOccurred())
916830

917-
// we should not see any permutations in serialized config
918-
i := 0
919-
for i < maxRuntimes {
831+
for i := 0; i < maxRuntimes; i++ {
920832
config, errs := psr.RenderMainConfig(false)
921833
// fmt.Println(config)
922834
g.Expect(errs).NotTo(HaveOccurred())
923835
g.Expect(string(getExpectedCfg("./expected/fluentd-cluster-cfg-filter-recordTransformer.cfg"))).To(Equal(config))
924-
925-
i++
926836
}
927837
}
928838

0 commit comments

Comments
 (0)