@@ -134,14 +134,14 @@ type TestConfig struct {
134
134
CreateTargetPathCmd string
135
135
CreateStagingPathCmd string
136
136
// Timeout for the executed commands for path creation.
137
- CreatePathCmdTimeout int
137
+ CreatePathCmdTimeout time. Duration
138
138
139
139
// Commands to be executed for customized removal of the target and staging
140
140
// paths. Thie command must be available on the host where sanity runs.
141
141
RemoveTargetPathCmd string
142
142
RemoveStagingPathCmd string
143
143
// Timeout for the executed commands for path removal.
144
- RemovePathCmdTimeout int
144
+ RemovePathCmdTimeout time. Duration
145
145
146
146
// IDGen is an interface for callers to provide a
147
147
// generator for valid Volume and Node IDs. Defaults to
@@ -171,8 +171,8 @@ func NewTestConfig() TestConfig {
171
171
return TestConfig {
172
172
TargetPath : os .TempDir () + "/csi-mount" ,
173
173
StagingPath : os .TempDir () + "/csi-staging" ,
174
- CreatePathCmdTimeout : 10 ,
175
- RemovePathCmdTimeout : 10 ,
174
+ CreatePathCmdTimeout : 10 * time . Second ,
175
+ RemovePathCmdTimeout : 10 * time . Second ,
176
176
TestVolumeSize : 10 * 1024 * 1024 * 1024 , // 10 GiB
177
177
IDGen : & DefaultIDGenerator {},
178
178
}
@@ -307,7 +307,7 @@ func (sc *TestContext) Finalize() {
307
307
// createMountTargetLocation takes a target path parameter and creates the
308
308
// target path using a custom command, custom function or falls back to the
309
309
// default using mkdir and returns the new target path.
310
- func createMountTargetLocation (targetPath string , createPathCmd string , customCreateDir func (string ) (string , error ), timeout int ) (string , error ) {
310
+ func createMountTargetLocation (targetPath string , createPathCmd string , customCreateDir func (string ) (string , error ), timeout time. Duration ) (string , error ) {
311
311
312
312
// Return the target path if empty.
313
313
if targetPath == "" {
@@ -318,7 +318,7 @@ func createMountTargetLocation(targetPath string, createPathCmd string, customCr
318
318
319
319
if createPathCmd != "" {
320
320
// Create the target path using the create path command.
321
- ctx , cancel := context .WithTimeout (context .Background (), time . Duration ( timeout ) * time . Second )
321
+ ctx , cancel := context .WithTimeout (context .Background (), timeout )
322
322
defer cancel ()
323
323
324
324
cmd := exec .CommandContext (ctx , createPathCmd , targetPath )
@@ -352,13 +352,13 @@ func createMountTargetLocation(targetPath string, createPathCmd string, customCr
352
352
// removeMountTargetLocation takes a target path parameter and removes the path
353
353
// using a custom command, custom function or falls back to the default removal
354
354
// by deleting the path on the host.
355
- func removeMountTargetLocation (targetPath string , removePathCmd string , customRemovePath func (string ) error , timeout int ) error {
355
+ func removeMountTargetLocation (targetPath string , removePathCmd string , customRemovePath func (string ) error , timeout time. Duration ) error {
356
356
if targetPath == "" {
357
357
return nil
358
358
}
359
359
360
360
if removePathCmd != "" {
361
- ctx , cancel := context .WithTimeout (context .Background (), time . Duration ( timeout ) * time . Second )
361
+ ctx , cancel := context .WithTimeout (context .Background (), timeout )
362
362
defer cancel ()
363
363
364
364
cmd := exec .CommandContext (ctx , removePathCmd , targetPath )
0 commit comments