move clean operation to AfterEach

Signed-off-by: changzhen <changzhen5@huawei.com>
This commit is contained in:
changzhen 2022-03-22 22:42:40 +08:00
parent 104d4aa0a3
commit 9ffbcbf261
1 changed files with 26 additions and 22 deletions

View File

@ -257,6 +257,19 @@ var _ = ginkgo.Describe("[MCS] Multi-Cluster Service testing", func() {
framework.RemoveService(exportClusterClient, demoService.Namespace, demoService.Name)
})
ginkgo.AfterEach(func() {
ginkgo.By("Cleanup", func() {
err := controlPlaneClient.Delete(context.TODO(), &serviceExport)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
err = controlPlaneClient.Delete(context.TODO(), &serviceImport)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
})
framework.RemovePropagationPolicy(karmadaClient, exportPolicy.Namespace, exportPolicy.Name)
framework.RemovePropagationPolicy(karmadaClient, importPolicy.Namespace, importPolicy.Name)
})
ginkgo.It("Export Service from source-clusters, import Service to destination-clusters", func() {
importClusterClient := framework.GetClusterClient(serviceImportClusterName)
gomega.Expect(importClusterClient).ShouldNot(gomega.BeNil())
@ -346,17 +359,6 @@ var _ = ginkgo.Describe("[MCS] Multi-Cluster Service testing", func() {
return podLogs(context.TODO(), importClusterClient, demoService.Namespace, pod.Name)
}, pollTimeout, pollInterval).Should(gomega.Equal("hello\n"))
})
ginkgo.By("Cleanup", func() {
err := controlPlaneClient.Delete(context.TODO(), &serviceExport)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
err = controlPlaneClient.Delete(context.TODO(), &serviceImport)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
})
framework.RemovePropagationPolicy(karmadaClient, exportPolicy.Namespace, exportPolicy.Name)
framework.RemovePropagationPolicy(karmadaClient, importPolicy.Namespace, importPolicy.Name)
})
})
@ -400,6 +402,19 @@ var _ = ginkgo.Describe("[MCS] Multi-Cluster Service testing", func() {
framework.RemoveService(exportClusterClient, demoService.Namespace, demoService.Name)
})
ginkgo.AfterEach(func() {
ginkgo.By("Cleanup", func() {
err := controlPlaneClient.Delete(context.TODO(), &serviceExport)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
err = controlPlaneClient.Delete(context.TODO(), &serviceImport)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
})
framework.RemovePropagationPolicy(karmadaClient, exportPolicy.Namespace, exportPolicy.Name)
framework.RemovePropagationPolicy(karmadaClient, importPolicy.Namespace, importPolicy.Name)
})
ginkgo.It("Update Deployment's replicas", func() {
exportClusterClient := framework.GetClusterClient(serviceExportClusterName)
gomega.Expect(exportClusterClient).ShouldNot(gomega.BeNil())
@ -467,17 +482,6 @@ var _ = ginkgo.Describe("[MCS] Multi-Cluster Service testing", func() {
return epNums, nil
}, pollTimeout, pollInterval).Should(gomega.Equal(2))
})
ginkgo.By("Cleanup", func() {
err := controlPlaneClient.Delete(context.TODO(), &serviceExport)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
err = controlPlaneClient.Delete(context.TODO(), &serviceImport)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
})
framework.RemovePropagationPolicy(karmadaClient, exportPolicy.Namespace, exportPolicy.Name)
framework.RemovePropagationPolicy(karmadaClient, importPolicy.Namespace, importPolicy.Name)
})
})
})