mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-26 17:15:08 +01:00
added tests for welcome app
This commit is contained in:
41
dist/apps/welcome/test.sh
vendored
41
dist/apps/welcome/test.sh
vendored
@@ -1,7 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "SCRIPT_NAME: $SCRIPT_NAME"
|
||||
echo "SHARED_HTPASSWD_PATH: $SHARED_HTPASSWD_PATH"
|
||||
echo "APP_SCRIPT_PATH: $APP_SCRIPT_PATH"
|
||||
echo "APP_START_SCRIPT_PATH: $APP_START_SCRIPT_PATH"
|
||||
timeout_feature() {
|
||||
local interval=10
|
||||
local totaltime=60
|
||||
local testwhat=${1}
|
||||
local returncode
|
||||
local endtime=$(($(date +%s) + ${totaltime}))
|
||||
|
||||
echo "No tests"
|
||||
while :
|
||||
do
|
||||
eval ${testwhat}
|
||||
returncode=$?
|
||||
|
||||
# If no error or 2 minutes passed, we get out of this loop
|
||||
([ "${returncode}" -eq "0" ] || [ $(date +%s) -gt ${endtime} ]) && break
|
||||
|
||||
printf "\e[1;31mMaybe it's too early, I'll retry every ${interval} seconds for $((${totaltime} / 60)) minutes ($((${endtime} - $(date +%s))) seconds left).\e[1;0m"
|
||||
|
||||
sleep ${interval}
|
||||
done
|
||||
|
||||
return ${returncode}
|
||||
}
|
||||
|
||||
do_test() {
|
||||
local rc
|
||||
rc=$(curl -k -s -o /dev/null -w "%{http_code}" https://localhost/welcome)
|
||||
[ "${rc}" -ne "401" ] && return 400
|
||||
return 0
|
||||
}
|
||||
|
||||
timeout_feature do_test
|
||||
returncode=$?
|
||||
|
||||
# return 0: tests cool
|
||||
# return 1: tests failed
|
||||
return $returncode
|
||||
|
||||
Reference in New Issue
Block a user