From 79e3c06f0e64737212b1a8d2eb43e8df7f9bcafc Mon Sep 17 00:00:00 2001 From: Kasem Alem Date: Wed, 11 Dec 2024 16:56:34 +0200 Subject: [PATCH] fix: improve Cleanup function (#1476) fix Cleanup function Signed-off-by: Kasem Alem Co-authored-by: Kasem Alem --- tests/integration-service/group-snapshots-tests.go | 2 +- tests/integration-service/integration.go | 13 ++++++------- .../status-reporting-to-pullrequest.go | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/integration-service/group-snapshots-tests.go b/tests/integration-service/group-snapshots-tests.go index d700b34da..772c6b9ab 100644 --- a/tests/integration-service/group-snapshots-tests.go +++ b/tests/integration-service/group-snapshots-tests.go @@ -76,7 +76,7 @@ var _ = framework.IntegrationServiceSuiteDescribe("Creation of group snapshots f AfterAll(func() { if !CurrentSpecReport().Failed() { - cleanup(*f, testNamespace, applicationName, componentA.Name) + cleanup(*f, testNamespace, applicationName, componentA.Name, snapshot) } // Delete new branches created by PaC and a testing branch used as a component's base branch diff --git a/tests/integration-service/integration.go b/tests/integration-service/integration.go index 6240f824f..43d625619 100644 --- a/tests/integration-service/integration.go +++ b/tests/integration-service/integration.go @@ -62,9 +62,7 @@ var _ = framework.IntegrationServiceSuiteDescribe("Integration Service E2E tests AfterAll(func() { if !CurrentSpecReport().Failed() { - cleanup(*f, testNamespace, applicationName, componentName) - - Expect(f.AsKubeAdmin.IntegrationController.DeleteSnapshot(snapshotPush, testNamespace)).To(Succeed()) + cleanup(*f, testNamespace, applicationName, componentName, snapshotPush) } // Delete new branches created by PaC and a testing branch used as a component's base branch @@ -253,7 +251,7 @@ var _ = framework.IntegrationServiceSuiteDescribe("Integration Service E2E tests AfterAll(func() { if !CurrentSpecReport().Failed() { - cleanup(*f, testNamespace, applicationName, componentName) + cleanup(*f, testNamespace, applicationName, componentName, snapshotPush) } // Delete new branches created by PaC and a testing branch used as a component's base branch @@ -493,16 +491,17 @@ func createComponentWithCustomBranch(f framework.Framework, testNamespace, appli return originalComponent } -func cleanup(f framework.Framework, testNamespace, applicationName, componentName string) { +func cleanup(f framework.Framework, testNamespace, applicationName, componentName string, snapshot *appstudioApi.Snapshot) { if !CurrentSpecReport().Failed() { - Expect(f.AsKubeAdmin.HasController.DeleteApplication(applicationName, testNamespace, false)).To(Succeed()) - Expect(f.AsKubeAdmin.HasController.DeleteComponent(componentName, testNamespace, false)).To(Succeed()) + Expect(f.AsKubeAdmin.IntegrationController.DeleteSnapshot(snapshot, testNamespace)).To(Succeed()) integrationTestScenarios, err := f.AsKubeAdmin.IntegrationController.GetIntegrationTestScenarios(applicationName, testNamespace) Expect(err).ShouldNot(HaveOccurred()) for _, testScenario := range *integrationTestScenarios { Expect(f.AsKubeAdmin.IntegrationController.DeleteIntegrationTestScenario(&testScenario, testNamespace)).To(Succeed()) } + Expect(f.AsKubeAdmin.HasController.DeleteComponent(componentName, testNamespace, false)).To(Succeed()) + Expect(f.AsKubeAdmin.HasController.DeleteApplication(applicationName, testNamespace, false)).To(Succeed()) Expect(f.SandboxController.DeleteUserSignup(f.UserName)).To(BeTrue()) } } diff --git a/tests/integration-service/status-reporting-to-pullrequest.go b/tests/integration-service/status-reporting-to-pullrequest.go index 092dcd7ef..121444363 100644 --- a/tests/integration-service/status-reporting-to-pullrequest.go +++ b/tests/integration-service/status-reporting-to-pullrequest.go @@ -59,7 +59,7 @@ var _ = framework.IntegrationServiceSuiteDescribe("Status Reporting of Integrati AfterAll(func() { if !CurrentSpecReport().Failed() { - cleanup(*f, testNamespace, applicationName, componentName) + cleanup(*f, testNamespace, applicationName, componentName, snapshot) } // Delete new branches created by PaC and a testing branch used as a component's base branch