@@ -78,30 +78,21 @@ var _ = Describe("validating CRP when resources exists", Ordered, func() {
7878 })
7979
8080 AfterAll (func () {
81- //By("removing the owner reference of the namespace")
82- //// Remove the extra owner reference from the namespace to avoid deletion delays.
83- //// With the new change to use foreground deletion on applied Work resources, the Work will be blocked
84- //// from deleting until the applied work is fully deleted. If the namespace has
85- //// multiple owner references, it won’t be deleted immediately, which can cause resource overlap
86- //// and flakiness in subsequent tests.
87- //removeOtherOwner(allMemberClusters[0])
88-
8981 By ("deleting created work resources on member cluster" )
9082 cleanWorkResourcesOnCluster (allMemberClusters [0 ])
9183
84+ By (fmt .Sprintf ("deleting placement %s" , crpName ))
85+ cleanupCRP (crpName )
86+
9287 // Check if work is deleted. Needed to ensure that the Work resource is cleaned up before the next CRP is created.
9388 // This is because the Work resource is created with a finalizer that blocks deletion until the all applied work
9489 // and applied work itself is successfully deleted. If the Work resource is not deleted, it can cause resource overlap
9590 // and flakiness in subsequent tests.
9691 By ("Check if work is deleted" )
9792 Eventually (func () bool {
9893 work := & placementv1beta1.Work {}
99- return errors .IsNotFound (hubClient .Get (ctx , types.NamespacedName {Name : "crp-1- work" , Namespace : "fleet-member-kind-cluster-1" }, work ))
94+ return errors .IsNotFound (hubClient .Get (ctx , types.NamespacedName {Name : fmt . Sprintf ( "%s- work" , crpName ), Namespace : fmt . Sprintf ( "fleet-member-%s" , allMemberClusterNames [ 0 ]) }, work ))
10095 }, 6 * eventuallyDuration , eventuallyInterval ).Should (BeTrue (), "Work resource should be deleted from hub" )
101-
102- By (fmt .Sprintf ("deleting placement %s" , crpName ))
103- cleanupCRP (crpName )
104-
10596 })
10697
10798 It ("should update CRP status as expected" , func () {
@@ -166,7 +157,7 @@ var _ = Describe("validating CRP when resources exists", Ordered, func() {
166157 By ("Check if work is deleted" )
167158 Eventually (func () bool {
168159 work := & placementv1beta1.Work {}
169- return errors .IsNotFound (hubClient .Get (ctx , types.NamespacedName {Name : "crp-1- work" , Namespace : "fleet-member-kind-cluster-1" }, work ))
160+ return errors .IsNotFound (hubClient .Get (ctx , types.NamespacedName {Name : fmt . Sprintf ( "%s- work" , crpName ), Namespace : fmt . Sprintf ( "fleet-member-%s" , allMemberClusterNames [ 0 ]) }, work ))
170161 }, 6 * eventuallyDuration , eventuallyInterval ).Should (BeTrue (), "Work resource should be deleted from hub" )
171162
172163 By (fmt .Sprintf ("deleting placement %s" , crpName ))
@@ -281,29 +272,21 @@ var _ = Describe("validating CRP when resources exists", Ordered, func() {
281272 })
282273
283274 AfterAll (func () {
284- //By("removing the owner reference of the namespace")
285- //// Remove the extra owner reference from the namespace to avoid deletion delays.
286- //// With the new change to use foreground deletion on applied Work resources, the Work will be blocked
287- //// from deleting until the applied work is fully deleted. If the namespace has
288- //// multiple owner references, it won’t be deleted immediately, which can cause resource overlap
289- //// and flakiness in subsequent tests.
290- //removeOtherOwner(allMemberClusters[0])
291-
292275 By ("deleting created work resources on member cluster" )
293276 cleanWorkResourcesOnCluster (allMemberClusters [0 ])
294277
278+ By (fmt .Sprintf ("deleting placement %s" , crpName ))
279+ cleanupCRP (crpName )
280+
295281 // Check if work is deleted. Needed to ensure that the Work resource is cleaned up before the next CRP is created.
296282 // This is because the Work resource is created with a finalizer that blocks deletion until the all applied work
297283 // and applied work itself is successfully deleted. If the Work resource is not deleted, it can cause resource overlap
298284 // and flakiness in subsequent tests.
299285 By ("Check if work is deleted" )
300286 Eventually (func () bool {
301287 work := & placementv1beta1.Work {}
302- return errors .IsNotFound (hubClient .Get (ctx , types.NamespacedName {Name : "crp-1- work" , Namespace : "fleet-member-kind-cluster-1" }, work ))
288+ return errors .IsNotFound (hubClient .Get (ctx , types.NamespacedName {Name : fmt . Sprintf ( "%s- work" , crpName ), Namespace : fmt . Sprintf ( "fleet-member-%s" , allMemberClusterNames [ 0 ]) }, work ))
303289 }, 6 * eventuallyDuration , eventuallyInterval ).Should (BeTrue (), "Work resource should be deleted from hub" )
304-
305- By (fmt .Sprintf ("deleting placement %s" , crpName ))
306- cleanupCRP (crpName )
307290 })
308291
309292 It ("should update CRP status as expected" , func () {
@@ -434,29 +417,21 @@ var _ = Describe("validating CRP when resources exists", Ordered, func() {
434417 })
435418
436419 AfterAll (func () {
437- //By("removing the owner reference of the namespace")
438- //// Remove the extra owner reference from the namespace to avoid deletion delays.
439- //// With the new change to use foreground deletion on applied Work resources, the Work will be blocked
440- //// from deleting until the applied work is fully deleted. If the namespace has
441- //// multiple owner references, it won’t be deleted immediately, which can cause resource overlap
442- //// and flakiness in subsequent tests.
443- //removeOtherOwner(allMemberClusters[0])
444-
445420 By ("deleting created work resources on member cluster" )
446421 cleanWorkResourcesOnCluster (allMemberClusters [0 ])
447422
423+ By (fmt .Sprintf ("deleting placement %s" , crpName ))
424+ cleanupCRP (crpName )
425+
448426 // Check if work is deleted. Needed to ensure that the Work resource is cleaned up before the next CRP is created.
449427 // This is because the Work resource is created with a finalizer that blocks deletion until the all applied work
450428 // and applied work itself is successfully deleted. If the Work resource is not deleted, it can cause resource overlap
451429 // and flakiness in subsequent tests.
452430 By ("Check if work is deleted" )
453431 Eventually (func () bool {
454432 work := & placementv1beta1.Work {}
455- return errors .IsNotFound (hubClient .Get (ctx , types.NamespacedName {Name : "crp-1- work" , Namespace : "fleet-member-kind-cluster-1" }, work ))
433+ return errors .IsNotFound (hubClient .Get (ctx , types.NamespacedName {Name : fmt . Sprintf ( "%s- work" , crpName ), Namespace : fmt . Sprintf ( "fleet-member-%s" , allMemberClusterNames [ 0 ]) }, work ))
456434 }, 7 * eventuallyDuration , eventuallyInterval ).Should (BeTrue (), "Work resource should be deleted from hub" )
457-
458- By (fmt .Sprintf ("deleting placement %s" , crpName ))
459- cleanupCRP (crpName )
460435 })
461436
462437 It ("should update CRP status as expected" , func () {
0 commit comments