Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBG-4423 Do not enable cross vector versioning for test #7247

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions base/main_test_bucket_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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)
}
}

Expand Down
37 changes: 0 additions & 37 deletions base/main_test_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Loading