mirror of https://github.com/fluxcd/cli-utils.git
				
				
				
			chore: add test for cross namespace depends-on
This commit is contained in:
		
							parent
							
								
									a5fa28845d
								
							
						
					
					
						commit
						aeff41d692
					
				|  | @ -26,13 +26,28 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 
 | 
 | ||||||
| 	inv := invConfig.InvWrapperFunc(invConfig.FactoryFunc(inventoryName, namespaceName, "test")) | 	inv := invConfig.InvWrapperFunc(invConfig.FactoryFunc(inventoryName, namespaceName, "test")) | ||||||
| 
 | 
 | ||||||
| 	pod1Obj := e2eutil.WithDependsOn(e2eutil.WithNamespace(e2eutil.ManifestToUnstructured(pod1), namespaceName), fmt.Sprintf("/namespaces/%s/Pod/pod3", namespaceName)) | 	namespace1Name := fmt.Sprintf("%s-ns1", namespaceName) | ||||||
| 	pod2Obj := e2eutil.WithNamespace(e2eutil.ManifestToUnstructured(pod2), namespaceName) | 	namespace1Obj := e2eutil.UnstructuredNamespace(namespace1Name) | ||||||
| 	pod3Obj := e2eutil.WithDependsOn(e2eutil.WithNamespace(e2eutil.ManifestToUnstructured(pod3), namespaceName), fmt.Sprintf("/namespaces/%s/Pod/pod2", namespaceName)) | 
 | ||||||
|  | 	namespace2Name := fmt.Sprintf("%s-ns2", namespaceName) | ||||||
|  | 	namespace2Obj := e2eutil.UnstructuredNamespace(namespace2Name) | ||||||
|  | 
 | ||||||
|  | 	pod1Obj := e2eutil.ManifestToUnstructured(pod1) | ||||||
|  | 	pod1Obj = e2eutil.WithNamespace(pod1Obj, namespace1Name) | ||||||
|  | 	pod1Obj = e2eutil.WithDependsOn(pod1Obj, fmt.Sprintf("/namespaces/%s/Pod/pod3", namespace1Name)) | ||||||
|  | 
 | ||||||
|  | 	pod2Obj := e2eutil.ManifestToUnstructured(pod2) | ||||||
|  | 	pod2Obj = e2eutil.WithNamespace(pod2Obj, namespace2Name) | ||||||
|  | 
 | ||||||
|  | 	pod3Obj := e2eutil.ManifestToUnstructured(pod3) | ||||||
|  | 	pod3Obj = e2eutil.WithNamespace(pod3Obj, namespace1Name) | ||||||
|  | 	pod3Obj = e2eutil.WithDependsOn(pod3Obj, fmt.Sprintf("/namespaces/%s/Pod/pod2", namespace2Name)) | ||||||
| 
 | 
 | ||||||
| 	// Dependency order: pod1 -> pod3 -> pod2
 | 	// Dependency order: pod1 -> pod3 -> pod2
 | ||||||
| 	// Apply order: pod2, pod3, pod1
 | 	// Apply order: pod2, pod3, pod1
 | ||||||
| 	resources := []*unstructured.Unstructured{ | 	resources := []*unstructured.Unstructured{ | ||||||
|  | 		namespace1Obj, | ||||||
|  | 		namespace2Obj, | ||||||
| 		pod1Obj, | 		pod1Obj, | ||||||
| 		pod2Obj, | 		pod2Obj, | ||||||
| 		pod3Obj, | 		pod3Obj, | ||||||
|  | @ -76,13 +91,21 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			// Apply Pod2 first
 | 			// Apply Namespace1 first
 | ||||||
| 			EventType: event.ApplyType, | 			EventType: event.ApplyType, | ||||||
| 			ApplyEvent: &testutil.ExpApplyEvent{ | 			ApplyEvent: &testutil.ExpApplyEvent{ | ||||||
| 				GroupName:  "apply-0", | 				GroupName:  "apply-0", | ||||||
| 				Operation:  event.Created, | 				Operation:  event.Created, | ||||||
| 				Identifier: object.UnstructuredToObjMetadata(pod2Obj), | 				Identifier: object.UnstructuredToObjMetadata(namespace1Obj), | ||||||
| 				Error:      nil, | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// Apply Namespace2 first
 | ||||||
|  | 			EventType: event.ApplyType, | ||||||
|  | 			ApplyEvent: &testutil.ExpApplyEvent{ | ||||||
|  | 				GroupName:  "apply-0", | ||||||
|  | 				Operation:  event.Created, | ||||||
|  | 				Identifier: object.UnstructuredToObjMetadata(namespace2Obj), | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
|  | @ -104,11 +127,93 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			// Pod2 reconcile Pending.
 | 			// Namespace1 reconcile Pending.
 | ||||||
| 			EventType: event.WaitType, | 			EventType: event.WaitType, | ||||||
| 			WaitEvent: &testutil.ExpWaitEvent{ | 			WaitEvent: &testutil.ExpWaitEvent{ | ||||||
| 				GroupName:  "wait-0", | 				GroupName:  "wait-0", | ||||||
| 				Operation:  event.ReconcilePending, | 				Operation:  event.ReconcilePending, | ||||||
|  | 				Identifier: object.UnstructuredToObjMetadata(namespace1Obj), | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// Namespace2 reconcile Pending.
 | ||||||
|  | 			EventType: event.WaitType, | ||||||
|  | 			WaitEvent: &testutil.ExpWaitEvent{ | ||||||
|  | 				GroupName:  "wait-0", | ||||||
|  | 				Operation:  event.ReconcilePending, | ||||||
|  | 				Identifier: object.UnstructuredToObjMetadata(namespace2Obj), | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// Namespace1 confirmed Current.
 | ||||||
|  | 			EventType: event.WaitType, | ||||||
|  | 			WaitEvent: &testutil.ExpWaitEvent{ | ||||||
|  | 				GroupName:  "wait-0", | ||||||
|  | 				Operation:  event.Reconciled, | ||||||
|  | 				Identifier: object.UnstructuredToObjMetadata(namespace1Obj), | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// Namespace2 confirmed Current.
 | ||||||
|  | 			EventType: event.WaitType, | ||||||
|  | 			WaitEvent: &testutil.ExpWaitEvent{ | ||||||
|  | 				GroupName:  "wait-0", | ||||||
|  | 				Operation:  event.Reconciled, | ||||||
|  | 				Identifier: object.UnstructuredToObjMetadata(namespace2Obj), | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// WaitTask finished
 | ||||||
|  | 			EventType: event.ActionGroupType, | ||||||
|  | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
|  | 				Action:    event.WaitAction, | ||||||
|  | 				GroupName: "wait-0", | ||||||
|  | 				Type:      event.Finished, | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// ApplyTask start
 | ||||||
|  | 			EventType: event.ActionGroupType, | ||||||
|  | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
|  | 				Action:    event.ApplyAction, | ||||||
|  | 				GroupName: "apply-1", | ||||||
|  | 				Type:      event.Started, | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// Apply Pod2 first
 | ||||||
|  | 			EventType: event.ApplyType, | ||||||
|  | 			ApplyEvent: &testutil.ExpApplyEvent{ | ||||||
|  | 				GroupName:  "apply-1", | ||||||
|  | 				Operation:  event.Created, | ||||||
|  | 				Identifier: object.UnstructuredToObjMetadata(pod2Obj), | ||||||
|  | 				Error:      nil, | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// ApplyTask finished
 | ||||||
|  | 			EventType: event.ActionGroupType, | ||||||
|  | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
|  | 				Action:    event.ApplyAction, | ||||||
|  | 				GroupName: "apply-1", | ||||||
|  | 				Type:      event.Finished, | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// WaitTask start
 | ||||||
|  | 			EventType: event.ActionGroupType, | ||||||
|  | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
|  | 				Action:    event.WaitAction, | ||||||
|  | 				GroupName: "wait-1", | ||||||
|  | 				Type:      event.Started, | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// Pod2 reconcile Pending.
 | ||||||
|  | 			EventType: event.WaitType, | ||||||
|  | 			WaitEvent: &testutil.ExpWaitEvent{ | ||||||
|  | 				GroupName:  "wait-1", | ||||||
|  | 				Operation:  event.ReconcilePending, | ||||||
| 				Identifier: object.UnstructuredToObjMetadata(pod2Obj), | 				Identifier: object.UnstructuredToObjMetadata(pod2Obj), | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|  | @ -116,7 +221,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			// Pod2 confirmed Current.
 | 			// Pod2 confirmed Current.
 | ||||||
| 			EventType: event.WaitType, | 			EventType: event.WaitType, | ||||||
| 			WaitEvent: &testutil.ExpWaitEvent{ | 			WaitEvent: &testutil.ExpWaitEvent{ | ||||||
| 				GroupName:  "wait-0", | 				GroupName:  "wait-1", | ||||||
| 				Operation:  event.Reconciled, | 				Operation:  event.Reconciled, | ||||||
| 				Identifier: object.UnstructuredToObjMetadata(pod2Obj), | 				Identifier: object.UnstructuredToObjMetadata(pod2Obj), | ||||||
| 			}, | 			}, | ||||||
|  | @ -126,7 +231,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			EventType: event.ActionGroupType, | 			EventType: event.ActionGroupType, | ||||||
| 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
| 				Action:    event.WaitAction, | 				Action:    event.WaitAction, | ||||||
| 				GroupName: "wait-0", | 				GroupName: "wait-1", | ||||||
| 				Type:      event.Finished, | 				Type:      event.Finished, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|  | @ -135,7 +240,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			EventType: event.ActionGroupType, | 			EventType: event.ActionGroupType, | ||||||
| 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
| 				Action:    event.ApplyAction, | 				Action:    event.ApplyAction, | ||||||
| 				GroupName: "apply-1", | 				GroupName: "apply-2", | ||||||
| 				Type:      event.Started, | 				Type:      event.Started, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|  | @ -143,7 +248,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			// Apply Pod3 second
 | 			// Apply Pod3 second
 | ||||||
| 			EventType: event.ApplyType, | 			EventType: event.ApplyType, | ||||||
| 			ApplyEvent: &testutil.ExpApplyEvent{ | 			ApplyEvent: &testutil.ExpApplyEvent{ | ||||||
| 				GroupName:  "apply-1", | 				GroupName:  "apply-2", | ||||||
| 				Operation:  event.Created, | 				Operation:  event.Created, | ||||||
| 				Identifier: object.UnstructuredToObjMetadata(pod3Obj), | 				Identifier: object.UnstructuredToObjMetadata(pod3Obj), | ||||||
| 				Error:      nil, | 				Error:      nil, | ||||||
|  | @ -154,7 +259,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			EventType: event.ActionGroupType, | 			EventType: event.ActionGroupType, | ||||||
| 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
| 				Action:    event.ApplyAction, | 				Action:    event.ApplyAction, | ||||||
| 				GroupName: "apply-1", | 				GroupName: "apply-2", | ||||||
| 				Type:      event.Finished, | 				Type:      event.Finished, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|  | @ -163,7 +268,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			EventType: event.ActionGroupType, | 			EventType: event.ActionGroupType, | ||||||
| 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
| 				Action:    event.WaitAction, | 				Action:    event.WaitAction, | ||||||
| 				GroupName: "wait-1", | 				GroupName: "wait-2", | ||||||
| 				Type:      event.Started, | 				Type:      event.Started, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|  | @ -171,7 +276,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			// Pod3 reconcile Pending.
 | 			// Pod3 reconcile Pending.
 | ||||||
| 			EventType: event.WaitType, | 			EventType: event.WaitType, | ||||||
| 			WaitEvent: &testutil.ExpWaitEvent{ | 			WaitEvent: &testutil.ExpWaitEvent{ | ||||||
| 				GroupName:  "wait-1", | 				GroupName:  "wait-2", | ||||||
| 				Operation:  event.ReconcilePending, | 				Operation:  event.ReconcilePending, | ||||||
| 				Identifier: object.UnstructuredToObjMetadata(pod3Obj), | 				Identifier: object.UnstructuredToObjMetadata(pod3Obj), | ||||||
| 			}, | 			}, | ||||||
|  | @ -180,7 +285,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			// Pod3 confirmed Current.
 | 			// Pod3 confirmed Current.
 | ||||||
| 			EventType: event.WaitType, | 			EventType: event.WaitType, | ||||||
| 			WaitEvent: &testutil.ExpWaitEvent{ | 			WaitEvent: &testutil.ExpWaitEvent{ | ||||||
| 				GroupName:  "wait-1", | 				GroupName:  "wait-2", | ||||||
| 				Operation:  event.Reconciled, | 				Operation:  event.Reconciled, | ||||||
| 				Identifier: object.UnstructuredToObjMetadata(pod3Obj), | 				Identifier: object.UnstructuredToObjMetadata(pod3Obj), | ||||||
| 			}, | 			}, | ||||||
|  | @ -190,7 +295,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			EventType: event.ActionGroupType, | 			EventType: event.ActionGroupType, | ||||||
| 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
| 				Action:    event.WaitAction, | 				Action:    event.WaitAction, | ||||||
| 				GroupName: "wait-1", | 				GroupName: "wait-2", | ||||||
| 				Type:      event.Finished, | 				Type:      event.Finished, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|  | @ -199,7 +304,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			EventType: event.ActionGroupType, | 			EventType: event.ActionGroupType, | ||||||
| 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
| 				Action:    event.ApplyAction, | 				Action:    event.ApplyAction, | ||||||
| 				GroupName: "apply-2", | 				GroupName: "apply-3", | ||||||
| 				Type:      event.Started, | 				Type:      event.Started, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|  | @ -207,7 +312,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			// Apply Pod1 third
 | 			// Apply Pod1 third
 | ||||||
| 			EventType: event.ApplyType, | 			EventType: event.ApplyType, | ||||||
| 			ApplyEvent: &testutil.ExpApplyEvent{ | 			ApplyEvent: &testutil.ExpApplyEvent{ | ||||||
| 				GroupName:  "apply-2", | 				GroupName:  "apply-3", | ||||||
| 				Operation:  event.Created, | 				Operation:  event.Created, | ||||||
| 				Identifier: object.UnstructuredToObjMetadata(pod1Obj), | 				Identifier: object.UnstructuredToObjMetadata(pod1Obj), | ||||||
| 				Error:      nil, | 				Error:      nil, | ||||||
|  | @ -218,7 +323,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			EventType: event.ActionGroupType, | 			EventType: event.ActionGroupType, | ||||||
| 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
| 				Action:    event.ApplyAction, | 				Action:    event.ApplyAction, | ||||||
| 				GroupName: "apply-2", | 				GroupName: "apply-3", | ||||||
| 				Type:      event.Finished, | 				Type:      event.Finished, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|  | @ -227,7 +332,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			EventType: event.ActionGroupType, | 			EventType: event.ActionGroupType, | ||||||
| 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
| 				Action:    event.WaitAction, | 				Action:    event.WaitAction, | ||||||
| 				GroupName: "wait-2", | 				GroupName: "wait-3", | ||||||
| 				Type:      event.Started, | 				Type:      event.Started, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|  | @ -235,7 +340,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			// Pod1 reconcile Pending.
 | 			// Pod1 reconcile Pending.
 | ||||||
| 			EventType: event.WaitType, | 			EventType: event.WaitType, | ||||||
| 			WaitEvent: &testutil.ExpWaitEvent{ | 			WaitEvent: &testutil.ExpWaitEvent{ | ||||||
| 				GroupName:  "wait-2", | 				GroupName:  "wait-3", | ||||||
| 				Operation:  event.ReconcilePending, | 				Operation:  event.ReconcilePending, | ||||||
| 				Identifier: object.UnstructuredToObjMetadata(pod1Obj), | 				Identifier: object.UnstructuredToObjMetadata(pod1Obj), | ||||||
| 			}, | 			}, | ||||||
|  | @ -244,7 +349,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			// Pod1 confirmed Current.
 | 			// Pod1 confirmed Current.
 | ||||||
| 			EventType: event.WaitType, | 			EventType: event.WaitType, | ||||||
| 			WaitEvent: &testutil.ExpWaitEvent{ | 			WaitEvent: &testutil.ExpWaitEvent{ | ||||||
| 				GroupName:  "wait-2", | 				GroupName:  "wait-3", | ||||||
| 				Operation:  event.Reconciled, | 				Operation:  event.Reconciled, | ||||||
| 				Identifier: object.UnstructuredToObjMetadata(pod1Obj), | 				Identifier: object.UnstructuredToObjMetadata(pod1Obj), | ||||||
| 			}, | 			}, | ||||||
|  | @ -254,7 +359,7 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 			EventType: event.ActionGroupType, | 			EventType: event.ActionGroupType, | ||||||
| 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
| 				Action:    event.WaitAction, | 				Action:    event.WaitAction, | ||||||
| 				GroupName: "wait-2", | 				GroupName: "wait-3", | ||||||
| 				Type:      event.Finished, | 				Type:      event.Finished, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|  | @ -279,6 +384,12 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 	} | 	} | ||||||
| 	Expect(testutil.EventsToExpEvents(applierEvents)).To(testutil.Equal(expEvents)) | 	Expect(testutil.EventsToExpEvents(applierEvents)).To(testutil.Equal(expEvents)) | ||||||
| 
 | 
 | ||||||
|  | 	By("verify namespace1 created") | ||||||
|  | 	e2eutil.AssertUnstructuredExists(ctx, c, namespace1Obj) | ||||||
|  | 
 | ||||||
|  | 	By("verify namespace2 created") | ||||||
|  | 	e2eutil.AssertUnstructuredExists(ctx, c, namespace2Obj) | ||||||
|  | 
 | ||||||
| 	By("verify pod1 created and ready") | 	By("verify pod1 created and ready") | ||||||
| 	result := e2eutil.AssertUnstructuredExists(ctx, c, pod1Obj) | 	result := e2eutil.AssertUnstructuredExists(ctx, c, pod1Obj) | ||||||
| 	podIP, found, err := object.NestedField(result.Object, "status", "podIP") | 	podIP, found, err := object.NestedField(result.Object, "status", "podIP") | ||||||
|  | @ -503,6 +614,96 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 				Type:      event.Finished, | 				Type:      event.Finished, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// PruneTask start
 | ||||||
|  | 			EventType: event.ActionGroupType, | ||||||
|  | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
|  | 				Action:    event.DeleteAction, | ||||||
|  | 				GroupName: "prune-3", | ||||||
|  | 				Type:      event.Started, | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// Delete Namespace2 last
 | ||||||
|  | 			EventType: event.DeleteType, | ||||||
|  | 			DeleteEvent: &testutil.ExpDeleteEvent{ | ||||||
|  | 				GroupName:  "prune-3", | ||||||
|  | 				Operation:  event.Deleted, | ||||||
|  | 				Identifier: object.UnstructuredToObjMetadata(namespace2Obj), | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// Delete Namespace1 last
 | ||||||
|  | 			EventType: event.DeleteType, | ||||||
|  | 			DeleteEvent: &testutil.ExpDeleteEvent{ | ||||||
|  | 				GroupName:  "prune-3", | ||||||
|  | 				Operation:  event.Deleted, | ||||||
|  | 				Identifier: object.UnstructuredToObjMetadata(namespace1Obj), | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// PruneTask finished
 | ||||||
|  | 			EventType: event.ActionGroupType, | ||||||
|  | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
|  | 				Action:    event.DeleteAction, | ||||||
|  | 				GroupName: "prune-3", | ||||||
|  | 				Type:      event.Finished, | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// WaitTask start
 | ||||||
|  | 			EventType: event.ActionGroupType, | ||||||
|  | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
|  | 				Action:    event.WaitAction, | ||||||
|  | 				GroupName: "wait-3", | ||||||
|  | 				Type:      event.Started, | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// Namespace2 reconcile Pending.
 | ||||||
|  | 			EventType: event.WaitType, | ||||||
|  | 			WaitEvent: &testutil.ExpWaitEvent{ | ||||||
|  | 				GroupName:  "wait-3", | ||||||
|  | 				Operation:  event.ReconcilePending, | ||||||
|  | 				Identifier: object.UnstructuredToObjMetadata(namespace2Obj), | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// Namespace1 reconcile Pending.
 | ||||||
|  | 			EventType: event.WaitType, | ||||||
|  | 			WaitEvent: &testutil.ExpWaitEvent{ | ||||||
|  | 				GroupName:  "wait-3", | ||||||
|  | 				Operation:  event.ReconcilePending, | ||||||
|  | 				Identifier: object.UnstructuredToObjMetadata(namespace1Obj), | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// Namespace1 confirmed NotFound.
 | ||||||
|  | 			EventType: event.WaitType, | ||||||
|  | 			WaitEvent: &testutil.ExpWaitEvent{ | ||||||
|  | 				GroupName:  "wait-3", | ||||||
|  | 				Operation:  event.Reconciled, | ||||||
|  | 				Identifier: object.UnstructuredToObjMetadata(namespace1Obj), | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// Namespace2 confirmed NotFound.
 | ||||||
|  | 			EventType: event.WaitType, | ||||||
|  | 			WaitEvent: &testutil.ExpWaitEvent{ | ||||||
|  | 				GroupName:  "wait-3", | ||||||
|  | 				Operation:  event.Reconciled, | ||||||
|  | 				Identifier: object.UnstructuredToObjMetadata(namespace2Obj), | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			// WaitTask finished
 | ||||||
|  | 			EventType: event.ActionGroupType, | ||||||
|  | 			ActionGroupEvent: &testutil.ExpActionGroupEvent{ | ||||||
|  | 				Action:    event.WaitAction, | ||||||
|  | 				GroupName: "wait-3", | ||||||
|  | 				Type:      event.Finished, | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			// DeleteInvTask start
 | 			// DeleteInvTask start
 | ||||||
| 			EventType: event.ActionGroupType, | 			EventType: event.ActionGroupType, | ||||||
|  | @ -532,4 +733,10 @@ func dependsOnTest(ctx context.Context, c client.Client, invConfig invconfig.Inv | ||||||
| 
 | 
 | ||||||
| 	By("verify pod3 deleted") | 	By("verify pod3 deleted") | ||||||
| 	e2eutil.AssertUnstructuredDoesNotExist(ctx, c, pod3Obj) | 	e2eutil.AssertUnstructuredDoesNotExist(ctx, c, pod3Obj) | ||||||
|  | 
 | ||||||
|  | 	By("verify namespace1 deleted") | ||||||
|  | 	e2eutil.AssertUnstructuredDoesNotExist(ctx, c, namespace1Obj) | ||||||
|  | 
 | ||||||
|  | 	By("verify namespace2 deleted") | ||||||
|  | 	e2eutil.AssertUnstructuredDoesNotExist(ctx, c, namespace2Obj) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -402,3 +402,11 @@ func UnstructuredIsTerminating(obj *unstructured.Unstructured) bool { | ||||||
| 	} | 	} | ||||||
| 	return false | 	return false | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | func UnstructuredNamespace(name string) *unstructured.Unstructured { | ||||||
|  | 	u := &unstructured.Unstructured{} | ||||||
|  | 	u.SetAPIVersion("v1") | ||||||
|  | 	u.SetKind("Namespace") | ||||||
|  | 	u.SetName(name) | ||||||
|  | 	return u | ||||||
|  | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue