Created
April 4, 2020 00:22
-
-
Save TsuyoshiUshio/40cf49c6d86799c610d6f949b350694e to your computer and use it in GitHub Desktop.
Postgresql database testing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ExpectedStatus := "success" | |
status := retry.DoWithRetry(t, "Waiting for DB connection validation...", 5, time.Duration(time.Second*5), | |
func() (string, error) { | |
output, err := k8s.RunKubectlAndGetOutputE(t, kubernetesOptions, "exec", psqlClientPodName, "--", "/bin/sh", "-c", fmt.Sprintf("PGPASSWORD=\"%s\" psql \"sslmode=require host=%s.postgres.database.azure.com dbname=%s user=%s@%s\";echo $?;", config.PGPassword, config.HostName, config.DBName, config.UserName, config.HostName)) | |
if err != nil { | |
return "", err | |
} | |
t.Log("PostgresClient:", output) | |
if output == "0" { | |
return ExpectedStatus, nil | |
} else { | |
return "", fmt.Errorf("fail") | |
} | |
}) | |
assert.Equal(t, ExpectedStatus, status) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment