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

Function waitForClusterReady

dgraph/cmd/dgraphimport/import_test.go:458–482  ·  view source on GitHub ↗

waitForClusterReady ensures the cluster is fully operational before proceeding

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

Source from the content-addressed store, hash-verified

456
457// waitForClusterReady ensures the cluster is fully operational before proceeding
458func waitForClusterReady(t *testing.T, cluster *dgraphtest.LocalCluster, gc *dgraphapi.GrpcClient, timeout time.Duration) error {
459 deadline := time.Now().Add(timeout)
460 retryDelay := 500 * time.Millisecond
461
462 for time.Now().Before(deadline) {
463 if _, err := gc.Query("schema{}"); err != nil {
464 t.Logf("Cluster not ready yet: %v, retrying in %v", err, retryDelay)
465 time.Sleep(retryDelay)
466 retryDelay = min(retryDelay*2, 5*time.Second)
467 continue
468 }
469
470 if err := cluster.HealthCheck(false); err != nil {
471 t.Logf("Health check failed: %v, retrying in %v", err, retryDelay)
472 time.Sleep(retryDelay)
473 retryDelay = min(retryDelay*2, 5*time.Second)
474 continue
475 }
476
477 t.Log("Cluster is ready")
478 return nil
479 }
480
481 return fmt.Errorf("cluster not ready within %v timeout", timeout)
482}
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 {

Calls 6

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

Tested by

no test coverage detected