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

Function TestServerlessUnsupportedOptions

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

Source from the content-addressed store, hash-verified

225}
226
227func TestServerlessUnsupportedOptions(t *testing.T) {
228 RequireBucketSpecificCredentials(t)
229 tests := []struct {
230 name string
231 expectedConnStr string
232 kvBuffer int
233 dcpBuffer int
234 }{
235 {
236 name: "unsupported options specified",
237 expectedConnStr: "?dcp_buffer_size=3000&idle_http_connection_timeout=90000&kv_buffer_size=2000&kv_pool_size=1&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
238 kvBuffer: 2000,
239 dcpBuffer: 3000,
240 },
241 {
242 name: "default serverless",
243 expectedConnStr: "?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",
244 },
245 }
246 for _, test := range tests {
247 t.Run(test.name, func(t *testing.T) {
248 ctx := base.TestCtx(t)
249 tb := base.GetTestBucket(t)
250 defer tb.Close(ctx)
251 bucketServer := tb.BucketSpec.Server
252 test.expectedConnStr = bucketServer + test.expectedConnStr
253
254 rt := NewRestTester(t, &RestTesterConfig{CustomTestBucket: tb.NoCloseClone(), PersistentConfig: true, serverless: true})
255 defer rt.Close()
256 sc := rt.ServerContext()
257 require.True(t, sc.Config.IsServerless())
258
259 if test.name == "unsupported options specified" {
260 resp := rt.SendAdminRequest(http.MethodPut, "/db/", fmt.Sprintf(`{"bucket": "%s", "use_views": %t, "num_index_replicas": 0, "unsupported": {"dcp_read_buffer": %d, "kv_buffer": %d}}`,
261 tb.GetName(), base.TestsDisableGSI(), test.dcpBuffer, test.kvBuffer))
262 RequireStatus(t, resp, http.StatusCreated)
263 } else {
264 resp := rt.SendAdminRequest(http.MethodPut, "/db/", fmt.Sprintf(`{"bucket": "%s", "use_views": %t, "num_index_replicas": 0}`,
265 tb.GetName(), base.TestsDisableGSI()))
266 RequireStatus(t, resp, http.StatusCreated)
267 }
268 assert.Equal(t, test.expectedConnStr, sc.getBucketSpec("db").Server)
269 })
270 }
271
272}
273
274func TestServerlessSuspendDatabase(t *testing.T) {
275 RequireBucketSpecificCredentials(t)

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
ServerContextMethod · 0.95
SendAdminRequestMethod · 0.95
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