@@ -197,7 +197,9 @@ var _ = Describe("InstanceSet Controller", func() {
197197
198198 By ("delete the ITS object" )
199199 Expect (k8sClient .Delete (ctx , itsObj )).Should (Succeed ())
200- Eventually (testapps .CheckObjExists (& testCtx , itsKey , & workloads.InstanceSet {}, false )).Should (Succeed ())
200+
201+ By ("check its object NOT deleted" )
202+ Consistently (testapps .CheckObjExists (& testCtx , itsKey , & workloads.InstanceSet {}, true )).Should (Succeed ())
201203
202204 By ("check pods deleted" )
203205 podKey := types.NamespacedName {
@@ -206,12 +208,16 @@ var _ = Describe("InstanceSet Controller", func() {
206208 }
207209 Eventually (testapps .CheckObjExists (& testCtx , podKey , & corev1.Pod {}, false )).Should (Succeed ())
208210
209- By ("check PVCs deleted" )
211+ By ("check PVCs deleted, but the pvc-protection finalizer prevent the pvc to be deleted physically " )
210212 pvcKey := types.NamespacedName {
211213 Namespace : itsObj .Namespace ,
212214 Name : fmt .Sprintf ("%s-%s-0" , pvc .Name , itsObj .Name ),
213215 }
214- Eventually (testapps .CheckObjExists (& testCtx , pvcKey , & corev1.PersistentVolumeClaim {}, false )).Should (Succeed ())
216+ Eventually (testapps .CheckObj (& testCtx , pvcKey , func (g Gomega , pvc * corev1.PersistentVolumeClaim ) {
217+ g .Expect (pvc .DeletionTimestamp ).ShouldNot (BeNil ())
218+ g .Expect (pvc .Finalizers ).To (HaveLen (1 ))
219+ g .Expect (pvc .Finalizers [0 ]).To (Equal ("kubernetes.io/pvc-protection" ))
220+ })).Should (Succeed ())
215221 })
216222
217223 It ("when deleted - retain" , func () {
@@ -233,12 +239,14 @@ var _ = Describe("InstanceSet Controller", func() {
233239 }
234240 Eventually (testapps .CheckObjExists (& testCtx , podKey , & corev1.Pod {}, false )).Should (Succeed ())
235241
236- By ("check PVCs retained" )
242+ By ("check PVCs retained and not deleted " )
237243 pvcKey := types.NamespacedName {
238244 Namespace : itsObj .Namespace ,
239245 Name : fmt .Sprintf ("%s-%s-0" , pvc .Name , itsObj .Name ),
240246 }
241- Eventually (testapps .CheckObjExists (& testCtx , pvcKey , & corev1.PersistentVolumeClaim {}, true )).Should (Succeed ())
247+ Consistently (testapps .CheckObj (& testCtx , pvcKey , func (g Gomega , pvc * corev1.PersistentVolumeClaim ) {
248+ g .Expect (pvc .DeletionTimestamp ).Should (BeNil ())
249+ })).Should (Succeed ())
242250 })
243251
244252 It ("when scaled - delete" , func () {
@@ -261,12 +269,16 @@ var _ = Describe("InstanceSet Controller", func() {
261269 }
262270 Eventually (testapps .CheckObjExists (& testCtx , podKey , & corev1.Pod {}, false )).Should (Succeed ())
263271
264- By ("check PVCs deleted" )
272+ By ("check PVCs deleted, but the pvc-protection finalizer prevent the pvc to be deleted physically " )
265273 pvcKey := types.NamespacedName {
266274 Namespace : itsObj .Namespace ,
267275 Name : fmt .Sprintf ("%s-%s-0" , pvc .Name , itsObj .Name ),
268276 }
269- Eventually (testapps .CheckObjExists (& testCtx , pvcKey , & corev1.PersistentVolumeClaim {}, false )).Should (Succeed ())
277+ Eventually (testapps .CheckObj (& testCtx , pvcKey , func (g Gomega , pvc * corev1.PersistentVolumeClaim ) {
278+ g .Expect (pvc .DeletionTimestamp ).ShouldNot (BeNil ())
279+ g .Expect (pvc .Finalizers ).To (HaveLen (1 ))
280+ g .Expect (pvc .Finalizers [0 ]).To (Equal ("kubernetes.io/pvc-protection" ))
281+ })).Should (Succeed ())
270282 })
271283
272284 It ("when scaled - retain" , func () {
@@ -289,12 +301,14 @@ var _ = Describe("InstanceSet Controller", func() {
289301 }
290302 Eventually (testapps .CheckObjExists (& testCtx , podKey , & corev1.Pod {}, false )).Should (Succeed ())
291303
292- By ("check PVCs retained" )
304+ By ("check PVCs retained and not deleted " )
293305 pvcKey := types.NamespacedName {
294306 Namespace : itsObj .Namespace ,
295307 Name : fmt .Sprintf ("%s-%s-0" , pvc .Name , itsObj .Name ),
296308 }
297- Eventually (testapps .CheckObjExists (& testCtx , pvcKey , & corev1.PersistentVolumeClaim {}, true )).Should (Succeed ())
309+ Consistently (testapps .CheckObj (& testCtx , pvcKey , func (g Gomega , pvc * corev1.PersistentVolumeClaim ) {
310+ g .Expect (pvc .DeletionTimestamp ).Should (BeNil ())
311+ })).Should (Succeed ())
298312 })
299313 })
300314
0 commit comments