Add failing server side integration test

This commit is contained in:
ChillerDragon 2024-01-20 23:49:14 +08:00
parent 0dcb85a0e3
commit 10a75cdb65
3 changed files with 71 additions and 20 deletions

View file

@ -32,12 +32,20 @@ jobs:
unzip DDNet-headless.zip
sudo mv DDNet-headless /usr/local/bin
rm DDNet-headless.zip
- name: Test sending chat messages
wget https://github.com/ChillerDragon/ddnet/releases/download/v17.4.2-headless-0.7/DDNet7-headless.zip
unzip DDNet7-headless.zip
chmod +x DDNet7-headless
sudo mv DDNet7-headless /usr/local/bin
rm DDNet7-headless.zip
- name: '[CLIENT] Test sending chat messages'
run: |
./integration_test/run.sh client/chat.rb
- name: Test reconnect
- name: '[CLIENT] Test reconnect'
run: |
./integration_test/run.sh client/reconnect.rb
- name: Test rcon
- name: '[CLIENT] Test rcon'
run: |
./integration_test/run.sh client/rcon.rb
./integration_test/run.sh client/rcon.rb
- name: '[SERVER] Test connect'
run: |
./integration_test/run.sh server/connect.rb

2
.gitignore vendored
View file

@ -8,5 +8,7 @@ integration_test/*.db
integration_test/*.sql
integration_test/*.sqlite
integration_test/*.sqlite3
integration_test/*.fifo
integration_test/logs
integration_test/tmp

View file

@ -4,14 +4,17 @@ cd "$(dirname "$0")" || exit 1
tw_srv_bin=teeworlds_srv
tw_cl_bin=teeworlds
logdir=logs
tmpdir=tmp
srvcfg='sv_rcon_password rcon;sv_port 8377;killme'
clcfg='connect 127.0.0.1:8377;killme'
cl_fifo="$tmpdir/client.fifo"
clcfg="cl_input_fifo $cl_fifo;connect 127.0.0.1:8377;killme"
tw_srv_running=0
tw_client_running=0
logdir=logs
ruby_logfile=ruby_client.txt
mkdir -p logs
mkdir -p tmp
function start_tw_server() {
if [[ -x "$(command -v teeworlds_srv)" ]]
@ -35,11 +38,11 @@ function start_tw_server() {
function connect_tw_client() {
if [[ -x "$(command -v teeworlds-headless)" ]]
then
teeworlds-headless "$clcfg" "$logdir/client.txt"
teeworlds-headless "$clcfg"
tw_cl_bin=teeworlds-headless
elif [[ -x "$(command -v /usr/local/bin/teeworlds-headless)" ]]
then
/usr/local/bin/teeworlds-headless "$clcfg" "$logdir/client.txt"
/usr/local/bin/teeworlds-headless "$clcfg"
tw_cl_bin=/usr/local/bin/teeworlds-headless
elif [[ -x "$(command -v teeworlds)" ]]
then
@ -52,6 +55,22 @@ function connect_tw_client() {
tw_client_running=1
}
function connect_ddnet7_client() {
if [[ -x "$(command -v DDNet7-headless)" ]]
then
DDNet7-headless "$clcfg"
tw_cl_bin=DDNet7-headless
elif [[ -x "$(command -v /usr/local/bin/DDNet7-headless)" ]]
then
/usr/local/bin/DDNet7-headless "$clcfg"
tw_cl_bin=/usr/local/bin/DDNet7-headless
else
echo "Error: please install a DDNet7-headless"
exit 1
fi
tw_client_running=1
}
function get_test_names() {
(find client -name "*.rb";find server -name "*.rb") | tr '\n' ' '
}
@ -94,7 +113,7 @@ function cleanup() {
echo "[*] shutting down client ..."
pkill -f "$tw_cl_bin $clcfg"
fi
[[ "$_timout_pid" != "" ]] && kill "$_timout_pid" &> /dev/null
[[ "$_timeout_pid" != "" ]] && kill "$_timeout_pid" &> /dev/null
}
trap cleanup EXIT
@ -108,10 +127,18 @@ function fail() {
# maybe a sleep does as well
# or I still did not get flushing
tail "$ruby_logfile" &>/dev/null
echo "[-] end of ruby client log:"
tail "$ruby_logfile"
echo "[-] end of server log:"
tail "$logdir/server.txt"
if [[ "$testname" =~ ^client/ ]]
then
echo "[-] end of ruby client log:"
tail "$ruby_logfile"
echo "[-] end of server log:"
tail "$logdir/server.txt"
else
echo "[-] end of ruby server log:"
tail "$ruby_logfile"
echo "[-] end of client log:"
tail "$logdir/client.txt"
fi
echo "$msg"
exit 1
}
@ -133,13 +160,22 @@ then
echo "server log $(date)" > "$logdir/server.txt"
start_tw_server
else
echo "client log $(date)" > "$logdir/client.txt"
echo "server log $(date)" > "$ruby_logfile"
connect_tw_client
echo "ddnet7 client log $(date)" > "$logdir/client.txt"
echo "ruby server log $(date)" > "$ruby_logfile"
fi
timeout 6 killme &
_timeout_pid=$!
if ! ruby "$testname" killme &> "$ruby_logfile"
then
fail "test $testname finished with non zero exit code"
fi
if [[ "$testname" =~ ^server/ ]]
then
connect_ddnet7_client &>> "$logdir/client.txt" &
sleep 1
echo "connect 127.0.0.1" > "$cl_fifo"
fi
timeout 3 killme &
_timout_pid=$!
ruby "$testname" killme &> "$ruby_logfile"
if [ "$testname" == "client/chat.rb" ]
then
@ -196,6 +232,11 @@ then
then
fail "Error: 'block 1' found after 'block 2' in client log"
fi
elif [ "$testname" == "server/connect.rb" ]
then
echo "rcon test" > "$cl_fifo"
sleep 1
echo "shutdown" > "$cl_fifo"
else
echo "Error: unkown test '$testname'"
exit 1
@ -203,7 +244,7 @@ fi
if [ -f timeout.txt ]
then
echo "[-] Error timouted"
echo "[-] Error timeouted"
exit 1
fi