Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve Cleanup function #1476

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading