(t *testing.T)
| 1399 | } |
| 1400 | |
| 1401 | func 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 |
| 1448 | func TestDBOnlineSingle(t *testing.T) { |
nothing calls this directly
no test coverage detected