MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / validateClientConnection

Function validateClientConnection

dgraph/cmd/dgraphimport/import_test.go:644–660  ·  view source on GitHub ↗

validateClientConnection ensures the client connection is working before use

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

Source from the content-addressed store, hash-verified

642
643// validateClientConnection ensures the client connection is working before use
644func validateClientConnection(t *testing.T, gc *dgraphapi.GrpcClient, timeout time.Duration) error {
645 deadline := time.Now().Add(timeout)
646 retryDelay := 1 * time.Second
647
648 for time.Now().Before(deadline) {
649 if _, err := gc.Query("schema{}"); err != nil {
650 t.Logf("Client connection validation failed: %v, retrying in %v", err, retryDelay)
651 time.Sleep(retryDelay)
652 retryDelay = min(retryDelay*2, 2*time.Second)
653 continue
654 }
655
656 return nil
657 }
658
659 return fmt.Errorf("client connection validation failed within %v timeout", timeout)
660}
661
662// retryStartZero attempts to start zero with retry logic for port conflicts
663func retryStartZero(t *testing.T, cluster *dgraphtest.LocalCluster, zeroID int, timeout time.Duration) error {

Callers 3

runImportTestFunction · 0.85
verifyImportResultsFunction · 0.85
requireCanaryServesFunction · 0.85

Calls 4

minFunction · 0.85
AddMethod · 0.45
QueryMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected