@@ -84,14 +84,27 @@ func LocalImage(nameTag string) Option {
84
84
}
85
85
}
86
86
87
+ // Deploy can be passed to NewKind to deploy extra components, in addition to the base deployment.
88
+ func WithClusterName (name string ) Option {
89
+ return func (k * KindTest ) {
90
+ k .clusterName = name
91
+ }
92
+ }
93
+
94
+ func ForTestInstance (t * testing.T ) Option {
95
+ return func (k * KindTest ) {
96
+ k .testInstance = t
97
+ }
98
+ }
99
+
87
100
// NewKind creates a kind cluster given a name and set of Option instances.
88
- func NewKindTester (kindClusterName string , filePath string , t * testing. T , options ... Option ) * KindTest {
101
+ func NewKindTester (config string , options ... Option ) * KindTest {
89
102
90
103
k := & KindTest {
91
- clusterName : kindClusterName ,
104
+ clusterName : "kured" ,
92
105
timeout : 10 * time .Minute ,
93
- kindConfigPath : filePath ,
94
- testInstance : t ,
106
+ kindConfigPath : config ,
107
+ testInstance : nil ,
95
108
}
96
109
for _ , option := range options {
97
110
option (k )
@@ -157,7 +170,14 @@ func TestE2EWithCommand(t *testing.T) {
157
170
kindClusterConfigFile := fmt .Sprintf ("../../.github/kind-cluster-%v.yaml" , version )
158
171
kindContext := fmt .Sprintf ("kind-%v" , kindClusterName )
159
172
160
- k := NewKindTester (kindClusterName , kindClusterConfigFile , t , LocalImage (kuredDevImage ), Deploy ("../../kured-rbac.yaml" ), Deploy ("testfiles/kured-ds.yaml" ))
173
+ k := NewKindTester (
174
+ kindClusterConfigFile ,
175
+ ForTestInstance (t ),
176
+ WithClusterName (kindClusterName ),
177
+ LocalImage (kuredDevImage ),
178
+ Deploy ("../../kured-rbac.yaml" ),
179
+ Deploy ("testfiles/kured-ds.yaml" ),
180
+ )
161
181
defer k .FlushLog ()
162
182
163
183
err := k .Create ()
@@ -207,7 +227,14 @@ func TestE2EWithSignal(t *testing.T) {
207
227
kindClusterConfigFile := fmt .Sprintf ("../../.github/kind-cluster-%v.yaml" , version )
208
228
kindContext := fmt .Sprintf ("kind-%v" , kindClusterName )
209
229
210
- k := NewKindTester (kindClusterName , kindClusterConfigFile , t , LocalImage (kuredDevImage ), Deploy ("../../kured-rbac.yaml" ), Deploy ("testfiles/kured-ds-signal.yaml" ))
230
+ k := NewKindTester (
231
+ kindClusterConfigFile ,
232
+ ForTestInstance (t ),
233
+ WithClusterName (kindClusterName ),
234
+ LocalImage (kuredDevImage ),
235
+ Deploy ("../../kured-rbac.yaml" ),
236
+ Deploy ("testfiles/kured-ds-signal.yaml" ),
237
+ )
211
238
defer k .FlushLog ()
212
239
213
240
err := k .Create ()
@@ -257,7 +284,14 @@ func TestE2EConcurrentWithCommand(t *testing.T) {
257
284
kindClusterConfigFile := fmt .Sprintf ("../../.github/kind-cluster-%v.yaml" , version )
258
285
kindContext := fmt .Sprintf ("kind-%v" , kindClusterName )
259
286
260
- k := NewKindTester (kindClusterName , kindClusterConfigFile , t , LocalImage (kuredDevImage ), Deploy ("../../kured-rbac.yaml" ), Deploy ("testfiles/kured-ds-concurrent-command.yaml" ))
287
+ k := NewKindTester (
288
+ kindClusterConfigFile ,
289
+ ForTestInstance (t ),
290
+ WithClusterName (kindClusterName ),
291
+ LocalImage (kuredDevImage ),
292
+ Deploy ("../../kured-rbac.yaml" ),
293
+ Deploy ("testfiles/kured-ds-concurrent-command.yaml" ),
294
+ )
261
295
defer k .FlushLog ()
262
296
263
297
err := k .Create ()
@@ -307,7 +341,14 @@ func TestE2EConcurrentWithSignal(t *testing.T) {
307
341
kindClusterConfigFile := fmt .Sprintf ("../../.github/kind-cluster-%v.yaml" , version )
308
342
kindContext := fmt .Sprintf ("kind-%v" , kindClusterName )
309
343
310
- k := NewKindTester (kindClusterName , kindClusterConfigFile , t , LocalImage (kuredDevImage ), Deploy ("../../kured-rbac.yaml" ), Deploy ("testfiles/kured-ds-concurrent-signal.yaml" ))
344
+ k := NewKindTester (
345
+ kindClusterConfigFile ,
346
+ ForTestInstance (t ),
347
+ WithClusterName (kindClusterName ),
348
+ LocalImage (kuredDevImage ),
349
+ Deploy ("../../kured-rbac.yaml" ),
350
+ Deploy ("testfiles/kured-ds-concurrent-signal.yaml" ),
351
+ )
311
352
defer k .FlushLog ()
312
353
313
354
err := k .Create ()
@@ -362,7 +403,16 @@ func TestCordonningIsKept(t *testing.T) {
362
403
} else {
363
404
manifest = "testfiles/kured-ds-concurrent-signal.yaml"
364
405
}
365
- k := NewKindTester (kindClusterName , kindClusterConfigFile , t , LocalImage (kuredDevImage ), Deploy ("../../kured-rbac.yaml" ), Deploy (manifest ))
406
+
407
+ k := NewKindTester (
408
+ kindClusterConfigFile ,
409
+ ForTestInstance (t ),
410
+ WithClusterName (kindClusterName ),
411
+ LocalImage (kuredDevImage ),
412
+ Deploy ("../../kured-rbac.yaml" ),
413
+ Deploy (manifest ),
414
+ )
415
+
366
416
defer k .FlushLog ()
367
417
368
418
err := k .Create ()
@@ -405,7 +455,14 @@ func TestE2EBlocker(t *testing.T) {
405
455
kindClusterConfigFile := "../../.github/kind-cluster-next.yaml"
406
456
kindContext := fmt .Sprintf ("kind-%v" , kindClusterName )
407
457
408
- k := NewKindTester (kindClusterName , kindClusterConfigFile , t , LocalImage (kuredDevImage ), Deploy ("../../kured-rbac.yaml" ), Deploy (fmt .Sprintf ("testfiles/kured-ds-%v.yaml" , variant )))
458
+ k := NewKindTester (
459
+ kindClusterConfigFile ,
460
+ ForTestInstance (t ),
461
+ WithClusterName (kindClusterName ),
462
+ LocalImage (kuredDevImage ),
463
+ Deploy ("../../kured-rbac.yaml" ),
464
+ Deploy (fmt .Sprintf ("testfiles/kured-ds-%v.yaml" , variant )),
465
+ )
409
466
defer k .FlushLog ()
410
467
411
468
err := k .Create ()
0 commit comments