Add failing server side integration test
This commit is contained in:
parent
0dcb85a0e3
commit
10a75cdb65
14
.github/workflows/integration.yml
vendored
14
.github/workflows/integration.yml
vendored
|
@ -32,12 +32,20 @@ jobs:
|
||||||
unzip DDNet-headless.zip
|
unzip DDNet-headless.zip
|
||||||
sudo mv DDNet-headless /usr/local/bin
|
sudo mv DDNet-headless /usr/local/bin
|
||||||
rm DDNet-headless.zip
|
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: |
|
run: |
|
||||||
./integration_test/run.sh client/chat.rb
|
./integration_test/run.sh client/chat.rb
|
||||||
- name: Test reconnect
|
- name: '[CLIENT] Test reconnect'
|
||||||
run: |
|
run: |
|
||||||
./integration_test/run.sh client/reconnect.rb
|
./integration_test/run.sh client/reconnect.rb
|
||||||
- name: Test rcon
|
- name: '[CLIENT] Test rcon'
|
||||||
run: |
|
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
2
.gitignore
vendored
|
@ -8,5 +8,7 @@ integration_test/*.db
|
||||||
integration_test/*.sql
|
integration_test/*.sql
|
||||||
integration_test/*.sqlite
|
integration_test/*.sqlite
|
||||||
integration_test/*.sqlite3
|
integration_test/*.sqlite3
|
||||||
|
integration_test/*.fifo
|
||||||
integration_test/logs
|
integration_test/logs
|
||||||
|
integration_test/tmp
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,17 @@ cd "$(dirname "$0")" || exit 1
|
||||||
|
|
||||||
tw_srv_bin=teeworlds_srv
|
tw_srv_bin=teeworlds_srv
|
||||||
tw_cl_bin=teeworlds
|
tw_cl_bin=teeworlds
|
||||||
|
logdir=logs
|
||||||
|
tmpdir=tmp
|
||||||
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'
|
cl_fifo="$tmpdir/client.fifo"
|
||||||
|
clcfg="cl_input_fifo $cl_fifo;connect 127.0.0.1:8377;killme"
|
||||||
tw_srv_running=0
|
tw_srv_running=0
|
||||||
tw_client_running=0
|
tw_client_running=0
|
||||||
logdir=logs
|
|
||||||
ruby_logfile=ruby_client.txt
|
ruby_logfile=ruby_client.txt
|
||||||
|
|
||||||
mkdir -p logs
|
mkdir -p logs
|
||||||
|
mkdir -p tmp
|
||||||
|
|
||||||
function start_tw_server() {
|
function start_tw_server() {
|
||||||
if [[ -x "$(command -v teeworlds_srv)" ]]
|
if [[ -x "$(command -v teeworlds_srv)" ]]
|
||||||
|
@ -35,11 +38,11 @@ function start_tw_server() {
|
||||||
function connect_tw_client() {
|
function connect_tw_client() {
|
||||||
if [[ -x "$(command -v teeworlds-headless)" ]]
|
if [[ -x "$(command -v teeworlds-headless)" ]]
|
||||||
then
|
then
|
||||||
teeworlds-headless "$clcfg" "$logdir/client.txt"
|
teeworlds-headless "$clcfg"
|
||||||
tw_cl_bin=teeworlds-headless
|
tw_cl_bin=teeworlds-headless
|
||||||
elif [[ -x "$(command -v /usr/local/bin/teeworlds-headless)" ]]
|
elif [[ -x "$(command -v /usr/local/bin/teeworlds-headless)" ]]
|
||||||
then
|
then
|
||||||
/usr/local/bin/teeworlds-headless "$clcfg" "$logdir/client.txt"
|
/usr/local/bin/teeworlds-headless "$clcfg"
|
||||||
tw_cl_bin=/usr/local/bin/teeworlds-headless
|
tw_cl_bin=/usr/local/bin/teeworlds-headless
|
||||||
elif [[ -x "$(command -v teeworlds)" ]]
|
elif [[ -x "$(command -v teeworlds)" ]]
|
||||||
then
|
then
|
||||||
|
@ -52,6 +55,22 @@ function connect_tw_client() {
|
||||||
tw_client_running=1
|
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() {
|
function get_test_names() {
|
||||||
(find client -name "*.rb";find server -name "*.rb") | tr '\n' ' '
|
(find client -name "*.rb";find server -name "*.rb") | tr '\n' ' '
|
||||||
}
|
}
|
||||||
|
@ -94,7 +113,7 @@ function cleanup() {
|
||||||
echo "[*] shutting down client ..."
|
echo "[*] shutting down client ..."
|
||||||
pkill -f "$tw_cl_bin $clcfg"
|
pkill -f "$tw_cl_bin $clcfg"
|
||||||
fi
|
fi
|
||||||
[[ "$_timout_pid" != "" ]] && kill "$_timout_pid" &> /dev/null
|
[[ "$_timeout_pid" != "" ]] && kill "$_timeout_pid" &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
@ -108,10 +127,18 @@ function fail() {
|
||||||
# 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 "$ruby_logfile" &>/dev/null
|
tail "$ruby_logfile" &>/dev/null
|
||||||
|
if [[ "$testname" =~ ^client/ ]]
|
||||||
|
then
|
||||||
echo "[-] end of ruby client log:"
|
echo "[-] end of ruby client log:"
|
||||||
tail "$ruby_logfile"
|
tail "$ruby_logfile"
|
||||||
echo "[-] end of server log:"
|
echo "[-] end of server log:"
|
||||||
tail "$logdir/server.txt"
|
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"
|
echo "$msg"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -133,13 +160,22 @@ then
|
||||||
echo "server log $(date)" > "$logdir/server.txt"
|
echo "server log $(date)" > "$logdir/server.txt"
|
||||||
start_tw_server
|
start_tw_server
|
||||||
else
|
else
|
||||||
echo "client log $(date)" > "$logdir/client.txt"
|
echo "ddnet7 client log $(date)" > "$logdir/client.txt"
|
||||||
echo "server log $(date)" > "$ruby_logfile"
|
echo "ruby server log $(date)" > "$ruby_logfile"
|
||||||
connect_tw_client
|
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
|
fi
|
||||||
timeout 3 killme &
|
|
||||||
_timout_pid=$!
|
|
||||||
ruby "$testname" killme &> "$ruby_logfile"
|
|
||||||
|
|
||||||
if [ "$testname" == "client/chat.rb" ]
|
if [ "$testname" == "client/chat.rb" ]
|
||||||
then
|
then
|
||||||
|
@ -196,6 +232,11 @@ then
|
||||||
then
|
then
|
||||||
fail "Error: 'block 1' found after 'block 2' in client log"
|
fail "Error: 'block 1' found after 'block 2' in client log"
|
||||||
fi
|
fi
|
||||||
|
elif [ "$testname" == "server/connect.rb" ]
|
||||||
|
then
|
||||||
|
echo "rcon test" > "$cl_fifo"
|
||||||
|
sleep 1
|
||||||
|
echo "shutdown" > "$cl_fifo"
|
||||||
else
|
else
|
||||||
echo "Error: unkown test '$testname'"
|
echo "Error: unkown test '$testname'"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -203,7 +244,7 @@ fi
|
||||||
|
|
||||||
if [ -f timeout.txt ]
|
if [ -f timeout.txt ]
|
||||||
then
|
then
|
||||||
echo "[-] Error timouted"
|
echo "[-] Error timeouted"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue