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

Function TestPutDBBytesRead

rest/bytes_read_public_api_test.go:421–454  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

419}
420
421func TestPutDBBytesRead(t *testing.T) {
422 if base.UnitTestUrlIsWalrus() {
423 t.Skip("Test only works with CBS because of use fo RBAC roles")
424 }
425 ctx := base.TestCtx(t)
426 tb := base.GetTestBucket(t)
427 defer tb.Close(ctx)
428
429 rt := NewRestTester(t, &RestTesterConfig{CustomTestBucket: tb.NoCloseClone(), AdminInterfaceAuthentication: true})
430 defer rt.Close()
431 SGWorBFArole := MobileSyncGatewayRole.RoleName
432
433 eps, httpClient, err := rt.ServerContext().ObtainManagementEndpointsAndHTTPClient()
434 require.NoError(t, err)
435
436 MakeUser(t, httpClient, eps[0], "MobileSyncGatewayUser", "password", []string{fmt.Sprintf("%s[%s]", SGWorBFArole, rt.Bucket().GetName())})
437 defer DeleteUser(t, httpClient, eps[0], "MobileSyncGatewayUser")
438
439 input := fmt.Sprintf(
440 `{"bucket": "%s", "num_index_replicas": 0, "enable_shared_bucket_access": %t, "use_views": %t,"username": "%s", "password":"%s"}`,
441 tb.GetName(), base.TestUseXattrs(), base.TestsDisableGSI(), base.TestClusterUsername(), base.TestClusterPassword(),
442 )
443
444 db := rt.GetDatabase() // get database before we add a new one
445
446 resp := rt.SendAdminRequestWithAuth(http.MethodPut, "/db1/", input, "MobileSyncGatewayUser", "password")
447 RequireStatus(t, resp, http.StatusCreated)
448
449 // assert the stat hasn't increased (admin request doesn't effect count)
450 base.RequireWaitForStat(t, func() int64 {
451 return db.DbStats.DatabaseStats.PublicRestBytesRead.Value()
452 }, 0)
453
454}
455
456func TestOfflineDBBytesRead(t *testing.T) {
457 rt := NewRestTester(t, nil)

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
ServerContextMethod · 0.95
BucketMethod · 0.95
GetDatabaseMethod · 0.95
UnitTestUrlIsWalrusFunction · 0.92
TestCtxFunction · 0.92
GetTestBucketFunction · 0.92
TestUseXattrsFunction · 0.92
TestsDisableGSIFunction · 0.92
TestClusterUsernameFunction · 0.92
TestClusterPasswordFunction · 0.92

Tested by

no test coverage detected