Skip to content

Instantly share code, notes, and snippets.

@TsuyoshiUshio
Created April 4, 2020 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TsuyoshiUshio/40cf49c6d86799c610d6f949b350694e to your computer and use it in GitHub Desktop.
Save TsuyoshiUshio/40cf49c6d86799c610d6f949b350694e to your computer and use it in GitHub Desktop.
Postgresql database testing.
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