Skip to content

Commit 611b4d3

Browse files
authored
Merge pull request #1077 from ozhuraki/envtest-crud-and-upgrade
envtest: Fix upgrade test fail when the tests for CRUD operations fail
2 parents b115ea1 + b693433 commit 611b4d3

8 files changed

+36
-0
lines changed

test/envtest/dlbdeviceplugin_controller_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,8 @@ var _ = Describe("DlbDevicePlugin Controller", func() {
128128

129129
Expect(dp.Spec.Image == image).To(BeTrue())
130130
})
131+
132+
var _ = AfterEach(func() {
133+
CleanupAfter("dlb", &devicepluginv1.DlbDevicePlugin{})
134+
})
131135
})

test/envtest/dsadeviceplugin_controller_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,8 @@ var _ = Describe("DsaDevicePlugin Controller", func() {
162162
Expect(dp.Spec.Image == image).To(BeTrue())
163163
Expect(dp.Spec.InitImage == initimage).To(BeTrue())
164164
})
165+
166+
var _ = AfterEach(func() {
167+
CleanupAfter("dsa", &devicepluginv1.DsaDevicePlugin{})
168+
})
165169
})

test/envtest/fpgadeviceplugin_controller_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,8 @@ var _ = Describe("FpgaDevicePlugin Controller", func() {
143143
Expect(dp.Spec.Image == image).To(BeTrue())
144144
Expect(dp.Spec.InitImage == initimage).To(BeTrue())
145145
})
146+
147+
var _ = AfterEach(func() {
148+
CleanupAfter("fpga", &devicepluginv1.FpgaDevicePlugin{})
149+
})
146150
})

test/envtest/gpudeviceplugin_controller_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,8 @@ var _ = Describe("GpuDevicePlugin Controller", func() {
147147
Expect(dp.Spec.Image == image).To(BeTrue())
148148
Expect(dp.Spec.InitImage == initimage).To(BeTrue())
149149
})
150+
151+
var _ = AfterEach(func() {
152+
CleanupAfter("gpu", &devicepluginv1.GpuDevicePlugin{})
153+
})
150154
})

test/envtest/iaadeviceplugin_controller_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,8 @@ var _ = Describe("IaaDevicePlugin Controller", func() {
166166

167167
Expect(dp.Spec.Image == image).To(BeTrue())
168168
})
169+
170+
var _ = AfterEach(func() {
171+
CleanupAfter("iaa", &devicepluginv1.IaaDevicePlugin{})
172+
})
169173
})

test/envtest/qatdeviceplugin_controller_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,8 @@ var _ = Describe("QatDevicePlugin Controller", func() {
177177
Expect(dp.Spec.Image == image).To(BeTrue())
178178
Expect(dp.Spec.InitImage == initimage).To(BeTrue())
179179
})
180+
181+
var _ = AfterEach(func() {
182+
CleanupAfter("qat", &devicepluginv1.QatDevicePlugin{})
183+
})
180184
})

test/envtest/sgxdeviceplugin_controller_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,8 @@ var _ = Describe("SgxDevicePlugin Controller", func() {
149149
Expect(dp.Spec.Image == image).To(BeTrue())
150150
Expect(dp.Spec.InitImage == initimage).To(BeTrue())
151151
})
152+
153+
var _ = AfterEach(func() {
154+
CleanupAfter("sgx", &devicepluginv1.SgxDevicePlugin{})
155+
})
152156
})

test/envtest/suite_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ func up() {
135135
time.Sleep(time.Second)
136136
}
137137

138+
func CleanupAfter(name string, cr client.Object) {
139+
namespacedName := types.NamespacedName{Namespace: ns, Name: name + "deviceplugin-test"}
140+
141+
if err := k8sClient.Get(ctx, namespacedName, cr); err == nil {
142+
Expect(k8sClient.Delete(ctx, cr)).Should(Succeed())
143+
}
144+
}
145+
138146
func down() {
139147
time.Sleep(time.Second)
140148

0 commit comments

Comments
 (0)