2018-12-19 17:13:51 +00:00
|
|
|
#!/bin/bash
|
|
|
|
which goss
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Please install goss from https://goss.rocks/install"
|
|
|
|
echo "For a quick auto install run the following"
|
|
|
|
echo "curl -fsSL https://goss.rocks/install | sh"
|
|
|
|
exit $?
|
|
|
|
fi
|
|
|
|
|
2019-12-02 11:26:37 +00:00
|
|
|
GOSS_WAIT_OPS="-r 60s -s 1s"
|
|
|
|
|
2019-05-30 20:30:25 +00:00
|
|
|
docker build --tag lancachenet/monolithic:goss-test .
|
2018-12-19 17:13:51 +00:00
|
|
|
case $1 in
|
|
|
|
circleci)
|
2020-02-11 15:32:09 +00:00
|
|
|
shift;
|
|
|
|
mkdir -p ./reports/goss
|
2018-12-19 17:13:51 +00:00
|
|
|
if [[ "$1" == "keepimage" ]]; then
|
|
|
|
KEEPIMAGE=true
|
|
|
|
shift
|
|
|
|
fi
|
2020-02-11 15:32:09 +00:00
|
|
|
export GOSS_OPTS="$GOSS_OPTS --format junit"
|
|
|
|
export CONTAINER_LOG_OUTPUT="reports/goss/docker.log"
|
2019-05-30 20:30:25 +00:00
|
|
|
dgoss run $@ lancachenet/monolithic:goss-test > reports/goss/report.xml
|
2018-12-19 17:13:51 +00:00
|
|
|
#store result for exit code
|
|
|
|
RESULT=$?
|
2020-02-11 15:32:09 +00:00
|
|
|
#Ensure non blank docker.log
|
|
|
|
echo \
|
|
|
|
"Container Output:
|
|
|
|
$(cat reports/goss/docker.log)" \
|
|
|
|
> reports/goss/docker.log
|
2018-12-19 17:13:51 +00:00
|
|
|
#delete the junk that goss currently outputs :(
|
2020-02-11 15:32:09 +00:00
|
|
|
sed -i '0,/^</d' reports/goss/report.xml
|
2018-12-19 17:13:51 +00:00
|
|
|
#remove invalid system-err outputs from junit output so circleci can read it
|
|
|
|
sed -i '/<system-err>.*<\/system-err>/d' reports/goss/report.xml
|
|
|
|
;;
|
2019-12-02 11:26:37 +00:00
|
|
|
docker)
|
|
|
|
shift;
|
|
|
|
if [[ "$1" == "keepimage" ]]; then
|
|
|
|
KEEPIMAGE=true
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
docker run --name monolithic-goss-test $@ lancachenet/monolithic:goss-test
|
|
|
|
docker stop monolithic-goss-test
|
|
|
|
docker rm monolithic-goss-test
|
|
|
|
RESULT=$?
|
|
|
|
;;
|
|
|
|
edit)
|
|
|
|
shift;
|
|
|
|
if [[ "$1" == "keepimage" ]]; then
|
|
|
|
KEEPIMAGE=true
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
dgoss edit $@ lancachenet/monolithic:goss-test
|
|
|
|
RESULT=$?
|
|
|
|
;;
|
2018-12-19 17:13:51 +00:00
|
|
|
*)
|
|
|
|
if [[ "$1" == "keepimage" ]]; then
|
|
|
|
KEEPIMAGE=true
|
|
|
|
shift
|
|
|
|
fi
|
2019-05-30 20:30:25 +00:00
|
|
|
dgoss run $@ lancachenet/monolithic:goss-test
|
2018-12-19 17:13:51 +00:00
|
|
|
RESULT=$?
|
|
|
|
;;
|
|
|
|
esac
|
2019-05-30 20:30:25 +00:00
|
|
|
[[ "$KEEPIMAGE" == "true" ]] || docker rmi lancachenet/monolithic:goss-test
|
2018-12-19 17:13:51 +00:00
|
|
|
|
|
|
|
exit $RESULT
|