test/connector/tcp/mssql/start
#!/bin/bash -ex
mssql_host=mssql
secretless_host=secretless
mssql_edition=Developer # can also be Express, Standard, Enterprise, EnterpriseCore
while getopts :dDm:s:e: opt; do
case $opt in
d) dev_mode=true;;
D) secretless_host=secretless-debug;;
m) mssql_host=${OPTARG};;
s) secretless_host=${OPTARG};;
e) mssql_edition=${OPTARG};;
\?) echo "Unknown option -$OPTARG"; exit 1;;
esac
done
# the secretless host pulls from either the default value or the command line
# input, but if dev mode is on it will be overriden by that flag to use the
# dev container
export SECRETLESS_HOST=$secretless_host
if [[ "$dev_mode" = true ]]; then
echo "Using secretless-dev container"
export SECRETLESS_HOST=secretless-dev
fi
./stop
echo -e "\nStarting containers for the $mssql_edition edition\n"
export MSSQL_PID=$mssql_edition
docker compose build
report_dir="./test-coverage"
mkdir -p "$report_dir"
chmod 777 "$report_dir"
# the order of the services is important. mssql must be up before we start secretless
docker compose up -d $mssql_host
time ./wait_for_mssql -m $mssql_host
docker compose logs $mssql_host
docker compose up -d $SECRETLESS_HOST test
echo "Waiting for '$SECRETLESS_HOST' service to start"
# single quotes are intentional:
# shellcheck disable=SC2016
# SECRETLESS_HOST has to be set on the container for this run, so that the test
# container can be used to query the correct Secretless instance
docker compose exec -T test bash -ec '
counter=0
while ! wget --quiet --output-document - http://'$SECRETLESS_HOST':5335/ready > /dev/null 2>&1; do
if expr $counter = 50 > /dev/null; then
echo ""
echo "Timed out waiting for Secretless"
exit 1
fi
let "counter=$counter+1"
>&2 printf ". "
sleep 1
done
printf "\n"
'
echo -e "\n'$SECRETLESS_HOST' service is up\n"
docker compose up -d app
echo "Waiting for app"
docker compose exec -T test bash -ec '
counter=0
while ! curl -v app:8080 > /dev/null 2>&1; do
if expr $counter = 100 > /dev/null; then
echo ""
echo "Timed out waiting for JDBC App"
exit 1
fi
let "counter=$counter+1"
>&2 printf ". "
sleep 1
done
'
echo "app is up - continuing"