update single server acc test, add HA test that installs Consul and runs HA mode

This commit is contained in:
Clint Shryock 2018-11-28 16:40:37 -06:00
parent 6688814862
commit 42600a73fc
No known key found for this signature in database
GPG key ID: B7C8F9C70EC5CD29
3 changed files with 63 additions and 6 deletions

View file

@ -18,10 +18,21 @@ helm_install() {
${BATS_TEST_DIRNAME}/../..
}
# helm_delete deletes the vault chart and all resources.
helm_delete() {
helm delete --purge vault
kubectl delete --all pvc
# helm_install_ha installs the vault chart using HA mode. This will source
# overridable 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
# easily possible to break tests this way so be careful.
helm_install_ha() {
local values="${BATS_TEST_DIRNAME}/values.yaml"
if [ ! -f "${values}" ]; then
touch $values
fi
helm install -f ${values} \
--name vault \
--set 'sever.enabled=false' \
--set 'severHA.enabled=true' \
${BATS_TEST_DIRNAME}/../..
}
# wait for a pod to be ready
@ -43,6 +54,7 @@ wait_for_running() {
for i in $(seq 30); do
if [ -n "$(check ${POD_NAME})" ]; then
echo "${POD_NAME} is ready."
sleep 2
return
fi

View file

@ -0,0 +1,42 @@
#!/usr/bin/env bats
load _helpers
@test "server-ha: default, comes up sealed, 1 replica" {
# helm_install_consul
helm_install_ha
wait_for_running $(name_prefix)-server-0
# Verify installed, sealed, and 1 replica
local sealed_status=$(kubectl exec "$(name_prefix)-server-0" -- vault status -format=json |
jq .sealed )
[ "${sealed_status}" == "true" ]
local init_status=$(kubectl exec "$(name_prefix)-server-0" -- vault status -format=json |
jq .initialized)
[ "${init_status}" == "false" ]
}
# setup a consul env
setup() {
#if [[ "$BATS_TEST_NUMBER" -eq 1]]; then
# ...
#fi
#helm delete --purge vault consul
#kubectl delete --all pvc
helm install https://github.com/hashicorp/consul-helm/archive/v0.3.0.tar.gz \
--name consul \
--set 'ui.enabled=false' \
--set 'client.enabled=false'
}
#cleanup
teardown() {
# only destroy the pvc if end of all tests, so we don't destroy the consul
# pvcs
#if [[ "${#BATS_TEST_NAMES[@]}" -eq "$BATS_TEST_NUMBER" ]]; then
#
#fi
helm delete --purge vault consul
kubectl delete --all pvc
}

View file

@ -6,7 +6,7 @@ load _helpers
helm_install
wait_for_running $(name_prefix)-server-0
# Verify there are three servers
# Verify installed, sealed, and 1 replica
local sealed_status=$(kubectl exec "$(name_prefix)-server-0" -- vault status -format=json |
jq .sealed )
[ "${sealed_status}" == "true" ]
@ -14,10 +14,13 @@ load _helpers
local init_status=$(kubectl exec "$(name_prefix)-server-0" -- vault status -format=json |
jq .initialized)
[ "${init_status}" == "false" ]
# TODO check pv, pvc
}
# Clean up
teardown() {
echo "helm/pvc teardown"
helm_delete
helm delete --purge vault
kubectl delete --all pvc
}