Skip to content

Commit e3e6e21

Browse files
e2e: fix AfterEach to be in the correct location
'AfterEach' was made to prevent the failure of a plugin pod that occurs due to 'BeforeEach' that deploys a plugin pod. If it is inside a 'Context' it will still occur the same problem. Since current e2e tests have one 'Context' in general, problems were not visible, but it still have problem in logic and would cause the same problems if more 'Contexts' are made. So, this commit fixes 'AfterEach' to be in the correct location. Signed-off-by: Hyeongju Johannes Lee <[email protected]>
1 parent 3744e09 commit e3e6e21

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

test/e2e/dsa/dsa.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ func describe() {
8585
}
8686
})
8787

88+
ginkgo.AfterEach(func() {
89+
ginkgo.By("undeploying DSA plugin")
90+
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "delete", "-k", filepath.Dir(kustomizationPath))
91+
if err := e2epod.WaitForPodNotFoundInNamespace(f.ClientSet, dpPodName, f.Namespace.Name, 30*time.Second); err != nil {
92+
framework.Failf("failed to terminate pod: %v", err)
93+
}
94+
})
95+
8896
ginkgo.Context("When DSA resources are available", func() {
8997
ginkgo.BeforeEach(func() {
9098
ginkgo.By("checking if the resource is allocatable")
@@ -93,14 +101,6 @@ func describe() {
93101
}
94102
})
95103

96-
ginkgo.AfterEach(func() {
97-
ginkgo.By("undeploying DSA plugin")
98-
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "delete", "-k", filepath.Dir(kustomizationPath))
99-
if err := e2epod.WaitForPodNotFoundInNamespace(f.ClientSet, dpPodName, f.Namespace.Name, 30*time.Second); err != nil {
100-
framework.Failf("failed to terminate pod: %v", err)
101-
}
102-
})
103-
104104
ginkgo.It("deploys a demo app", func() {
105105
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", demoPath)
106106

test/e2e/qat/qatplugin_dpdk.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ func describeQatDpdkPlugin() {
8585
}
8686
})
8787

88+
ginkgo.AfterEach(func() {
89+
ginkgo.By("undeploying QAT plugin")
90+
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "delete", "-k", filepath.Dir(kustomizationPath))
91+
if err := e2epod.WaitForPodNotFoundInNamespace(f.ClientSet, dpPodName, f.Namespace.Name, 30*time.Second); err != nil {
92+
framework.Failf("failed to terminate pod: %v", err)
93+
}
94+
})
95+
8896
ginkgo.Context("When QAT Gen4 resources are available", func() {
8997
ginkgo.BeforeEach(func() {
9098
ginkgo.By("checking if the resource is allocatable")
@@ -93,14 +101,6 @@ func describeQatDpdkPlugin() {
93101
}
94102
})
95103

96-
ginkgo.AfterEach(func() {
97-
ginkgo.By("undeploying QAT plugin")
98-
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "delete", "-k", filepath.Dir(kustomizationPath))
99-
if err := e2epod.WaitForPodNotFoundInNamespace(f.ClientSet, dpPodName, f.Namespace.Name, 30*time.Second); err != nil {
100-
framework.Failf("failed to terminate pod: %v", err)
101-
}
102-
})
103-
104104
ginkgo.It("deploys a crypto pod requesting QAT resources", func() {
105105
ginkgo.By("submitting a crypto pod requesting QAT resources")
106106
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", opensslTestYamlPath)
@@ -113,6 +113,7 @@ func describeQatDpdkPlugin() {
113113
framework.Logf("cpa_sample_code output:\n %s", output)
114114
})
115115
})
116+
116117
ginkgo.Context("When QAT Gen2 resources are available", func() {
117118
ginkgo.BeforeEach(func() {
118119
ginkgo.By("checking if the resource is allocatable")

test/e2e/qat/qatplugin_kernel.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ func describeQatKernelPlugin() {
7171
}
7272
})
7373

74+
ginkgo.AfterEach(func() {
75+
ginkgo.By("undeploying QAT plugin")
76+
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "delete", "-f", yamlPath)
77+
if err := e2epod.WaitForPodNotFoundInNamespace(f.ClientSet, dpPodName, f.Namespace.Name, 30*time.Second); err != nil {
78+
framework.Failf("failed to terminate pod: %v", err)
79+
}
80+
})
81+
7482
ginkgo.Context("When QAT resources are available", func() {
7583
ginkgo.BeforeEach(func() {
7684
ginkgo.By("checking if the resource is allocatable")
@@ -79,14 +87,6 @@ func describeQatKernelPlugin() {
7987
}
8088
})
8189

82-
ginkgo.AfterEach(func() {
83-
ginkgo.By("undeploying QAT plugin")
84-
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "delete", "-f", yamlPath)
85-
if err := e2epod.WaitForPodNotFoundInNamespace(f.ClientSet, dpPodName, f.Namespace.Name, 30*time.Second); err != nil {
86-
framework.Failf("failed to terminate pod: %v", err)
87-
}
88-
})
89-
9090
ginkgo.It("deploys a pod requesting QAT resources", func() {
9191
ginkgo.By("submitting a pod requesting QAT resources")
9292
podSpec := &v1.Pod{

0 commit comments

Comments
 (0)