@@ -332,16 +332,32 @@ func TestSetVolumeOwnershipMode(t *testing.T) {
332
332
func TestProgressTracking (t * testing.T ) {
333
333
alwaysApplyPolicy := v1 .FSGroupChangeAlways
334
334
var expectedGID int64 = 9999
335
+
336
+ // capture original variable
337
+ originalfilePermissionChangeFunc := filePermissionChangeFunc
338
+ originalProgressReportDuration := progressReportDuration
339
+ originalfirstEventReportDuration := firstEventReportDuration
340
+
335
341
var permissionSleepDuration = 5 * time .Millisecond
336
- // how often to report the events
342
+
343
+ // Override how often progress is reported
337
344
progressReportDuration = 200 * time .Millisecond
345
+ // Override when first event about progress is reported
338
346
firstEventReportDuration = 50 * time .Millisecond
339
347
340
- filePermissionChangeFunc = func (filename string , fsGroup * int64 , _ bool , _ os.FileInfo ) error {
341
- t .Logf ("Calling file permission change for %s with gid %d" , filename , * fsGroup )
348
+ // Override how permission change is applied, so as to artificially slow
349
+ // permission change
350
+ filePermissionChangeFunc = func (filename string , fsGroup * int64 , readonly bool , info os.FileInfo ) error {
342
351
time .Sleep (permissionSleepDuration )
352
+ originalfilePermissionChangeFunc (filename , fsGroup , readonly , info )
343
353
return nil
344
354
}
355
+ t .Cleanup (func () {
356
+ filePermissionChangeFunc = originalfilePermissionChangeFunc
357
+ progressReportDuration = originalProgressReportDuration
358
+ firstEventReportDuration = originalfirstEventReportDuration
359
+ })
360
+
345
361
pod := & v1.Pod {
346
362
ObjectMeta : metav1.ObjectMeta {
347
363
Name : "pod1" ,
0 commit comments