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

Function TestResyncStopUsingDCPStream

rest/adminapitest/admin_api_test.go:1401–1445  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1399}
1400
1401func TestResyncStopUsingDCPStream(t *testing.T) {
1402 base.TestRequiresDCPResync(t)
1403
1404 syncFn := `
1405 function(doc) {
1406 channel("x")
1407 }`
1408
1409 testBucket := base.GetTestBucket(t)
1410
1411 rt := rest.NewRestTester(t,
1412 &rest.RestTesterConfig{
1413 SyncFn: syncFn,
1414 CustomTestBucket: testBucket,
1415 },
1416 )
1417 defer rt.Close()
1418
1419 numOfDocs := 1000
1420 // gsi is slower than views, so update the number of documents for views so stopping the resync will not complete
1421 if base.TestsDisableGSI() {
1422 numOfDocs = 5000
1423 }
1424 for i := range numOfDocs {
1425 rt.CreateTestDoc(fmt.Sprintf("doc%d", i))
1426 }
1427
1428 rt.WaitForPendingChanges()
1429
1430 require.Equal(t, int64(numOfDocs), rt.GetDatabase().DbStats.Database().SyncFunctionCount.Value())
1431
1432 rt.TakeDbOffline()
1433
1434 response := rt.SendAdminRequest("POST", "/db/_resync?action=start", "")
1435 rest.RequireStatus(t, response, http.StatusOK)
1436 rt.WaitForResyncDCPStatus(db.BackgroundProcessStateRunning)
1437
1438 response = rt.SendAdminRequest("POST", "/db/_resync?action=stop", "")
1439 rest.RequireStatus(t, response, http.StatusOK)
1440
1441 rt.WaitForResyncDCPStatus(db.BackgroundProcessStateStopped)
1442
1443 // make sure resync stopped before it completed
1444 require.Less(t, int(rt.GetDatabase().DbStats.Database().SyncFunctionCount.Value()), numOfDocs*2)
1445}
1446
1447// Single threaded bring DB online
1448func TestDBOnlineSingle(t *testing.T) {

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
CreateTestDocMethod · 0.95
WaitForPendingChangesMethod · 0.95
GetDatabaseMethod · 0.95
TakeDbOfflineMethod · 0.95
SendAdminRequestMethod · 0.95
TestRequiresDCPResyncFunction · 0.92
GetTestBucketFunction · 0.92
NewRestTesterFunction · 0.92
TestsDisableGSIFunction · 0.92
RequireStatusFunction · 0.92

Tested by

no test coverage detected