MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestServerlessGoCBConnectionString

Function TestServerlessGoCBConnectionString

rest/serverless_test.go:177–225  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

175}
176
177func TestServerlessGoCBConnectionString(t *testing.T) {
178 if base.UnitTestUrlIsWalrus() {
179 t.Skip("This test only works against Couchbase Server due to testing gocb connection strings")
180 }
181 tests := []struct {
182 name string
183 expectedConnstrQuery string
184 specKvConn string
185 kvConnCount int
186 }{
187 {
188 name: "serverless connection",
189 expectedConnstrQuery: "?dcp_buffer_size=1048576&idle_http_connection_timeout=90000&kv_buffer_size=1048576&kv_pool_size=1&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
190 kvConnCount: 1,
191 },
192 {
193 name: "serverless connection with kv pool specified",
194 specKvConn: "?idle_http_connection_timeout=90000&kv_pool_size=3&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
195 expectedConnstrQuery: "?dcp_buffer_size=1048576&idle_http_connection_timeout=90000&kv_buffer_size=1048576&kv_pool_size=3&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
196 kvConnCount: 3,
197 },
198 }
199 for _, test := range tests {
200 t.Run(test.name, func(t *testing.T) {
201 t.Skip("here")
202 ctx := base.TestCtx(t)
203 tb := base.GetTestBucket(t)
204 defer tb.Close(ctx)
205 bucketServer := tb.BucketSpec.Server
206 expectedServer := bucketServer + test.expectedConnstrQuery
207
208 if test.specKvConn != "" {
209 tb.BucketSpec.Server = bucketServer + "?kv_pool_size=3"
210 }
211
212 rt := NewRestTester(t, &RestTesterConfig{CustomTestBucket: tb.NoCloseClone(), PersistentConfig: true, serverless: true})
213 defer rt.Close()
214 sc := rt.ServerContext()
215 require.True(t, sc.Config.IsServerless())
216
217 resp := rt.SendAdminRequest(http.MethodPut, "/db/", fmt.Sprintf(`{"bucket": "%s", "use_views": %t, "num_index_replicas": 0}`,
218 tb.GetName(), base.TestsDisableGSI()))
219 RequireStatus(t, resp, http.StatusCreated)
220
221 assert.Equal(t, expectedServer, sc.getBucketSpec("db").Server)
222 })
223 }
224
225}
226
227func TestServerlessUnsupportedOptions(t *testing.T) {
228 RequireBucketSpecificCredentials(t)

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
ServerContextMethod · 0.95
SendAdminRequestMethod · 0.95
UnitTestUrlIsWalrusFunction · 0.92
TestCtxFunction · 0.92
GetTestBucketFunction · 0.92
TestsDisableGSIFunction · 0.92
NewRestTesterFunction · 0.85
RequireStatusFunction · 0.85
NoCloseCloneMethod · 0.80
IsServerlessMethod · 0.80
getBucketSpecMethod · 0.80

Tested by

no test coverage detected