Skip to content

Commit

Permalink
Increasing mount timeout threshold and taking minimum of 10 iterations (
Browse files Browse the repository at this point in the history
#2780)

* using minimum of 10 mount operations to compare with threshold

* increased threshold

* nits
  • Loading branch information
anushka567 authored Dec 11, 2024
1 parent 4a36886 commit 5c8e89e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
33 changes: 23 additions & 10 deletions tools/integration_tests/mount_timeout/gcsfuse_mount_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package mount_timeout

import (
"fmt"
"math"
"os"
"path"
"testing"
Expand All @@ -29,6 +30,10 @@ import (
"github.com/stretchr/testify/suite"
)

const (
iterations int = 10
)

func TestMountTimeout(t *testing.T) {
if os.Getenv("TEST_ENV") == testEnvGCEUSCentral {
// Set strict region based timeout values if testing environment is GCE VM in us-central.
Expand Down Expand Up @@ -97,19 +102,27 @@ func (testSuite *MountTimeoutTest) TearDownTest() {
// mountOrTimeout mounts the bucket with the given client protocol. If the time taken
// exceeds the expected for the particular test case , an error is thrown and test will fail.
func (testSuite *MountTimeoutTest) mountOrTimeout(bucketName, mountDir, clientProtocol string, expectedMountTime time.Duration) error {
args := []string{"--client-protocol", clientProtocol, bucketName, testSuite.dir}
start := time.Now()
if err := mounting.MountGcsfuse(testSuite.gcsfusePath, args); err != nil {
return err
}
defer func() {
minMountTime := time.Duration(math.MaxInt64)

// Iterating 10 times to account for randomness in time taken to mount.
for i := 0; i < iterations; i++ {
args := []string{"--client-protocol", clientProtocol, bucketName, testSuite.dir}
start := time.Now()
if err := mounting.MountGcsfuse(testSuite.gcsfusePath, args); err != nil {
return err
}
mountTime := time.Since(start)

minMountTime = time.Duration(math.Min(float64(minMountTime), float64(mountTime)))

if err := util.Unmount(mountDir); err != nil {
fmt.Fprintf(os.Stderr, "Warning: unmount failed: %v\n", err)
err = fmt.Errorf("Warning: unmount failed: %v\n", err)
return err
}
}()
}

if mountTime := time.Since(start); mountTime > expectedMountTime {
return fmt.Errorf("[Client Protocol: %s]Mounting failed due to timeout(exceeding %f seconds).Time taken for the mounting %s: %f sec", clientProtocol, expectedMountTime.Seconds(), bucketName, mountTime.Seconds())
if minMountTime > expectedMountTime {
return fmt.Errorf("[Client Protocol: %s] Mounting failed due to timeout (exceeding %f seconds). Time taken for mounting %s: %f sec", clientProtocol, expectedMountTime.Seconds(), bucketName, minMountTime.Seconds())
}
return nil
}
Expand Down
12 changes: 6 additions & 6 deletions tools/integration_tests/mount_timeout/mount_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ const (
dualRegionAsiaBucket string = "mount_timeout_test_bucket_asia1"
singleRegionUSCentralBucket string = "mount_timeout_test_bucket_us-central1"
singleRegionAsiaEastBucket string = "mount_timeout_test_bucket_asia-east1"
singleRegionAsiaEastExpectedMountTime time.Duration = 3200 * time.Millisecond
multiRegionUSExpectedMountTime time.Duration = 2000 * time.Millisecond
multiRegionAsiaExpectedMountTime time.Duration = 4500 * time.Millisecond
dualRegionUSExpectedMountTime time.Duration = 2700 * time.Millisecond
dualRegionAsiaExpectedMountTime time.Duration = 3750 * time.Millisecond
singleRegionUSCentralExpectedMountTime time.Duration = 2000 * time.Millisecond
singleRegionAsiaEastExpectedMountTime time.Duration = 5500 * time.Millisecond
multiRegionUSExpectedMountTime time.Duration = 4500 * time.Millisecond
multiRegionAsiaExpectedMountTime time.Duration = 7500 * time.Millisecond
dualRegionUSExpectedMountTime time.Duration = 4500 * time.Millisecond
dualRegionAsiaExpectedMountTime time.Duration = 6250 * time.Millisecond
singleRegionUSCentralExpectedMountTime time.Duration = 2500 * time.Millisecond
relaxedExpectedMountTime time.Duration = 8000 * time.Millisecond
logfilePathPrefix string = "/tmp/gcsfuse_mount_timeout_"
)
Expand Down

0 comments on commit 5c8e89e

Please sign in to comment.