update acceptance test to check vault single server boots, and is running but sealed and uninitialized

This commit is contained in:
Clint Shryock 2018-11-28 11:43:24 -06:00
parent 66211943e8
commit 6688814862
No known key found for this signature in database
GPG key ID: B7C8F9C70EC5CD29
2 changed files with 20 additions and 15 deletions

View file

@ -1,9 +1,9 @@
# name_prefix returns the prefix of the resources within Kubernetes. # name_prefix returns the prefix of the resources within Kubernetes.
name_prefix() { name_prefix() {
printf "consul" printf "vault"
} }
# helm_install installs the Consul chart. This will source overridable # helm_install installs the vault chart. This will source overridable
# values from the "values.yaml" file in this directory. This can be set # values from the "values.yaml" file in this directory. This can be set
# by CI or other environments to do test-specific overrides. Note that its # by CI or other environments to do test-specific overrides. Note that its
# easily possible to break tests this way so be careful. # easily possible to break tests this way so be careful.
@ -14,19 +14,18 @@ helm_install() {
fi fi
helm install -f ${values} \ helm install -f ${values} \
--name consul \ --name vault \
--wait \
${BATS_TEST_DIRNAME}/../.. ${BATS_TEST_DIRNAME}/../..
} }
# helm_delete deletes the Consul chart and all resources. # helm_delete deletes the vault chart and all resources.
helm_delete() { helm_delete() {
helm delete --purge consul helm delete --purge vault
kubectl delete --all pvc kubectl delete --all pvc
} }
# wait for a pod to be ready # wait for a pod to be ready
wait_for_ready() { wait_for_running() {
POD_NAME=$1 POD_NAME=$1
check() { check() {
@ -37,7 +36,7 @@ wait_for_ready() {
kubectl get pods $1 -o json | \ kubectl get pods $1 -o json | \
jq -r 'select( jq -r 'select(
.status.phase == "Running" and .status.phase == "Running" and
([ .status.conditions[] | select(.type == "Ready" and .status == "True") ] | length) == 1 ([ .status.conditions[] | select(.type == "Ready" and .status == "False") ] | length) == 1
) | .metadata.namespace + "/" + .metadata.name' ) | .metadata.namespace + "/" + .metadata.name'
} }

View file

@ -2,16 +2,22 @@
load _helpers load _helpers
@test "server: default, comes up healthy" { @test "server: default, comes up sealed" {
helm_install helm_install
wait_for_ready $(name_prefix)-server-0 wait_for_running $(name_prefix)-server-0
# Verify there are three servers # Verify there are three servers
local server_count=$(kubectl exec "$(name_prefix)-server-0" consul members | local sealed_status=$(kubectl exec "$(name_prefix)-server-0" -- vault status -format=json |
grep server | jq .sealed )
wc -l) [ "${sealed_status}" == "true" ]
[ "${server_count}" -eq "3" ]
# Clean up local init_status=$(kubectl exec "$(name_prefix)-server-0" -- vault status -format=json |
jq .initialized)
[ "${init_status}" == "false" ]
}
# Clean up
teardown() {
echo "helm/pvc teardown"
helm_delete helm_delete
} }