Skip to content

Commit

Permalink
fix(testing): improve sanity requirements error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
paullaffitte committed Sep 22, 2020
1 parent 5c77d4b commit 959e4ec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
3 changes: 3 additions & 0 deletions test/.env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DOTHILL_USERNAME=
DOTHILL_PASSWORD=
DOTHILL_API_ADDR=
22 changes: 14 additions & 8 deletions test/sanity
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
#! /usr/bin/env bash

set -e

function teardown {
rm -vf ${secretsFile} /tmp/{controller,node}.sock
}

trap teardown EXIT

secretsFileTmpl="secrets.template.yml"
secretsFile="secrets.yml"
inititatorNameFile="/etc/iscsi/initiatorname.iscsi"

function setup {
cd $(dirname $0)
set -a; . .env; set +a
envsubst < ${secretsFileTmpl} > ${secretsFile}
cat ${inititatorNameFile} > /dev/null
if [ $? -ne 0 ]; then
echo "InitiatorName=iqn.2020-01.io.enix:sanity-test-cluster" > ${inititatorNameFile}
if [ ! -f ${inititatorNameFile} ]; then
>&2 echo "/etc/iscsi/initiatorname.iscsi is missing, please run the following commands"
>&2 echo -e " sudo mkdir -p /etc/iscsi"
>&2 echo -e " sudo sh -c 'echo \"InitiatorName=iqn.2020-01.io.enix:sanity-test-cluster\" > ${inititatorNameFile}'"
exit 1
fi
}

function teardown {
rm ${secretsFile}
}

setup
go test ../cmd/controller $@
out=$?
teardown

exit ${out}

0 comments on commit 959e4ec

Please sign in to comment.