// Check the status of the given Vault node and ensure it matches the expected status. Note that we use curl to do the
// status check so we can ensure that TLS certificates work for curl (and not just the Vault client).
Check the status of the given Vault node and ensure it matches the expected status. Note that we use curl to do the
status check so we can ensure that TLS certificates work for curl (and not just the Vault client).
// Check the status of the given Vault node and ensure it matches the expected status . Note that we use curl to do the // status check so we can ensure that TLS certificates work for curl ( and not just the Vault client ) .
func checkStatus(t *testing.T, host ssh.Host, bastionHost *ssh.Host, expectedStatus VaultStatus) (string, error) {
	curlCommand := "curl -s -o /dev/null -w '%{http_code}' https://127.0.0.1:8200/v1/sys/health"
	logger.Logf(t, "Using curl to check status of Vault server %s: %s", host.Hostname, curlCommand)
	output, err := runCommand(t, bastionHost, &host, curlCommand)
	if err != nil {
		return output, err
	}
	status, err := strconv.Atoi(output)
	if err != nil {
		return "", err
	}
	if status == int(expectedStatus) {
		return fmt.Sprintf("Got expected status code %d", status), nil
	} else {
		return "", fmt.Errorf("Expected status code %d for host %s, but got %d", int(expectedStatus), host.Hostname, status)
	}
}
func checkStatus ( t * testing . T , host ssh . Host , bastionHost * ssh . Host , expectedStatus VaultStatus ) ( string , error ) { curlCommand := " " logger . Logf ( t , " " , host . Hostname , curlCommand ) output , err := runCommand ( t , bastionHost , & host , curlCommand ) if err != nil { return output , err } status , err := strconv . Atoi ( output ) if err != nil { return " " , err } if status == int ( expectedStatus ) { return fmt . Sprintf ( " " , status ) , nil } else { return " " , fmt . Errorf ( " " , int ( expectedStatus ) , host . Hostname , status ) } }
Check the status of the given Vault node and ensure it matches the expected status.
Check the status of the given Vault node and ensure it matches the expected status .