Skip to content

Commit 4af94db

Browse files
committed
CBG-4444 create an env var override for bucket op timeout
1 parent d61c392 commit 4af94db

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

base/main_test_bucket_pool_config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ const (
5858

5959
// Creates buckets with a specific number of number of replicas
6060
tbpEnvBucketNumReplicas = "SG_TEST_BUCKET_NUM_REPLICAS"
61+
62+
// bucket op timeout is the number of seconds that kv operations will retry. Increasing this can be necessary when flushing buckets rapidly.
63+
tbpEnvBucketOpTimeout = "SG_TEST_BUCKET_OP_TIMEOUT"
6164
)
6265

6366
// TestsUseNamedCollections returns true if the tests use named collections.

base/main_test_cluster.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ package base
1111
import (
1212
"context"
1313
"fmt"
14+
"os"
15+
"strconv"
1416
"strings"
1517
"time"
1618

@@ -54,11 +56,17 @@ func newTestCluster(ctx context.Context, server string, tbp *TestBucketPool) *tb
5456
// getGocbClusterForTest makes cluster connection. Callers must close. Returns the cluster and the connection string used to connect.
5557
func getGocbClusterForTest(ctx context.Context, server string) (*gocb.Cluster, string) {
5658

57-
testClusterTimeout := 10 * time.Second
5859
spec := BucketSpec{
59-
Server: server,
60-
TLSSkipVerify: true,
61-
BucketOpTimeout: &testClusterTimeout,
60+
Server: server,
61+
TLSSkipVerify: true,
62+
}
63+
bucketOpTimeout := os.Getenv(tbpEnvBucketOpTimeout)
64+
if bucketOpTimeout != "" {
65+
secs, err := strconv.Atoi(bucketOpTimeout)
66+
if err != nil {
67+
FatalfCtx(ctx, "Couldn't parse %s: %v", tbpEnvBucketOpTimeout, err)
68+
}
69+
spec.BucketOpTimeout = Ptr(time.Duration(secs) * time.Second)
6270
}
6371
connStr, err := spec.GetGoCBConnString()
6472
if err != nil {

0 commit comments

Comments
 (0)