monolithic/run-tests.sh
James Kinsman f013ac0958
Change maps to allow user agent mapping too (#87)
Correclty disable StrictHostKeyChecking whilst we are at it!
map "$http_useragent---$http_host" $cacheidentifier {
Hostnames in maps file need to be regexs
Save the docker image into the artifacts store to allow download for testing
Need to handle *. wildcard
Use # instead of / as regex/sed seperator to provide a slightly cleaner sed line for debug
Provide comments and breakdown for sed (Requested by @GotenXiao
Changed UA/Host seperator from --- to £££ @rconan suggestion from UKLans chat

Closes #86 See github for details
2020-02-11 15:32:09 +00:00

68 lines
1.6 KiB
Bash
Executable file

#!/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
GOSS_WAIT_OPS="-r 60s -s 1s"
docker build --tag lancachenet/monolithic:goss-test .
case $1 in
circleci)
shift;
mkdir -p ./reports/goss
if [[ "$1" == "keepimage" ]]; then
KEEPIMAGE=true
shift
fi
export GOSS_OPTS="$GOSS_OPTS --format junit"
export CONTAINER_LOG_OUTPUT="reports/goss/docker.log"
dgoss run $@ lancachenet/monolithic:goss-test > reports/goss/report.xml
#store result for exit code
RESULT=$?
#Ensure non blank docker.log
echo \
"Container Output:
$(cat reports/goss/docker.log)" \
> reports/goss/docker.log
#delete the junk that goss currently outputs :(
sed -i '0,/^</d' reports/goss/report.xml
#remove invalid system-err outputs from junit output so circleci can read it
sed -i '/<system-err>.*<\/system-err>/d' reports/goss/report.xml
;;
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=$?
;;
*)
if [[ "$1" == "keepimage" ]]; then
KEEPIMAGE=true
shift
fi
dgoss run $@ lancachenet/monolithic:goss-test
RESULT=$?
;;
esac
[[ "$KEEPIMAGE" == "true" ]] || docker rmi lancachenet/monolithic:goss-test
exit $RESULT