From 5c8e89ed61ad521b44ae6b20f7add85df41cf264 Mon Sep 17 00:00:00 2001 From: anushka <78717608+anushka567@users.noreply.github.com> Date: Wed, 11 Dec 2024 16:03:27 +0530 Subject: [PATCH] Increasing mount timeout threshold and taking minimum of 10 iterations (#2780) * using minimum of 10 mount operations to compare with threshold * increased threshold * nits --- .../gcsfuse_mount_timeout_test.go | 33 +++++++++++++------ .../mount_timeout/mount_timeout_test.go | 12 +++---- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/tools/integration_tests/mount_timeout/gcsfuse_mount_timeout_test.go b/tools/integration_tests/mount_timeout/gcsfuse_mount_timeout_test.go index 83e5b074f6..b05a917a1e 100644 --- a/tools/integration_tests/mount_timeout/gcsfuse_mount_timeout_test.go +++ b/tools/integration_tests/mount_timeout/gcsfuse_mount_timeout_test.go @@ -16,6 +16,7 @@ package mount_timeout import ( "fmt" + "math" "os" "path" "testing" @@ -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. @@ -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 } diff --git a/tools/integration_tests/mount_timeout/mount_timeout_test.go b/tools/integration_tests/mount_timeout/mount_timeout_test.go index c322b2c533..727e37125a 100644 --- a/tools/integration_tests/mount_timeout/mount_timeout_test.go +++ b/tools/integration_tests/mount_timeout/mount_timeout_test.go @@ -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_" )