More integration test refactors
This commit is contained in:
parent
44e20583e6
commit
5fda2dcde1
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,4 +5,5 @@ integration_test/*.db
|
||||||
integration_test/*.sql
|
integration_test/*.sql
|
||||||
integration_test/*.sqlite
|
integration_test/*.sqlite
|
||||||
integration_test/*.sqlite3
|
integration_test/*.sqlite3
|
||||||
|
integration_test/logs
|
||||||
|
|
||||||
|
|
|
@ -5,28 +5,43 @@ cd "$(dirname "$0")" || exit 1
|
||||||
tw_srv_bin=teeworlds_srv
|
tw_srv_bin=teeworlds_srv
|
||||||
tw_cl_bin=teeworlds
|
tw_cl_bin=teeworlds
|
||||||
srvcfg='sv_rcon_password rcon;sv_port 8377;killme'
|
srvcfg='sv_rcon_password rcon;sv_port 8377;killme'
|
||||||
|
clcfg='connect 127.0.0.1:8377;killme'
|
||||||
|
tw_srv_running=0
|
||||||
|
tw_client_running=0
|
||||||
|
logdir=logs
|
||||||
|
|
||||||
if [[ -x "$(command -v teeworlds_srv)" ]]
|
mkdir -p logs
|
||||||
then
|
|
||||||
teeworlds_srv "$srvcfg" &> server.txt &
|
function start_tw_server() {
|
||||||
elif [[ -x "$(command -v teeworlds-server)" ]]
|
if [[ -x "$(command -v teeworlds_srv)" ]]
|
||||||
then
|
then
|
||||||
teeworlds-server "$srvcfg" &> server.txt &
|
teeworlds_srv "$srvcfg" &> "$logdir/server.txt" &
|
||||||
|
elif [[ -x "$(command -v teeworlds-server)" ]]
|
||||||
|
then
|
||||||
|
teeworlds-server "$srvcfg" &> "$logdir/server.txt" &
|
||||||
tw_srv_bin='teeworlds-server'
|
tw_srv_bin='teeworlds-server'
|
||||||
elif [[ -x "$(command -v teeworlds-srv)" ]]
|
elif [[ -x "$(command -v teeworlds-srv)" ]]
|
||||||
then
|
then
|
||||||
teeworlds-srv "$srvcfg" &> server.txt &
|
teeworlds-srv "$srvcfg" &> "$logdir/server.txt" &
|
||||||
tw_srv_bin='teeworlds-srv'
|
tw_srv_bin='teeworlds-srv'
|
||||||
else
|
else
|
||||||
echo "Error: please install a teeworlds_srv"
|
echo "Error: please install a teeworlds_srv"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
tw_srv_running=1
|
||||||
|
}
|
||||||
|
|
||||||
if [[ ! -x "$(command -v "$tw_cl_bin")" ]]
|
function connect_tw_client() {
|
||||||
then
|
if [[ -x "$(command -v teeworlds)" ]]
|
||||||
|
then
|
||||||
|
teeworlds "$clcfg"
|
||||||
|
tw_cl_bin=teeworlds
|
||||||
|
else
|
||||||
echo "Error: please install a teeworlds"
|
echo "Error: please install a teeworlds"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
tw_client_running=1
|
||||||
|
}
|
||||||
|
|
||||||
function get_test_names() {
|
function get_test_names() {
|
||||||
(find client -name "*.rb";find server -name "*.rb") | tr '\n' ' '
|
(find client -name "*.rb";find server -name "*.rb") | tr '\n' ' '
|
||||||
|
@ -53,14 +68,17 @@ then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[*] running test '$testname' ..."
|
|
||||||
echo "client log $(date)" > client.txt
|
|
||||||
echo "server log $(date)" > server.txt
|
|
||||||
[[ -f timeout.txt ]] && rm timeout.txt
|
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
|
if [ "$tw_srv_running" == "1" ]
|
||||||
|
then
|
||||||
echo "[*] shutting down server ..."
|
echo "[*] shutting down server ..."
|
||||||
pkill -f "$tw_srv_bin $srvcfg"
|
pkill -f "$tw_srv_bin $srvcfg"
|
||||||
|
fi
|
||||||
|
if [ "$tw_client_running" == "1" ]
|
||||||
|
then
|
||||||
|
echo "[*] shutting down client ..."
|
||||||
|
pkill -f "$tw_cl_bin $clcfg"
|
||||||
|
fi
|
||||||
[[ "$_timout_pid" != "" ]] && kill "$_timout_pid" &> /dev/null
|
[[ "$_timout_pid" != "" ]] && kill "$_timout_pid" &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,11 +92,11 @@ function fail() {
|
||||||
# this is a bit ugly but it works
|
# this is a bit ugly but it works
|
||||||
# maybe a sleep does as well
|
# maybe a sleep does as well
|
||||||
# or I still did not get flushing
|
# or I still did not get flushing
|
||||||
tail client.txt &>/dev/null
|
tail "$logdir/ruby_client.txt" &>/dev/null
|
||||||
echo "[-] end of client log:"
|
echo "[-] end of ruby client log:"
|
||||||
tail client.txt
|
tail "$logdir/ruby_client.txt"
|
||||||
echo "[-] end of server log:"
|
echo "[-] end of server log:"
|
||||||
tail server.txt
|
tail "$logdir/server.txt"
|
||||||
echo "$msg"
|
echo "$msg"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -92,31 +110,30 @@ function timeout() {
|
||||||
fail "[-] Timeout"
|
fail "[-] Timeout"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "[*] running test '$testname' ..."
|
||||||
|
echo "ruby client log $(date)" > "$logdir/ruby_client.txt"
|
||||||
|
echo "server log $(date)" > "$logdir/server.txt"
|
||||||
|
[[ -f timeout.txt ]] && rm timeout.txt
|
||||||
|
start_tw_server
|
||||||
timeout 3 killme &
|
timeout 3 killme &
|
||||||
_timout_pid=$!
|
_timout_pid=$!
|
||||||
|
ruby "$testname" killme &> "$logdir/ruby_client.txt"
|
||||||
|
|
||||||
if [ "$testname" == "client/chat.rb" ]
|
if [ "$testname" == "client/chat.rb" ]
|
||||||
then
|
then
|
||||||
ruby "$testname" killme &> client.txt
|
if ! grep -q 'hello world' "$logdir/server.txt"
|
||||||
|
|
||||||
if ! grep -q 'hello world' server.txt
|
|
||||||
then
|
then
|
||||||
fail "Error: did not find chat message in server log"
|
fail "Error: did not find chat message in server log"
|
||||||
fi
|
fi
|
||||||
elif [ "$testname" == "client/reconnect.rb" ]
|
elif [ "$testname" == "client/reconnect.rb" ]
|
||||||
then
|
then
|
||||||
ruby "$testname" killme &> client.txt
|
if ! grep -q 'bar' "$logdir/server.txt"
|
||||||
|
|
||||||
if ! grep -q 'bar' server.txt
|
|
||||||
then
|
then
|
||||||
fail "Error: did not find 2nd chat message in server log"
|
fail "Error: did not find 2nd chat message in server log"
|
||||||
fi
|
fi
|
||||||
elif [ "$testname" == "client/rcon.rb" ]
|
elif [ "$testname" == "client/rcon.rb" ]
|
||||||
then
|
then
|
||||||
ruby "$testname" killme &> client.txt
|
sleep 1
|
||||||
|
|
||||||
sleep 0.1
|
|
||||||
if pgrep -f "$tw_srv_bin $srvcfg"
|
if pgrep -f "$tw_srv_bin $srvcfg"
|
||||||
then
|
then
|
||||||
fail "Error: server still running rcon shutdown failed"
|
fail "Error: server still running rcon shutdown failed"
|
||||||
|
|
Loading…
Reference in a new issue