validateClientConnection ensures the client connection is working before use
(t *testing.T, gc *dgraphapi.GrpcClient, timeout time.Duration)
| 642 | |
| 643 | // validateClientConnection ensures the client connection is working before use |
| 644 | func 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 |
| 663 | func retryStartZero(t *testing.T, cluster *dgraphtest.LocalCluster, zeroID int, timeout time.Duration) error { |
no test coverage detected