(t *testing.T)
| 406 | } |
| 407 | |
| 408 | func 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 | |
| 456 | func TestResyncStopUsingDCPStream(t *testing.T) { |
| 457 | base.TestRequiresDCPResync(t) |
nothing calls this directly
no test coverage detected