waitForClusterStable ensures remaining alphas are accessible after some are shut down
(t *testing.T, cluster *dgraphtest.LocalCluster, timeout time.Duration)
| 483 | |
| 484 | // waitForClusterStable ensures remaining alphas are accessible after some are shut down |
| 485 | func waitForClusterStable(t *testing.T, cluster *dgraphtest.LocalCluster, timeout time.Duration) error { |
| 486 | deadline := time.Now().Add(timeout) |
| 487 | retryDelay := 1 * time.Second |
| 488 | |
| 489 | for time.Now().Before(deadline) { |
| 490 | if err := cluster.HealthCheck(false); err != nil { |
| 491 | t.Logf("Cluster not stable yet: %v, retrying in %v", err, retryDelay) |
| 492 | time.Sleep(retryDelay) |
| 493 | retryDelay = min(retryDelay*2, 5*time.Second) |
| 494 | continue |
| 495 | } |
| 496 | |
| 497 | t.Log("Cluster is stable") |
| 498 | return nil |
| 499 | } |
| 500 | |
| 501 | return fmt.Errorf("cluster not stable within %v timeout", timeout) |
| 502 | } |
| 503 | |
| 504 | // waitForAlphaReady waits for a specific alpha to be ready after startup |
| 505 | func waitForAlphaReady(t *testing.T, cluster *dgraphtest.LocalCluster, alphaID int, timeout time.Duration) error { |
no test coverage detected