(t *testing.T)
| 454 | } |
| 455 | |
| 456 | func 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 | |
| 498 | func TestResyncRegenerateSequences(t *testing.T) { |
| 499 | base.TestRequiresDCPResync(t) |
nothing calls this directly
no test coverage detected