MCPcopy
hub / github.com/dgraph-io/dgraph / waitForClusterStable

Function waitForClusterStable

dgraph/cmd/dgraphimport/import_test.go:485–502  ·  view source on GitHub ↗

waitForClusterStable ensures remaining alphas are accessible after some are shut down

(t *testing.T, cluster *dgraphtest.LocalCluster, timeout time.Duration)

Source from the content-addressed store, hash-verified

483
484// waitForClusterStable ensures remaining alphas are accessible after some are shut down
485func 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
505func waitForAlphaReady(t *testing.T, cluster *dgraphtest.LocalCluster, alphaID int, timeout time.Duration) error {

Callers 1

runImportTestFunction · 0.85

Calls 5

minFunction · 0.85
HealthCheckMethod · 0.80
LogMethod · 0.80
AddMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected