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

Function TestResyncStopUsingDCPStream

rest/sync_fn_test.go:456–496  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

454}
455
456func TestResyncStopUsingDCPStream(t *testing.T) {
457 base.TestRequiresDCPResync(t)
458
459 syncFn := `
460 function(doc) {
461 channel("x")
462 }`
463
464 rt := NewRestTester(t,
465 &RestTesterConfig{
466 SyncFn: syncFn,
467 DatabaseConfig: &DatabaseConfig{DbConfig: DbConfig{
468 QueryPaginationLimit: base.Ptr(10),
469 }},
470 },
471 )
472 defer rt.Close()
473
474 for i := 0; i < 1000; i++ {
475 rt.CreateTestDoc(fmt.Sprintf("doc%d", i))
476 }
477
478 err := rt.WaitForCondition(func() bool {
479 return int(rt.GetDatabase().DbStats.Database().SyncFunctionCount.Value()) == 1000
480 })
481 assert.NoError(t, err)
482
483 rt.TakeDbOffline()
484
485 response := rt.SendAdminRequest("POST", "/db/_resync?action=start", "")
486 RequireStatus(t, response, http.StatusOK)
487
488 rt.WaitForResyncDCPStatus(db.BackgroundProcessStateRunning)
489 response = rt.SendAdminRequest("POST", "/db/_resync?action=stop", "")
490 RequireStatus(t, response, http.StatusOK)
491
492 rt.WaitForResyncDCPStatus(db.BackgroundProcessStateStopped)
493
494 syncFnCount := int(rt.GetDatabase().DbStats.Database().SyncFunctionCount.Value())
495 assert.Less(t, syncFnCount, 2000, "Expected syncFnCount < 2000 but syncFnCount=%d", syncFnCount)
496}
497
498func TestResyncRegenerateSequences(t *testing.T) {
499 base.TestRequiresDCPResync(t)

Callers

nothing calls this directly

Calls 14

CloseMethod · 0.95
CreateTestDocMethod · 0.95
WaitForConditionMethod · 0.95
GetDatabaseMethod · 0.95
TakeDbOfflineMethod · 0.95
SendAdminRequestMethod · 0.95
TestRequiresDCPResyncFunction · 0.92
PtrFunction · 0.92
NewRestTesterFunction · 0.85
RequireStatusFunction · 0.85
ValueMethod · 0.45

Tested by

no test coverage detected