From 6a6de5902915663d16dc55f1704f667a83b5c7ad Mon Sep 17 00:00:00 2001 From: Tor Colvin Date: Mon, 16 Dec 2024 11:53:36 -0500 Subject: [PATCH] CBG-4423 Do not enable cross vector versioning for test - backport changes from anemone for test harness to retry setting enableCrossVectorVersioning in case we do want to enable it. - disable mobile XDCR in 3.x branch since we do not want to use this until 4.0 anyway --- base/main_test_bucket_pool.go | 26 +++++++++++++----------- base/main_test_cluster.go | 37 ----------------------------------- 2 files changed, 15 insertions(+), 48 deletions(-) diff --git a/base/main_test_bucket_pool.go b/base/main_test_bucket_pool.go index c79d2231d4..445087af57 100644 --- a/base/main_test_bucket_pool.go +++ b/base/main_test_bucket_pool.go @@ -121,6 +121,7 @@ func NewTestBucketPoolWithOptions(ctx context.Context, bucketReadierFunc TBPBuck unclosedBuckets: make(map[string]map[string]struct{}), useExistingBucket: TestUseExistingBucket(), useDefaultScope: options.UseDefaultScope, + skipMobileXDCR: true, // do not set up enableCrossClusterVersioning until Sync Gateway 4.x } tbp.cluster = newTestCluster(ctx, UnitTestUrl(), &tbp) @@ -131,12 +132,6 @@ func NewTestBucketPoolWithOptions(ctx context.Context, bucketReadierFunc TBPBuck } tbp.skipCollections = !useCollections - useMobileXDCR, err := tbp.cluster.mobileXDCRCompatible(ctx) - if err != nil { - tbp.Fatalf(ctx, "%s", err) - } - tbp.skipMobileXDCR = !useMobileXDCR - tbp.verbose.Set(tbpVerbose()) // Start up an async readier worker to process dirty buckets @@ -450,6 +445,7 @@ func (tbp *TestBucketPool) setXDCRBucketSetting(ctx context.Context, bucket Buck tbp.Logf(ctx, "Setting crossClusterVersioningEnabled=true") + // retry for 1 minute to get this bucket setting, MB-63675 store, ok := AsCouchbaseBucketStore(bucket) if !ok { tbp.Fatalf(ctx, "unable to get server management endpoints. Underlying bucket type was not GoCBBucket") @@ -459,12 +455,20 @@ func (tbp *TestBucketPool) setXDCRBucketSetting(ctx context.Context, bucket Buck posts.Add("enableCrossClusterVersioning", "true") url := fmt.Sprintf("/pools/default/buckets/%s", store.GetName()) - output, statusCode, err := store.MgmtRequest(ctx, http.MethodPost, url, "application/x-www-form-urlencoded", strings.NewReader(posts.Encode())) + // retry for 1 minute to get this bucket setting, MB-63675 + _, err := RetryLoop(ctx, "setXDCRBucketSetting", func() (bool, error, interface{}) { + output, statusCode, err := store.MgmtRequest(ctx, http.MethodPost, url, "application/x-www-form-urlencoded", strings.NewReader(posts.Encode())) + if err != nil { + tbp.Fatalf(ctx, "request to mobile XDCR bucket setting failed, status code: %d error: %w output: %s", statusCode, err, string(output)) + } + if statusCode != http.StatusOK { + err := fmt.Errorf("request to mobile XDCR bucket setting failed with status code, %d, output: %s", statusCode, string(output)) + return true, err, nil + } + return false, nil, nil + }, CreateMaxDoublingSleeperFunc(200, 500, 500)) if err != nil { - tbp.Fatalf(ctx, "request to mobile XDCR bucket setting failed, status code: %d error: %v output: %s", statusCode, err, string(output)) - } - if statusCode != http.StatusOK { - tbp.Fatalf(ctx, "request to mobile XDCR bucket setting failed with status code, %d, output: %s", statusCode, string(output)) + tbp.Fatalf(ctx, "Couldn't set crossClusterVersioningEnabled: %v", err) } } diff --git a/base/main_test_cluster.go b/base/main_test_cluster.go index b6af39fc35..98b3b8648d 100644 --- a/base/main_test_cluster.go +++ b/base/main_test_cluster.go @@ -17,14 +17,6 @@ import ( "github.com/couchbase/gocb/v2" ) -// firstServerVersionToSupportMobileXDCR this is the first server version to support Mobile XDCR feature -var firstServerVersionToSupportMobileXDCR = &ComparableBuildVersion{ - epoch: 0, - major: 7, - minor: 6, - patch: 2, -} - type clusterLogFunc func(ctx context.Context, format string, args ...interface{}) // tbpCluster represents a gocb v2 cluster @@ -205,32 +197,3 @@ func (c *tbpCluster) supportsMobileRBAC() (bool, error) { } return major >= 7 && minor >= 1, nil } - -// mobileXDCRCompatible checks if a cluster is mobile XDCR compatible, a cluster must be enterprise edition AND > 7.6.1 -func (c *tbpCluster) mobileXDCRCompatible(ctx context.Context) (bool, error) { - enterprise, err := c.isServerEnterprise() - if err != nil { - return false, err - } - if !enterprise { - return false, nil - } - - // take server version, server version will be the first 5 character of version string - // in the form of x.x.x - vrs := c.version[:5] - - // convert the above string into a comparable string - version, err := NewComparableBuildVersionFromString(vrs) - if err != nil { - return false, err - } - - if !version.Less(firstServerVersionToSupportMobileXDCR) { - c.supportsHLV = true - return true, nil - } - c.logger(ctx, "cluster does not support mobile XDCR") - - return false, nil -}