Skip to content

Commit

Permalink
fix: improve Cleanup function (#1476)
Browse files Browse the repository at this point in the history
fix Cleanup function

Signed-off-by: Kasem Alem <[email protected]>
Co-authored-by: Kasem Alem <[email protected]>
  • Loading branch information
kasemAlem and Kasem Alem authored Dec 11, 2024
1 parent b51de25 commit 79e3c06
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/integration-service/group-snapshots-tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions tests/integration-service/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 79e3c06

Please sign in to comment.