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

Function TestResyncErrorScenariosUsingDCPStream

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

Source from the content-addressed store, hash-verified

406}
407
408func TestResyncErrorScenariosUsingDCPStream(t *testing.T) {
409 base.TestRequiresDCPResync(t)
410
411 syncFn := `
412 function(doc) {
413 channel("x")
414 }`
415
416 rt := NewRestTester(t,
417 &RestTesterConfig{
418 SyncFn: syncFn,
419 },
420 )
421 defer rt.Close()
422
423 for i := 0; i < 1000; i++ {
424 rt.CreateTestDoc(fmt.Sprintf("doc%d", i))
425 }
426
427 response := rt.SendAdminRequest("GET", "/db/_resync", "")
428 RequireStatus(t, response, http.StatusOK)
429
430 response = rt.SendAdminRequest("POST", "/db/_resync?action=start", "")
431 RequireStatus(t, response, http.StatusServiceUnavailable)
432
433 response = rt.SendAdminRequest("POST", "/db/_resync?action=stop", "")
434 RequireStatus(t, response, http.StatusBadRequest)
435
436 rt.TakeDbOffline()
437
438 response = rt.SendAdminRequest("POST", "/db/_resync?action=start", "")
439 RequireStatus(t, response, http.StatusOK)
440
441 rt.WaitForResyncDCPStatus(db.BackgroundProcessStateCompleted)
442
443 response = rt.SendAdminRequest("POST", "/db/_resync?action=stop", "")
444 RequireStatus(t, response, http.StatusBadRequest)
445
446 response = rt.SendAdminRequest("POST", "/db/_resync?action=invalid", "")
447 RequireStatus(t, response, http.StatusBadRequest)
448
449 // Test empty action, should default to start
450 response = rt.SendAdminRequest("POST", "/db/_resync", "")
451 RequireStatus(t, response, http.StatusOK)
452
453 rt.WaitForResyncDCPStatus(db.BackgroundProcessStateCompleted)
454}
455
456func TestResyncStopUsingDCPStream(t *testing.T) {
457 base.TestRequiresDCPResync(t)

Callers

nothing calls this directly

Calls 8

CloseMethod · 0.95
CreateTestDocMethod · 0.95
SendAdminRequestMethod · 0.95
TakeDbOfflineMethod · 0.95
TestRequiresDCPResyncFunction · 0.92
NewRestTesterFunction · 0.85
RequireStatusFunction · 0.85

Tested by

no test coverage detected