Skip to content

Commit b88f8d2

Browse files
authored
fix(travis): add various fixes to travis tests (#2827)
1 parent 8f14f97 commit b88f8d2

File tree

6 files changed

+460
-98
lines changed

6 files changed

+460
-98
lines changed

lgsm/functions/command_backup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn_backup_trap(){
3030
fn_backup_check_lockfile(){
3131
if [ -f "${lockdir}/.backup.lock" ]; then
3232
fn_print_info_nl "Lock file found: Backup is currently running"
33-
fn_script_log_error "Lock file found: Backup is currently running: ${tmpdir}/.backup.lock"
33+
fn_script_log_error "Lock file found: Backup is currently running: ${lockdir}/.backup.lock"
3434
core_exit.sh
3535
fi
3636
}

lgsm/functions/command_monitor.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
1212

1313
fn_monitor_check_lockfile(){
1414
# Monitor does not run it lockfile is not found.
15-
if [ ! -f "${rootdir}/${lockselfname}" ]; then
15+
if [ ! -f "${lockdir}/${selfname}.lock" ]; then
1616
fn_print_dots "Checking lockfile: "
1717
fn_print_checking_eol
1818
fn_script_log_info "Checking lockfile: CHECKING"
@@ -26,8 +26,8 @@ fn_monitor_check_lockfile(){
2626
fi
2727

2828
# Fix if lockfile is not unix time or contains letters
29-
if [[ "$(cat "${rootdir}/${lockselfname}")" =~ [A-Za-z] ]]; then
30-
date '+%s' > "${rootdir}/${lockselfname}"
29+
if [[ "$(cat "${lockdir}/${selfname}.lock")" =~ [A-Za-z] ]]; then
30+
date '+%s' > "${lockdir}/${selfname}.lock"
3131
fi
3232
}
3333

@@ -108,7 +108,7 @@ for queryattempt in {1..5}; do
108108
fn_script_log_info "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt} : QUERYING"
109109
fn_sleep_time
110110
# querydelay
111-
if [ "$(cat "${rootdir}/${lockselfname}")" -gt "$(date "+%s" -d "${querydelay} mins ago")" ]; then
111+
if [ "$(cat "${lockdir}/${selfname}.lock")" -gt "$(date "+%s" -d "${querydelay} mins ago")" ]; then
112112
fn_print_ok "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: "
113113
fn_print_delay_eol_nl
114114
fn_script_log_info "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt} : DELAY"

tests/tests_fctrserver.sh

Lines changed: 114 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,17 @@ configdirserver="${configdir}/${gameservername}"
4141
configdirdefault="${lgsmdir}/config-default"
4242
userinput="${1}"
4343

44-
# Allows for testing not on Travis CI
45-
if [ ! -v TRAVIS ]; then
44+
# Allows for testing not on Travis CI.
45+
# if using travis for tests
46+
if [ -n "${TRAVIS}" ]; then
47+
selfname="travis"
48+
# if not using travis for tests
49+
else
4650
TRAVIS_BRANCH="develop"
4751
TRAVIS_BUILD_DIR="${rootdir}"
48-
else
49-
selfname="travis"
50-
travistest="1"
52+
5153
fi
54+
travistest="1"
5255

5356
## GitHub Branch Select
5457
# Allows for the use of different function files
@@ -353,19 +356,24 @@ else
353356
fi
354357
fi
355358
fi
359+
# shellcheck source=/dev/null
356360
source "${configdirserver}/_default.cfg"
357361
# Load the common.cfg config. If missing download it.
358362
if [ ! -f "${configdirserver}/common.cfg" ]; then
359363
fn_fetch_config "lgsm/config-default/config-lgsm" "common-template.cfg" "${configdirserver}" "common.cfg" "${chmodx}" "nochmodx" "norun" "noforcedl" "nomd5"
364+
# shellcheck source=/dev/null
360365
source "${configdirserver}/common.cfg"
361366
else
367+
# shellcheck source=/dev/null
362368
source "${configdirserver}/common.cfg"
363369
fi
364370
# Load the instance.cfg config. If missing download it.
365371
if [ ! -f "${configdirserver}/${selfname}.cfg" ]; then
366372
fn_fetch_config "lgsm/config-default/config-lgsm" "instance-template.cfg" "${configdirserver}" "${selfname}.cfg" "nochmodx" "norun" "noforcedl" "nomd5"
373+
# shellcheck source=/dev/null
367374
source "${configdirserver}/${selfname}.cfg"
368375
else
376+
# shellcheck source=/dev/null
369377
source "${configdirserver}/${selfname}.cfg"
370378
fi
371379

@@ -377,7 +385,7 @@ else
377385
# Enables ANSI colours from core_messages.sh. Can be disabled with ansi=off.
378386
fn_ansi_loader
379387
# Prevents running of core_exit.sh for Travis-CI.
380-
if [ -z "${travistest}" ]; then
388+
if [ "${travistest}" != "1" ]; then
381389
getopt=$1
382390
core_getopt.sh
383391
fi
@@ -392,15 +400,6 @@ fn_currentstatus_tmux(){
392400
fi
393401
}
394402

395-
fn_currentstatus_ts3(){
396-
check_status.sh
397-
if [ "${status}" != "0" ]; then
398-
currentstatus="ONLINE"
399-
else
400-
currentstatus="OFFLINE"
401-
fi
402-
}
403-
404403
fn_setstatus(){
405404
fn_currentstatus_tmux
406405
echo""
@@ -490,10 +489,61 @@ echo -e ""
490489
echo -e "================================="
491490
echo -e "Server Tests"
492491
echo -e "Using: ${gamename}"
493-
echo -e "Testing Branch: $TRAVIS_BRANCH"
492+
echo -e "Testing Branch: ${TRAVIS_BRANCH}"
494493
echo -e "================================="
495494

496495
echo -e ""
496+
echo -e "Tests Summary"
497+
echo -e "================================="
498+
echo -e "0.0 - Pre-test Tasks"
499+
echo -e "0.1 - Create log dir's"
500+
echo -e "0.2 - Enable dev-debug"
501+
echo -e ""
502+
echo -e "1.0 - Pre-install tests"
503+
echo -e "1.1 - start - no files"
504+
echo -e "1.2 - getopt"
505+
echo -e "1.3 - getopt with incorrect args"
506+
echo -e ""
507+
echo -e "2.0 - Installation"
508+
echo -e "2.1 - install"
509+
echo -e ""
510+
echo -e "3.0 - Start/Stop/Restart Tests"
511+
echo -e "3.1 - start"
512+
echo -e "3.2 - start - online"
513+
echo -e "3.3 - start - updateonstart"
514+
echo -e "3.4 - stop"
515+
echo -e "3.5 - stop - offline"
516+
echo -e "3.6 - restart"
517+
echo -e "3.7 - restart - offline"
518+
echo -e ""
519+
echo -e "4.0 - Update Tests"
520+
echo -e "4.1 - update"
521+
echo -e "4.2 - update-lgsm"
522+
echo -e ""
523+
echo -e "5.0 - Monitor Tests"
524+
echo -e "5.1 - monitor - online"
525+
echo -e "5.2 - monitor - offline - with lockfile"
526+
echo -e "5.3 - monitor - offline - no lockfile"
527+
echo -e "5.4 - test-alert"
528+
echo -e ""
529+
echo -e "6.0 - Details Tests"
530+
echo -e "6.1 - details"
531+
echo -e "6.2 - postdetails"
532+
echo -e ""
533+
echo -e "7.0 - Backup Tests"
534+
echo -e "7.1 - backup"
535+
echo -e ""
536+
echo -e "8.0 - Development Tools Tests"
537+
echo -e "8.1 - dev - detect glibc"
538+
echo -e "8.2 - dev - detect ldd"
539+
echo -e "8.3 - dev - detect deps"
540+
echo -e "8.4 - dev - query-raw"
541+
542+
echo -e ""
543+
echo -e "9.0 - Donate"
544+
echo -e "9.1 - donate"
545+
echo -e ""
546+
497547
echo -e "0.0 - Pre-test Tasks"
498548
echo -e "=================================================================="
499549
echo -e "Description:"
@@ -543,7 +593,7 @@ echo -e "test script reaction to missing server files."
543593
echo -e "Command: ./${gameservername} start"
544594
echo -e ""
545595
# Allows for testing not on Travis CI
546-
if [ ! -v TRAVIS ]; then
596+
if [ -z "${TRAVIS}" ]; then
547597
(
548598
exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
549599
BASH_XTRACEFD="5"
@@ -601,7 +651,7 @@ echo -e "2.0 - Installation"
601651
echo -e "=================================================================="
602652

603653
echo -e ""
604-
echo -e "2.0 - install"
654+
echo -e "2.1 - install"
605655
echo -e "================================="
606656
echo -e "Description:"
607657
echo -e "install ${gamename} server."
@@ -777,10 +827,31 @@ echo -e "run order"
777827
echo -e "================="
778828
grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
779829

830+
echo -e ""
831+
echo -e "4.2 - update-lgsm"
832+
echo -e "================================="
833+
echo -e "Description:"
834+
echo -e "update LinuxGSM."
835+
echo -e ""
836+
echo -e "Command: ./jc2server update-lgam"
837+
requiredstatus="ONLINE"
838+
fn_setstatus
839+
(
840+
exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
841+
BASH_XTRACEFD="5"
842+
set -x
843+
command_update_linuxgsm.sh
844+
)
845+
fn_test_result_pass
846+
echo -e "run order"
847+
echo -e "================="
848+
grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
849+
780850
echo -e ""
781851
echo -e "5.0 - Monitor Tests"
782852
echo -e "=================================================================="
783853
echo -e ""
854+
info_config.sh
784855
echo -e "Server IP - Port: ${ip}:${port}"
785856
echo -e "Server IP - Query Port: ${ip}:${queryport}"
786857

@@ -1003,15 +1074,36 @@ echo -e "run order"
10031074
echo -e "================="
10041075
grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
10051076

1077+
echo -e ""
1078+
1079+
echo -e "9.0 - Donate"
1080+
echo -e "=================================================================="
1081+
1082+
echo -e ""
1083+
echo -e "9.1 - donate"
1084+
echo -e "================================="
1085+
echo -e "Description:"
1086+
echo -e "donate."
1087+
echo -e "Command: ./${gameservername} donate"
1088+
requiredstatus="ONLINE"
1089+
fn_setstatus
1090+
(
1091+
exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
1092+
BASH_XTRACEFD="5"
1093+
set -x
1094+
command_donate.sh
1095+
)
1096+
fn_test_result_pass
1097+
echo -e "run order"
1098+
echo -e "================="
1099+
grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
1100+
10061101
echo -e ""
10071102
echo -e "================================="
10081103
echo -e "Server Tests - Complete!"
10091104
echo -e "Using: ${gamename}"
10101105
echo -e "================================="
10111106
requiredstatus="OFFLINE"
10121107
fn_setstatus
1013-
if [ ! -v TRAVIS ]; then
1014-
fn_print_info "Tidying up directories."
1015-
rm -rfv "${serverfiles:?}"
1016-
fi
1108+
10171109
core_exit.sh

0 commit comments

Comments
 (0)