-
Notifications
You must be signed in to change notification settings - Fork 140
CBG-4895: Allow tuning of dcp_read_buffer and kv_buffer server connstr parameters #7829
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes the serverless-only gating of dcp_read_buffer and kv_buffer connection string parameters so they can be tuned for regular Couchbase Server deployments, and adds a test to validate expected connection string formation.
- Removes the IsServerless() conditional, applying DefaultServerlessGoCBConnStringParams unconditionally.
- Adds a new test (TestUnsupportedOptions) covering explicit and default parameter cases in a serverless test configuration.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| rest/server_context.go | Removes serverless check so serverless-specific default connection params are always applied; enables unsupported tuning options for all deployments. |
| rest/api_test.go | Adds TestUnsupportedOptions to assert connection string parameters with and without explicitly provided unsupported options. |
rest/api_test.go
Outdated
| base.DebugfCtx(t.Context(), base.KeySGTest, "additional logs") | ||
| } | ||
|
|
||
| func TestUnsupportedOptions( t *testing.T){ |
Copilot
AI
Oct 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extraneous space after '(' in the test function signature deviates from standard Go formatting (gofmt would produce func TestUnsupportedOptions(t *testing.T)). Remove the space to keep consistency.
| func TestUnsupportedOptions( t *testing.T){ | |
| func TestUnsupportedOptions(t *testing.T){ |
rest/api_test.go
Outdated
| tb.GetName(), base.TestsDisableGSI())) | ||
| RequireStatus(t, resp, http.StatusCreated) | ||
| } | ||
| assert.Equal(t, test.expectedConnStr, sc.getBucketSpec("db").Server) |
Copilot
AI
Oct 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The test asserts exact string equality of the full connection string, making it brittle to harmless reordering of query parameters. Consider parsing the query portion and asserting key-value presence (e.g. using url.Parse + comparison of a map) rather than relying on order-specific full-string matching.
rest/api_test.go
Outdated
| } | ||
|
|
||
| func TestUnsupportedOptions(t *testing.T) { | ||
| RequireBucketSpecificCredentials(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RequireBucketSpecificCredentials should be changed to specify that it needs CBS RBAC credentials.
This test probably needs SG_TEST_BACKING_STORE=couchbase to fall into the gocb sections, but it would actually be served by a function that said:
if base.UnitTestUrlIsWalrus() {
t.Skip("This test only works against Couchbase Server since it requires a gocb bucket")
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is applicable, given, the unit test has been refactored to directly generate the bucketspec
rest/server_context.go
Outdated
| if serverConfig.IsServerless() { | ||
| params := base.DefaultServerlessGoCBConnStringParams() | ||
|
|
||
| if strings.HasPrefix(server, "couchbase") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if strings.HasPrefix(server, "couchbase") { | |
| if !base.ServerIsWalrus(server) { |
rest/server_context.go
Outdated
| } | ||
|
|
||
| if !base.ServerIsWalrus(server) { | ||
| if !base.ServerIsWalrus(server) && server != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is production code so I'm cautious about modifying it, what's an example test that fails? It feels like we should define a Server in all cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TestDeleteDatabasePointingAtSameBucket kept failing if I did not add server != "". When I dug into it, the test tries to create a db on the same bucket.
When the createDB handler handles this request and then tries to setup the config passed here, it updates the config string to "" from nil, while inheriting the connection string from bootstrapConfig, here. Since this is a unit test, so we do not set the bootstrap config, therefore, I think it is expected for the Config.Server to be set to "".
This is why I added this additional check, I know this condition looks very suspicious, but I'm not not sure as to how else do I prevent the test from failing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A slight correction to my comment earlier,
while inheriting the connection string from bootstrapConfig, here. Since this is a unit test, so we do not set the bootstrap config, therefore, I think it is expected for the Config.Server to be set to "".
It does not inherit the existing Bootstrap config, instead it inherits an empty bootstrap config
|
|
||
| var server string | ||
| if config.Server != nil { | ||
| if config.Server != nil && *config.Server != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved the check for empty string from _getOrAddDatabaseFromConfig, i'm doing the check inside the GetBucketSpec
CBG-4895
Describe your PR here...
dcp_read_bufferandkv_bufferare only supported if CBS is serverless, need to enable them for regular CBS as well for perf tests in capellaPre-review checklist
fmt.Print,log.Print, ...)base.UD(docID),base.MD(dbName))docs/apiDependencies (if applicable)
Integration Tests
GSI=true,xattrs=truehttps://jenkins.sgwdev.com/job/SyncGatewayIntegration/142/GSI=true,xattrs=truehttps://jenkins.sgwdev.com/job/SyncGatewayIntegration/146/GSI=true,xattrs=truehttps://jenkins.sgwdev.com/job/SyncGatewayIntegration/147/