@@ -45,17 +45,21 @@ type AwaitilityInt interface {
4545
4646// AddCleanTasks adds cleaning tasks for the given objects that will be automatically performed at the end of the test execution
4747func AddCleanTasks (t * testing.T , cl client.Client , objects ... client.Object ) {
48- cleaning . addCleanTasks (t , cl , objects ... )
48+ AddCleanTasksWithTimeout (t , cl , defaultTimeout , objects ... )
4949}
5050
51- func (c * cleanManager ) addCleanTasks (t * testing.T , cl client.Client , objects ... client.Object ) {
51+ func AddCleanTasksWithTimeout (t * testing.T , cl client.Client , timeout time.Duration , objects ... client.Object ) {
52+ cleaning .addCleanTasks (t , cl , timeout , objects ... )
53+ }
54+
55+ func (c * cleanManager ) addCleanTasks (t * testing.T , cl client.Client , timeout time.Duration , objects ... client.Object ) {
5256 c .Lock ()
5357 defer c .Unlock ()
5458 for _ , obj := range objects {
5559 if len (c .cleanTasks [t ]) == 0 {
5660 t .Cleanup (c .clean (t ))
5761 }
58- c .cleanTasks [t ] = append (c .cleanTasks [t ], newCleanTask (t , cl , obj ))
62+ c .cleanTasks [t ] = append (c .cleanTasks [t ], newCleanTask (t , cl , obj , timeout ))
5963 }
6064}
6165
@@ -94,16 +98,19 @@ type cleanTask struct {
9498 objToClean client.Object
9599 client client.Client
96100 t * testing.T
101+ timeout time.Duration
97102}
98103
99104func (c * cleanTask ) clean () {
100105 c .Do (c .cleanObject )
101106}
102- func newCleanTask (t * testing.T , cl client.Client , obj client.Object ) * cleanTask {
107+
108+ func newCleanTask (t * testing.T , cl client.Client , obj client.Object , timeout time.Duration ) * cleanTask {
103109 return & cleanTask {
104110 t : t ,
105111 client : cl ,
106112 objToClean : obj ,
113+ timeout : timeout ,
107114 }
108115}
109116
@@ -141,7 +148,7 @@ func (c *cleanTask) cleanObject() {
141148
142149 // wait until deletion is done
143150 c .t .Logf ("waiting until %s: %s is completely deleted" , kind , objToClean .GetName ())
144- err = wait .PollUntilContextTimeout (context .TODO (), defaultRetryInterval , defaultTimeout , true , func (ctx context.Context ) (done bool , err error ) {
151+ err = wait .PollUntilContextTimeout (context .TODO (), defaultRetryInterval , c . timeout , true , func (ctx context.Context ) (done bool , err error ) {
145152 if err := c .client .Get (context .TODO (), test .NamespacedName (objToClean .GetNamespace (), objToClean .GetName ()), objToClean ); err != nil {
146153 if errors .IsNotFound (err ) {
147154 // if the object was UserSignup, then let's check that the MUR is deleted as well
0 commit comments