@@ -26,13 +26,28 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
26
26
27
27
inv := invConfig .InvWrapperFunc (invConfig .FactoryFunc (inventoryName , namespaceName , "test" ))
28
28
29
- pod1Obj := e2eutil .WithDependsOn (e2eutil .WithNamespace (e2eutil .ManifestToUnstructured (pod1 ), namespaceName ), fmt .Sprintf ("/namespaces/%s/Pod/pod3" , namespaceName ))
30
- pod2Obj := e2eutil .WithNamespace (e2eutil .ManifestToUnstructured (pod2 ), namespaceName )
31
- pod3Obj := e2eutil .WithDependsOn (e2eutil .WithNamespace (e2eutil .ManifestToUnstructured (pod3 ), namespaceName ), fmt .Sprintf ("/namespaces/%s/Pod/pod2" , namespaceName ))
29
+ namespace1Name := fmt .Sprintf ("%s-ns1" , namespaceName )
30
+ namespace1Obj := e2eutil .UnstructuredNamespace (namespace1Name )
31
+
32
+ namespace2Name := fmt .Sprintf ("%s-ns2" , namespaceName )
33
+ namespace2Obj := e2eutil .UnstructuredNamespace (namespace2Name )
34
+
35
+ pod1Obj := e2eutil .ManifestToUnstructured (pod1 )
36
+ pod1Obj = e2eutil .WithNamespace (pod1Obj , namespace1Name )
37
+ pod1Obj = e2eutil .WithDependsOn (pod1Obj , fmt .Sprintf ("/namespaces/%s/Pod/pod3" , namespace1Name ))
38
+
39
+ pod2Obj := e2eutil .ManifestToUnstructured (pod2 )
40
+ pod2Obj = e2eutil .WithNamespace (pod2Obj , namespace2Name )
41
+
42
+ pod3Obj := e2eutil .ManifestToUnstructured (pod3 )
43
+ pod3Obj = e2eutil .WithNamespace (pod3Obj , namespace1Name )
44
+ pod3Obj = e2eutil .WithDependsOn (pod3Obj , fmt .Sprintf ("/namespaces/%s/Pod/pod2" , namespace2Name ))
32
45
33
46
// Dependency order: pod1 -> pod3 -> pod2
34
47
// Apply order: pod2, pod3, pod1
35
48
resources := []* unstructured.Unstructured {
49
+ namespace1Obj ,
50
+ namespace2Obj ,
36
51
pod1Obj ,
37
52
pod2Obj ,
38
53
pod3Obj ,
@@ -76,13 +91,21 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
76
91
},
77
92
},
78
93
{
79
- // Apply Pod2 first
94
+ // Apply Namespace1 first
80
95
EventType : event .ApplyType ,
81
96
ApplyEvent : & testutil.ExpApplyEvent {
82
97
GroupName : "apply-0" ,
83
98
Operation : event .Created ,
84
- Identifier : object .UnstructuredToObjMetadata (pod2Obj ),
85
- Error : nil ,
99
+ Identifier : object .UnstructuredToObjMetadata (namespace1Obj ),
100
+ },
101
+ },
102
+ {
103
+ // Apply Namespace2 first
104
+ EventType : event .ApplyType ,
105
+ ApplyEvent : & testutil.ExpApplyEvent {
106
+ GroupName : "apply-0" ,
107
+ Operation : event .Created ,
108
+ Identifier : object .UnstructuredToObjMetadata (namespace2Obj ),
86
109
},
87
110
},
88
111
{
@@ -104,21 +127,39 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
104
127
},
105
128
},
106
129
{
107
- // Pod2 reconcile Pending.
130
+ // Namespace1 reconcile Pending.
108
131
EventType : event .WaitType ,
109
132
WaitEvent : & testutil.ExpWaitEvent {
110
133
GroupName : "wait-0" ,
111
134
Operation : event .ReconcilePending ,
112
- Identifier : object .UnstructuredToObjMetadata (pod2Obj ),
135
+ Identifier : object .UnstructuredToObjMetadata (namespace1Obj ),
113
136
},
114
137
},
115
138
{
116
- // Pod2 confirmed Current.
139
+ // Namespace2 reconcile Pending.
140
+ EventType : event .WaitType ,
141
+ WaitEvent : & testutil.ExpWaitEvent {
142
+ GroupName : "wait-0" ,
143
+ Operation : event .ReconcilePending ,
144
+ Identifier : object .UnstructuredToObjMetadata (namespace2Obj ),
145
+ },
146
+ },
147
+ {
148
+ // Namespace1 confirmed Current.
117
149
EventType : event .WaitType ,
118
150
WaitEvent : & testutil.ExpWaitEvent {
119
151
GroupName : "wait-0" ,
120
152
Operation : event .Reconciled ,
121
- Identifier : object .UnstructuredToObjMetadata (pod2Obj ),
153
+ Identifier : object .UnstructuredToObjMetadata (namespace1Obj ),
154
+ },
155
+ },
156
+ {
157
+ // Namespace2 confirmed Current.
158
+ EventType : event .WaitType ,
159
+ WaitEvent : & testutil.ExpWaitEvent {
160
+ GroupName : "wait-0" ,
161
+ Operation : event .Reconciled ,
162
+ Identifier : object .UnstructuredToObjMetadata (namespace2Obj ),
122
163
},
123
164
},
124
165
{
@@ -140,12 +181,12 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
140
181
},
141
182
},
142
183
{
143
- // Apply Pod3 second
184
+ // Apply Pod2 first
144
185
EventType : event .ApplyType ,
145
186
ApplyEvent : & testutil.ExpApplyEvent {
146
187
GroupName : "apply-1" ,
147
188
Operation : event .Created ,
148
- Identifier : object .UnstructuredToObjMetadata (pod3Obj ),
189
+ Identifier : object .UnstructuredToObjMetadata (pod2Obj ),
149
190
Error : nil ,
150
191
},
151
192
},
@@ -168,21 +209,21 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
168
209
},
169
210
},
170
211
{
171
- // Pod3 reconcile Pending.
212
+ // Pod2 reconcile Pending.
172
213
EventType : event .WaitType ,
173
214
WaitEvent : & testutil.ExpWaitEvent {
174
215
GroupName : "wait-1" ,
175
216
Operation : event .ReconcilePending ,
176
- Identifier : object .UnstructuredToObjMetadata (pod3Obj ),
217
+ Identifier : object .UnstructuredToObjMetadata (pod2Obj ),
177
218
},
178
219
},
179
220
{
180
- // Pod3 confirmed Current.
221
+ // Pod2 confirmed Current.
181
222
EventType : event .WaitType ,
182
223
WaitEvent : & testutil.ExpWaitEvent {
183
224
GroupName : "wait-1" ,
184
225
Operation : event .Reconciled ,
185
- Identifier : object .UnstructuredToObjMetadata (pod3Obj ),
226
+ Identifier : object .UnstructuredToObjMetadata (pod2Obj ),
186
227
},
187
228
},
188
229
{
@@ -204,12 +245,12 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
204
245
},
205
246
},
206
247
{
207
- // Apply Pod1 third
248
+ // Apply Pod3 second
208
249
EventType : event .ApplyType ,
209
250
ApplyEvent : & testutil.ExpApplyEvent {
210
251
GroupName : "apply-2" ,
211
252
Operation : event .Created ,
212
- Identifier : object .UnstructuredToObjMetadata (pod1Obj ),
253
+ Identifier : object .UnstructuredToObjMetadata (pod3Obj ),
213
254
Error : nil ,
214
255
},
215
256
},
@@ -232,19 +273,83 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
232
273
},
233
274
},
234
275
{
235
- // Pod1 reconcile Pending.
276
+ // Pod3 reconcile Pending.
236
277
EventType : event .WaitType ,
237
278
WaitEvent : & testutil.ExpWaitEvent {
238
279
GroupName : "wait-2" ,
239
280
Operation : event .ReconcilePending ,
281
+ Identifier : object .UnstructuredToObjMetadata (pod3Obj ),
282
+ },
283
+ },
284
+ {
285
+ // Pod3 confirmed Current.
286
+ EventType : event .WaitType ,
287
+ WaitEvent : & testutil.ExpWaitEvent {
288
+ GroupName : "wait-2" ,
289
+ Operation : event .Reconciled ,
290
+ Identifier : object .UnstructuredToObjMetadata (pod3Obj ),
291
+ },
292
+ },
293
+ {
294
+ // WaitTask finished
295
+ EventType : event .ActionGroupType ,
296
+ ActionGroupEvent : & testutil.ExpActionGroupEvent {
297
+ Action : event .WaitAction ,
298
+ GroupName : "wait-2" ,
299
+ Type : event .Finished ,
300
+ },
301
+ },
302
+ {
303
+ // ApplyTask start
304
+ EventType : event .ActionGroupType ,
305
+ ActionGroupEvent : & testutil.ExpActionGroupEvent {
306
+ Action : event .ApplyAction ,
307
+ GroupName : "apply-3" ,
308
+ Type : event .Started ,
309
+ },
310
+ },
311
+ {
312
+ // Apply Pod1 third
313
+ EventType : event .ApplyType ,
314
+ ApplyEvent : & testutil.ExpApplyEvent {
315
+ GroupName : "apply-3" ,
316
+ Operation : event .Created ,
317
+ Identifier : object .UnstructuredToObjMetadata (pod1Obj ),
318
+ Error : nil ,
319
+ },
320
+ },
321
+ {
322
+ // ApplyTask finished
323
+ EventType : event .ActionGroupType ,
324
+ ActionGroupEvent : & testutil.ExpActionGroupEvent {
325
+ Action : event .ApplyAction ,
326
+ GroupName : "apply-3" ,
327
+ Type : event .Finished ,
328
+ },
329
+ },
330
+ {
331
+ // WaitTask start
332
+ EventType : event .ActionGroupType ,
333
+ ActionGroupEvent : & testutil.ExpActionGroupEvent {
334
+ Action : event .WaitAction ,
335
+ GroupName : "wait-3" ,
336
+ Type : event .Started ,
337
+ },
338
+ },
339
+ {
340
+ // Pod1 reconcile Pending.
341
+ EventType : event .WaitType ,
342
+ WaitEvent : & testutil.ExpWaitEvent {
343
+ GroupName : "wait-3" ,
344
+ Operation : event .ReconcilePending ,
240
345
Identifier : object .UnstructuredToObjMetadata (pod1Obj ),
241
346
},
242
347
},
243
348
{
244
349
// Pod1 confirmed Current.
245
350
EventType : event .WaitType ,
246
351
WaitEvent : & testutil.ExpWaitEvent {
247
- GroupName : "wait-2 " ,
352
+ GroupName : "wait-3 " ,
248
353
Operation : event .Reconciled ,
249
354
Identifier : object .UnstructuredToObjMetadata (pod1Obj ),
250
355
},
@@ -254,7 +359,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
254
359
EventType : event .ActionGroupType ,
255
360
ActionGroupEvent : & testutil.ExpActionGroupEvent {
256
361
Action : event .WaitAction ,
257
- GroupName : "wait-2 " ,
362
+ GroupName : "wait-3 " ,
258
363
Type : event .Finished ,
259
364
},
260
365
},
@@ -279,6 +384,12 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
279
384
}
280
385
Expect (testutil .EventsToExpEvents (applierEvents )).To (testutil .Equal (expEvents ))
281
386
387
+ By ("verify namespace1 created" )
388
+ e2eutil .AssertUnstructuredExists (ctx , c , namespace1Obj )
389
+
390
+ By ("verify namespace2 created" )
391
+ e2eutil .AssertUnstructuredExists (ctx , c , namespace2Obj )
392
+
282
393
By ("verify pod1 created and ready" )
283
394
result := e2eutil .AssertUnstructuredExists (ctx , c , pod1Obj )
284
395
podIP , found , err := object .NestedField (result .Object , "status" , "podIP" )
@@ -503,6 +614,96 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
503
614
Type : event .Finished ,
504
615
},
505
616
},
617
+ {
618
+ // PruneTask start
619
+ EventType : event .ActionGroupType ,
620
+ ActionGroupEvent : & testutil.ExpActionGroupEvent {
621
+ Action : event .DeleteAction ,
622
+ GroupName : "prune-3" ,
623
+ Type : event .Started ,
624
+ },
625
+ },
626
+ {
627
+ // Delete Namespace2 last
628
+ EventType : event .DeleteType ,
629
+ DeleteEvent : & testutil.ExpDeleteEvent {
630
+ GroupName : "prune-3" ,
631
+ Operation : event .Deleted ,
632
+ Identifier : object .UnstructuredToObjMetadata (namespace2Obj ),
633
+ },
634
+ },
635
+ {
636
+ // Delete Namespace1 last
637
+ EventType : event .DeleteType ,
638
+ DeleteEvent : & testutil.ExpDeleteEvent {
639
+ GroupName : "prune-3" ,
640
+ Operation : event .Deleted ,
641
+ Identifier : object .UnstructuredToObjMetadata (namespace1Obj ),
642
+ },
643
+ },
644
+ {
645
+ // PruneTask finished
646
+ EventType : event .ActionGroupType ,
647
+ ActionGroupEvent : & testutil.ExpActionGroupEvent {
648
+ Action : event .DeleteAction ,
649
+ GroupName : "prune-3" ,
650
+ Type : event .Finished ,
651
+ },
652
+ },
653
+ {
654
+ // WaitTask start
655
+ EventType : event .ActionGroupType ,
656
+ ActionGroupEvent : & testutil.ExpActionGroupEvent {
657
+ Action : event .WaitAction ,
658
+ GroupName : "wait-3" ,
659
+ Type : event .Started ,
660
+ },
661
+ },
662
+ {
663
+ // Namespace2 reconcile Pending.
664
+ EventType : event .WaitType ,
665
+ WaitEvent : & testutil.ExpWaitEvent {
666
+ GroupName : "wait-3" ,
667
+ Operation : event .ReconcilePending ,
668
+ Identifier : object .UnstructuredToObjMetadata (namespace2Obj ),
669
+ },
670
+ },
671
+ {
672
+ // Namespace1 reconcile Pending.
673
+ EventType : event .WaitType ,
674
+ WaitEvent : & testutil.ExpWaitEvent {
675
+ GroupName : "wait-3" ,
676
+ Operation : event .ReconcilePending ,
677
+ Identifier : object .UnstructuredToObjMetadata (namespace1Obj ),
678
+ },
679
+ },
680
+ {
681
+ // Namespace1 confirmed NotFound.
682
+ EventType : event .WaitType ,
683
+ WaitEvent : & testutil.ExpWaitEvent {
684
+ GroupName : "wait-3" ,
685
+ Operation : event .Reconciled ,
686
+ Identifier : object .UnstructuredToObjMetadata (namespace1Obj ),
687
+ },
688
+ },
689
+ {
690
+ // Namespace2 confirmed NotFound.
691
+ EventType : event .WaitType ,
692
+ WaitEvent : & testutil.ExpWaitEvent {
693
+ GroupName : "wait-3" ,
694
+ Operation : event .Reconciled ,
695
+ Identifier : object .UnstructuredToObjMetadata (namespace2Obj ),
696
+ },
697
+ },
698
+ {
699
+ // WaitTask finished
700
+ EventType : event .ActionGroupType ,
701
+ ActionGroupEvent : & testutil.ExpActionGroupEvent {
702
+ Action : event .WaitAction ,
703
+ GroupName : "wait-3" ,
704
+ Type : event .Finished ,
705
+ },
706
+ },
506
707
{
507
708
// DeleteInvTask start
508
709
EventType : event .ActionGroupType ,
@@ -532,4 +733,10 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv
532
733
533
734
By ("verify pod3 deleted" )
534
735
e2eutil .AssertUnstructuredDoesNotExist (ctx , c , pod3Obj )
736
+
737
+ By ("verify namespace1 deleted" )
738
+ e2eutil .AssertUnstructuredDoesNotExist (ctx , c , namespace1Obj )
739
+
740
+ By ("verify namespace2 deleted" )
741
+ e2eutil .AssertUnstructuredDoesNotExist (ctx , c , namespace2Obj )
535
742
}
0 commit comments