tests_fctrserver.sh 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  1. #!/bin/bash
  2. # Project: Game Server Managers - LinuxGSM
  3. # Author: Daniel Gibbs
  4. # License: MIT License, Copyright (c) 2019 Daniel Gibbs
  5. # Purpose: Travis CI Tests: Factorio | Linux Game Server Management Script
  6. # Contributors: https://linuxgsm.com/contrib
  7. # Documentation: https://docs.linuxgsm.com
  8. # Website: https://linuxgsm.com
  9. # DO NOT EDIT THIS FILE
  10. # LinuxGSM configuration is no longer edited here
  11. # To update your LinuxGSM config go to:
  12. # lgsm/config-lgsm
  13. # https://docs.linuxgsm.com/configuration/linuxgsm-config
  14. # Debugging
  15. if [ -f ".dev-debug" ]; then
  16. exec 5>dev-debug.log
  17. BASH_XTRACEFD="5"
  18. set -x
  19. fi
  20. version="v19.9.0"
  21. shortname="fctr"
  22. gameservername="fctrserver"
  23. rootdir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
  24. selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
  25. lockselfname=".${selfname}.lock"
  26. lgsmdir="${rootdir}/lgsm"
  27. logdir="${rootdir}/log"
  28. lgsmlogdir="${logdir}/lgsm"
  29. steamcmddir="${rootdir}/steamcmd"
  30. serverfiles="${rootdir}/serverfiles"
  31. functionsdir="${lgsmdir}/functions"
  32. libdir="${lgsmdir}/lib"
  33. tmpdir="${lgsmdir}/tmp"
  34. datadir="${lgsmdir}/data"
  35. serverlist="${datadir}/serverlist.csv"
  36. serverlistmenu="${datadir}/serverlistmenu.csv"
  37. configdir="${lgsmdir}/config-lgsm"
  38. configdirserver="${configdir}/${gameservername}"
  39. configdirdefault="${lgsmdir}/config-default"
  40. userinput="${1}"
  41. # Allows for testing not on Travis CI
  42. if [ ! -v TRAVIS ]; then
  43. TRAVIS_BRANCH="develop"
  44. TRAVIS_BUILD_DIR="${rootdir}"
  45. else
  46. selfname="travis"
  47. travistest="1"
  48. fi
  49. ## GitHub Branch Select
  50. # Allows for the use of different function files
  51. # from a different repo and/or branch.
  52. githubuser="GameServerManagers"
  53. githubrepo="LinuxGSM"
  54. githubbranch="${TRAVIS_BRANCH}"
  55. # Core function that is required first.
  56. core_functions.sh(){
  57. functionfile="${FUNCNAME[0]}"
  58. fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5"
  59. }
  60. # Bootstrap
  61. # Fetches the core functions required before passed off to core_dl.sh.
  62. fn_bootstrap_fetch_file(){
  63. remote_fileurl="${1}"
  64. local_filedir="${2}"
  65. local_filename="${3}"
  66. chmodx="${4:-0}"
  67. run="${5:-0}"
  68. forcedl="${6:-0}"
  69. md5="${7:-0}"
  70. # Download file if missing or download forced.
  71. if [ ! -f "${local_filedir}/${local_filename}" ]||[ "${forcedl}" == "forcedl" ]; then
  72. if [ ! -d "${local_filedir}" ]; then
  73. mkdir -p "${local_filedir}"
  74. fi
  75. # If curl exists download file.
  76. if [ "$(command -v curl 2>/dev/null)" ]; then
  77. # Trap to remove part downloaded files.
  78. echo -en " fetching ${local_filename}...\c"
  79. curlcmd=$(curl -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1)
  80. local exitcode=$?
  81. if [ ${exitcode} -ne 0 ]; then
  82. echo -e "FAIL"
  83. if [ -f "${lgsmlog}" ]; then
  84. echo -e "${remote_fileurl}" | tee -a "${lgsmlog}"
  85. echo -e "${curlcmd}" | tee -a "${lgsmlog}"
  86. fi
  87. exit 1
  88. else
  89. echo -e "OK"
  90. fi
  91. else
  92. echo -e "[ FAIL ] Curl is not installed"
  93. exit 1
  94. fi
  95. # Make file chmodx if chmodx is set.
  96. if [ "${chmodx}" == "chmodx" ]; then
  97. chmod +x "${local_filedir}/${local_filename}"
  98. fi
  99. fi
  100. if [ -f "${local_filedir}/${local_filename}" ]; then
  101. # Run file if run is set.
  102. if [ "${run}" == "run" ]; then
  103. # shellcheck source=/dev/null
  104. source "${local_filedir}/${local_filename}"
  105. fi
  106. fi
  107. }
  108. fn_bootstrap_fetch_file_github(){
  109. github_file_url_dir="${1}"
  110. github_file_url_name="${2}"
  111. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  112. remote_fileurl="${githuburl}"
  113. local_filedir="${3}"
  114. local_filename="${github_file_url_name}"
  115. chmodx="${4:-0}"
  116. run="${5:-0}"
  117. forcedl="${6:-0}"
  118. md5="${7:-0}"
  119. # Passes vars to the file download function.
  120. fn_bootstrap_fetch_file "${remote_fileurl}" "${local_filedir}" "${local_filename}" "${chmodx}" "${run}" "${forcedl}" "${md5}"
  121. }
  122. # Installer menu.
  123. fn_print_center() {
  124. columns=$(tput cols)
  125. line="$*"
  126. printf "%*s\n" $(( (${#line} + columns) / 2)) "${line}"
  127. }
  128. fn_print_horizontal(){
  129. printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "="
  130. }
  131. # Bash menu.
  132. fn_install_menu_bash() {
  133. local resultvar=$1
  134. title=$2
  135. caption=$3
  136. options=$4
  137. fn_print_horizontal
  138. fn_print_center "${title}"
  139. fn_print_center "${caption}"
  140. fn_print_horizontal
  141. menu_options=()
  142. while read -r line || [[ -n "${line}" ]]; do
  143. var=$(echo -e "${line}" | awk -F "," '{print $2 " - " $3}')
  144. menu_options+=( "${var}" )
  145. done < "${options}"
  146. menu_options+=( "Cancel" )
  147. select option in "${menu_options[@]}"; do
  148. if [ -n "${option}" ]&&[ "${option}" != "Cancel" ]; then
  149. eval "$resultvar=\"${option/%\ */}\""
  150. fi
  151. break
  152. done
  153. }
  154. # Whiptail/Dialog menu.
  155. fn_install_menu_whiptail() {
  156. local menucmd=$1
  157. local resultvar=$2
  158. title=$3
  159. caption=$4
  160. options=$5
  161. height=${6:-40}
  162. width=${7:-80}
  163. menuheight=${8:-30}
  164. IFS=","
  165. menu_options=()
  166. while read -r line; do
  167. key=$(echo -e "${line}" | awk -F "," '{print $3}')
  168. val=$(echo -e "${line}" | awk -F "," '{print $2}')
  169. menu_options+=( "${val//\"}" "${key//\"}" )
  170. done < "${options}"
  171. OPTION=$(${menucmd} --title "${title}" --menu "${caption}" "${height}" "${width}" "${menuheight}" "${menu_options[@]}" 3>&1 1>&2 2>&3)
  172. if [ $? == 0 ]; then
  173. eval "$resultvar=\"${OPTION}\""
  174. else
  175. eval "$resultvar="
  176. fi
  177. }
  178. # Menu selector.
  179. fn_install_menu() {
  180. local resultvar=$1
  181. local selection=""
  182. title=$2
  183. caption=$3
  184. options=$4
  185. # Get menu command.
  186. for menucmd in whiptail dialog bash; do
  187. if [ "$(command -v "${menucmd}")" ]; then
  188. menucmd=$(command -v "${menucmd}")
  189. break
  190. fi
  191. done
  192. case "$(basename "${menucmd}")" in
  193. whiptail|dialog)
  194. fn_install_menu_whiptail "${menucmd}" selection "${title}" "${caption}" "${options}" 40 80 30;;
  195. *)
  196. fn_install_menu_bash selection "${title}" "${caption}" "${options}";;
  197. esac
  198. eval "$resultvar=\"${selection}\""
  199. }
  200. # Gets server info from serverlist.csv and puts in to array.
  201. fn_server_info(){
  202. IFS=","
  203. server_info_array=($(grep -aw "${userinput}" "${serverlist}"))
  204. shortname="${server_info_array[0]}" # csgo
  205. gameservername="${server_info_array[1]}" # csgoserver
  206. gamename="${server_info_array[2]}" # Counter Strike: Global Offensive
  207. }
  208. fn_install_getopt(){
  209. userinput="empty"
  210. echo -e "Usage: $0 [option]"
  211. echo -e ""
  212. echo -e "Installer - Linux Game Server Managers - Version ${version}"
  213. echo -e "https://linuxgsm.com"
  214. echo -e ""
  215. echo -e "Commands"
  216. echo -e "install\t\t| Select server to install."
  217. echo -e "servername\t| Enter name of game server to install. e.g $0 csgoserver."
  218. echo -e "list\t\t| List all servers available for install."
  219. exit
  220. }
  221. fn_install_file(){
  222. local_filename="${gameservername}"
  223. if [ -e "${local_filename}" ]; then
  224. i=2
  225. while [ -e "${local_filename}-${i}" ] ; do
  226. (( i++ ))
  227. done
  228. local_filename="${local_filename}-${i}"
  229. fi
  230. cp -R "${selfname}" "${local_filename}"
  231. sed -i -e "s/shortname=\"core\"/shortname=\"${shortname}\"/g" "${local_filename}"
  232. sed -i -e "s/gameservername=\"core\"/gameservername=\"${gameservername}\"/g" "${local_filename}"
  233. echo -e "Installed ${gamename} server as ${local_filename}"
  234. echo -e ""
  235. if [ ! -d "${serverfiles}" ]; then
  236. echo -e "./${local_filename} install"
  237. else
  238. echo -e "Remember to check server ports"
  239. echo -e "./${local_filename} details"
  240. fi
  241. echo -e ""
  242. exit
  243. }
  244. # Prevent LinuxGSM from running as root. Except if doing a dependency install.
  245. if [ "$(whoami)" == "root" ]; then
  246. if [ "${userinput}" == "install" ]||[ "${userinput}" == "auto-install" ]||[ "${userinput}" == "i" ]||[ "${userinput}" == "ai" ]; then
  247. if [ "${shortname}" == "core" ]; then
  248. echo -e "[ FAIL ] Do NOT run this script as root!"
  249. exit 1
  250. fi
  251. elif [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]; then
  252. echo -e "[ FAIL ] Do NOT run this script as root!"
  253. exit 1
  254. else
  255. core_functions.sh
  256. check_root.sh
  257. fi
  258. fi
  259. # LinuxGSM installer mode.
  260. if [ "${shortname}" == "core" ]; then
  261. # Download the latest serverlist. This is the complete list of all supported servers.
  262. fn_bootstrap_fetch_file_github "lgsm/data" "serverlist.csv" "${datadir}" "nochmodx" "norun" "forcedl" "nomd5"
  263. if [ ! -f "${serverlist}" ]; then
  264. echo -e "[ FAIL ] serverlist.csv could not be loaded."
  265. exit 1
  266. fi
  267. if [ "${userinput}" == "list" ]||[ "${userinput}" == "l" ]; then
  268. {
  269. tail -n +2 "${serverlist}" | awk -F "," '{print $2 "\t" $3}'
  270. } | column -s $'\t' -t | more
  271. exit
  272. elif [ "${userinput}" == "install" ]||[ "${userinput}" == "i" ]; then
  273. tail -n +2 "${serverlist}" | awk -F "," '{print $1 "," $2 "," $3}' > "${serverlistmenu}"
  274. fn_install_menu result "LinuxGSM" "Select game server to install." "${serverlistmenu}"
  275. userinput="${result}"
  276. fn_server_info
  277. if [ "${result}" == "${gameservername}" ]; then
  278. fn_install_file
  279. elif [ "${result}" == "" ]; then
  280. echo -e "Install canceled"
  281. else
  282. echo -e "[ FAIL ] menu result does not match gameservername"
  283. echo -e "result: ${result}"
  284. echo -e "gameservername: ${gameservername}"
  285. fi
  286. elif [ -n "${userinput}" ]; then
  287. fn_server_info
  288. if [ "${userinput}" == "${gameservername}" ]||[ "${userinput}" == "${gamename}" ]||[ "${userinput}" == "${shortname}" ]; then
  289. fn_install_file
  290. else
  291. echo -e "[ FAIL ] unknown game server"
  292. fi
  293. else
  294. fn_install_getopt
  295. fi
  296. # LinuxGSM server mode.
  297. else
  298. core_functions.sh
  299. if [ "${shortname}" != "core-dep" ]; then
  300. # Load LinuxGSM configs.
  301. # These are required to get all the default variables for the specific server.
  302. # Load the default config. If missing download it. If changed reload it.
  303. if [ ! -f "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" ]; then
  304. mkdir -p "${configdirdefault}/config-lgsm/${gameservername}"
  305. fn_fetch_config "lgsm/config-default/config-lgsm/${gameservername}" "_default.cfg" "${configdirdefault}/config-lgsm/${gameservername}" "_default.cfg" "nochmodx" "norun" "noforcedl" "nomd5"
  306. fi
  307. if [ ! -f "${configdirserver}/_default.cfg" ]; then
  308. mkdir -p "${configdirserver}"
  309. echo -en " copying _default.cfg...\c"
  310. cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg"
  311. exitcode=$?
  312. if [ ${exitcode} -ne 0 ]; then
  313. echo -e "FAIL"
  314. exit 1
  315. else
  316. echo -e "OK"
  317. fi
  318. else
  319. function_file_diff=$(diff -q "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg")
  320. if [ "${function_file_diff}" != "" ]; then
  321. fn_print_warn_nl "_default.cfg has been altered. reloading config."
  322. echo -en " copying _default.cfg...\c"
  323. cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg"
  324. exitcode=$?
  325. if [ ${exitcode} -ne 0 ]; then
  326. echo -e "FAIL"
  327. exit 1
  328. else
  329. echo -e "OK"
  330. fi
  331. fi
  332. fi
  333. source "${configdirserver}/_default.cfg"
  334. # Load the common.cfg config. If missing download it.
  335. if [ ! -f "${configdirserver}/common.cfg" ]; then
  336. fn_fetch_config "lgsm/config-default/config-lgsm" "common-template.cfg" "${configdirserver}" "common.cfg" "${chmodx}" "nochmodx" "norun" "noforcedl" "nomd5"
  337. source "${configdirserver}/common.cfg"
  338. else
  339. source "${configdirserver}/common.cfg"
  340. fi
  341. # Load the instance.cfg config. If missing download it.
  342. if [ ! -f "${configdirserver}/${selfname}.cfg" ]; then
  343. fn_fetch_config "lgsm/config-default/config-lgsm" "instance-template.cfg" "${configdirserver}" "${selfname}.cfg" "nochmodx" "norun" "noforcedl" "nomd5"
  344. source "${configdirserver}/${selfname}.cfg"
  345. else
  346. source "${configdirserver}/${selfname}.cfg"
  347. fi
  348. # Load the linuxgsm.sh in to tmpdir. If missing download it.
  349. if [ ! -f "${tmpdir}/linuxgsm.sh" ]; then
  350. fn_fetch_file_github "" "linuxgsm.sh" "${tmpdir}" "chmodx" "norun" "noforcedl" "nomd5"
  351. fi
  352. fi
  353. # Enables ANSI colours from core_messages.sh. Can be disabled with ansi=off.
  354. fn_ansi_loader
  355. # Prevents running of core_exit.sh for Travis-CI.
  356. if [ -z "${travistest}" ]; then
  357. getopt=$1
  358. core_getopt.sh
  359. fi
  360. fi
  361. fn_currentstatus_tmux(){
  362. check_status.sh
  363. if [ "${status}" != "0" ]; then
  364. currentstatus="ONLINE"
  365. else
  366. currentstatus="OFFLINE"
  367. fi
  368. }
  369. fn_currentstatus_ts3(){
  370. check_status.sh
  371. if [ "${status}" != "0" ]; then
  372. currentstatus="ONLINE"
  373. else
  374. currentstatus="OFFLINE"
  375. fi
  376. }
  377. fn_setstatus(){
  378. fn_currentstatus_tmux
  379. echo""
  380. echo -e "Required status: ${requiredstatus}"
  381. counter=0
  382. echo -e "Current status: ${currentstatus}"
  383. while [ "${requiredstatus}" != "${currentstatus}" ]; do
  384. counter=$((counter+1))
  385. fn_currentstatus_tmux
  386. echo -en "New status: ${currentstatus}\\r"
  387. if [ "${requiredstatus}" == "ONLINE" ]; then
  388. (command_start.sh > /dev/null 2>&1)
  389. else
  390. (command_stop.sh > /dev/null 2>&1)
  391. fi
  392. if [ "${counter}" -gt "5" ]; then
  393. currentstatus="FAIL"
  394. echo -e "Current status: ${currentstatus}"
  395. echo -e ""
  396. echo -e "Unable to start or stop server."
  397. exit 1
  398. fi
  399. done
  400. echo -en "New status: ${currentstatus}\\r"
  401. echo -e "\n"
  402. echo -e "Test starting:"
  403. echo -e ""
  404. }
  405. # End of every test will expect the result to either pass or fail
  406. # If the script does not do as intended the whole test will fail
  407. # if expecting a pass
  408. fn_test_result_pass(){
  409. if [ $? != 0 ]; then
  410. echo -e "================================="
  411. echo -e "Expected result: PASS"
  412. echo -e "Actual result: FAIL"
  413. fn_print_fail_nl "TEST FAILED"
  414. exitcode=1
  415. core_exit.sh
  416. else
  417. echo -e "================================="
  418. echo -e "Expected result: PASS"
  419. echo -e "Actual result: PASS"
  420. fn_print_ok_nl "TEST PASSED"
  421. echo -e ""
  422. fi
  423. }
  424. # if expecting a fail
  425. fn_test_result_fail(){
  426. if [ $? == 0 ]; then
  427. echo -e "================================="
  428. echo -e "Expected result: FAIL"
  429. echo -e "Actual result: PASS"
  430. fn_print_fail_nl "TEST FAILED"
  431. exitcode=1
  432. core_exit.sh
  433. else
  434. echo -e "================================="
  435. echo -e "Expected result: FAIL"
  436. echo -e "Actual result: FAIL"
  437. fn_print_ok_nl "TEST PASSED"
  438. echo -e ""
  439. fi
  440. }
  441. # test result n/a
  442. fn_test_result_na(){
  443. echo -e "================================="
  444. echo -e "Expected result: N/A"
  445. echo -e "Actual result: N/A"
  446. fn_print_fail_nl "TEST N/A"
  447. }
  448. sleeptime="0"
  449. echo -e "================================="
  450. echo -e "Travis CI Tests"
  451. echo -e "Linux Game Server Manager"
  452. echo -e "by Daniel Gibbs"
  453. echo -e "Contributors: http://goo.gl/qLmitD"
  454. echo -e "https://linuxgsm.com"
  455. echo -e "================================="
  456. echo -e ""
  457. echo -e "================================="
  458. echo -e "Server Tests"
  459. echo -e "Using: ${gamename}"
  460. echo -e "Testing Branch: $TRAVIS_BRANCH"
  461. echo -e "================================="
  462. echo -e ""
  463. echo -e "0.0 - Pre-test Tasks"
  464. echo -e "=================================================================="
  465. echo -e "Description:"
  466. echo -e "Create log dir's"
  467. echo -e ""
  468. echo -e ""
  469. echo -e "0.1 - Create log dir's"
  470. echo -e "================================="
  471. echo -e ""
  472. (
  473. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  474. BASH_XTRACEFD="5"
  475. set -x
  476. install_logs.sh
  477. )
  478. echo -e "run order"
  479. echo -e "================="
  480. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  481. echo -e ""
  482. echo -e "0.2 - Enable dev-debug"
  483. echo -e "================================="
  484. echo -e "Description:"
  485. echo -e "Enable dev-debug"
  486. echo -e ""
  487. (
  488. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  489. BASH_XTRACEFD="5"
  490. set -x
  491. command_dev_debug.sh
  492. )
  493. fn_test_result_pass
  494. echo -e "run order"
  495. echo -e "================="
  496. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  497. echo -e ""
  498. echo -e "1.0 - Pre-install tests"
  499. echo -e "=================================================================="
  500. echo -e ""
  501. echo -e "1.1 - start - no files"
  502. echo -e "================================="
  503. echo -e "Description:"
  504. echo -e "test script reaction to missing server files."
  505. echo -e "Command: ./${gameservername} start"
  506. echo -e ""
  507. # Allows for testing not on Travis CI
  508. if [ ! -v TRAVIS ]; then
  509. (
  510. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  511. BASH_XTRACEFD="5"
  512. set -x
  513. command_start.sh
  514. )
  515. fn_test_result_fail
  516. else
  517. echo -e "Test bypassed"
  518. fi
  519. echo -e "run order"
  520. echo -e "================="
  521. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  522. echo -e ""
  523. echo -e "1.2 - getopt"
  524. echo -e "================================="
  525. echo -e "Description:"
  526. echo -e "displaying options messages."
  527. echo -e "Command: ./${gameservername}"
  528. echo -e ""
  529. (
  530. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  531. BASH_XTRACEFD="5"
  532. set -x
  533. core_getopt.sh
  534. )
  535. fn_test_result_pass
  536. echo -e "run order"
  537. echo -e "================="
  538. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  539. echo -e ""
  540. echo -e "1.3 - getopt with incorrect args"
  541. echo -e "================================="
  542. echo -e "Description:"
  543. echo -e "displaying options messages."
  544. echo -e "Command: ./${gameservername} abc123"
  545. echo -e ""
  546. getopt="abc123"
  547. (
  548. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  549. BASH_XTRACEFD="5"
  550. set -x
  551. core_getopt.sh
  552. )
  553. fn_test_result_fail
  554. echo -e "run order"
  555. echo -e "================="
  556. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  557. echo -e ""
  558. echo -e "2.0 - Installation"
  559. echo -e "=================================================================="
  560. echo -e ""
  561. echo -e "2.0 - install"
  562. echo -e "================================="
  563. echo -e "Description:"
  564. echo -e "install ${gamename} server."
  565. echo -e "Command: ./${gameservername} auto-install"
  566. (
  567. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  568. BASH_XTRACEFD="5"
  569. set -x
  570. fn_autoinstall
  571. )
  572. fn_test_result_pass
  573. echo -e "run order"
  574. echo -e "================="
  575. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  576. echo -e ""
  577. echo -e "3.0 - Start/Stop/Restart Tests"
  578. echo -e "=================================================================="
  579. echo -e ""
  580. echo -e "3.1 - start"
  581. echo -e "================================="
  582. echo -e "Description:"
  583. echo -e "start ${gamename} server."
  584. echo -e "Command: ./${gameservername} start"
  585. requiredstatus="OFFLINE"
  586. fn_setstatus
  587. (
  588. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  589. BASH_XTRACEFD="5"
  590. set -x
  591. command_start.sh
  592. )
  593. fn_test_result_pass
  594. echo -e "run order"
  595. echo -e "================="
  596. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  597. echo -e ""
  598. echo -e "3.2 - start - online"
  599. echo -e "================================="
  600. echo -e "Description:"
  601. echo -e "start ${gamename} server while already running."
  602. echo -e "Command: ./${gameservername} start"
  603. requiredstatus="ONLINE"
  604. fn_setstatus
  605. (
  606. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  607. BASH_XTRACEFD="5"
  608. set -x
  609. command_start.sh
  610. )
  611. fn_test_result_fail
  612. echo -e "run order"
  613. echo -e "================="
  614. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  615. echo -e ""
  616. echo -e "3.3 - start - updateonstart"
  617. echo -e "================================="
  618. echo -e "Description:"
  619. echo -e "will update server on start."
  620. echo -e "Command: ./${gameservername} start"
  621. requiredstatus="OFFLINE"
  622. fn_setstatus
  623. (
  624. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  625. BASH_XTRACEFD="5"
  626. set -x
  627. updateonstart="on";command_start.sh
  628. )
  629. fn_test_result_pass
  630. echo -e "run order"
  631. echo -e "================="
  632. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  633. echo -e ""
  634. echo -e "3.4 - stop"
  635. echo -e "================================="
  636. echo -e "Description:"
  637. echo -e "stop ${gamename} server."
  638. echo -e "Command: ./${gameservername} stop"
  639. requiredstatus="ONLINE"
  640. fn_setstatus
  641. (
  642. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  643. BASH_XTRACEFD="5"
  644. set -x
  645. command_stop.sh
  646. )
  647. fn_test_result_pass
  648. echo -e "run order"
  649. echo -e "================="
  650. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  651. echo -e ""
  652. echo -e "3.5 - stop - offline"
  653. echo -e "================================="
  654. echo -e "Description:"
  655. echo -e "stop ${gamename} server while already stopped."
  656. echo -e "Command: ./${gameservername} stop"
  657. requiredstatus="OFFLINE"
  658. fn_setstatus
  659. (
  660. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  661. BASH_XTRACEFD="5"
  662. set -x
  663. command_stop.sh
  664. )
  665. fn_test_result_fail
  666. echo -e "run order"
  667. echo -e "================="
  668. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  669. echo -e ""
  670. echo -e "3.6 - restart"
  671. echo -e "================================="
  672. echo -e "Description:"
  673. echo -e "restart ${gamename}."
  674. echo -e "Command: ./${gameservername} restart"
  675. requiredstatus="ONLINE"
  676. fn_setstatus
  677. (
  678. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  679. BASH_XTRACEFD="5"
  680. set -x
  681. command_restart.sh
  682. )
  683. fn_test_result_pass
  684. echo -e "run order"
  685. echo -e "================="
  686. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  687. echo -e ""
  688. echo -e "3.7 - restart - offline"
  689. echo -e "================================="
  690. echo -e "Description:"
  691. echo -e "restart ${gamename} while already stopped."
  692. echo -e "Command: ./${gameservername} restart"
  693. requiredstatus="OFFLINE"
  694. fn_setstatus
  695. (
  696. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  697. BASH_XTRACEFD="5"
  698. set -x
  699. command_restart.sh
  700. )
  701. fn_test_result_pass
  702. echo -e "run order"
  703. echo -e "================="
  704. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  705. echo -e ""
  706. echo -e "4.0 - Update Tests"
  707. echo -e "=================================================================="
  708. echo -e ""
  709. echo -e "4.1 - update"
  710. echo -e "================================="
  711. echo -e "Description:"
  712. echo -e "check for updates."
  713. echo -e "Command: ./${gameservername} update"
  714. requiredstatus="OFFLINE"
  715. fn_setstatus
  716. (
  717. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  718. BASH_XTRACEFD="5"
  719. set -x
  720. command_update.sh
  721. )
  722. fn_test_result_pass
  723. echo -e "run order"
  724. echo -e "================="
  725. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  726. echo -e ""
  727. echo -e "5.0 - Monitor Tests"
  728. echo -e "=================================================================="
  729. echo -e ""
  730. echo -e "Server IP - Port: ${ip}:${port}"
  731. echo -e "Server IP - Query Port: ${ip}:${queryport}"
  732. echo -e ""
  733. echo -e "5.1 - monitor - online"
  734. echo -e "================================="
  735. echo -e "Description:"
  736. echo -e "run monitor server while already running."
  737. echo -e "Command: ./${gameservername} monitor"
  738. requiredstatus="ONLINE"
  739. fn_setstatus
  740. (
  741. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  742. BASH_XTRACEFD="5"
  743. set -x
  744. command_monitor.sh
  745. )
  746. fn_test_result_pass
  747. echo -e "run order"
  748. echo -e "================="
  749. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  750. echo -e ""
  751. echo -e "5.2 - monitor - offline - with lockfile"
  752. echo -e "================================="
  753. echo -e "Description:"
  754. echo -e "run monitor while server is offline with lockfile."
  755. echo -e "Command: ./${gameservername} monitor"
  756. requiredstatus="OFFLINE"
  757. fn_setstatus
  758. fn_print_info_nl "creating lockfile."
  759. date '+%s' > "${rootdir}/${lockselfname}"
  760. (
  761. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  762. BASH_XTRACEFD="5"
  763. set -x
  764. command_monitor.sh
  765. )
  766. fn_test_result_pass
  767. echo -e "run order"
  768. echo -e "================="
  769. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  770. echo -e ""
  771. echo -e "5.3 - monitor - offline - no lockfile"
  772. echo -e "================================="
  773. echo -e "Description:"
  774. echo -e "run monitor while server is offline with no lockfile."
  775. echo -e "Command: ./${gameservername} monitor"
  776. requiredstatus="OFFLINE"
  777. fn_setstatus
  778. (
  779. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  780. BASH_XTRACEFD="5"
  781. set -x
  782. command_monitor.sh
  783. )
  784. fn_test_result_fail
  785. echo -e "run order"
  786. echo -e "================="
  787. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  788. echo -e ""
  789. echo -e "5.4 - test-alert"
  790. echo -e "================================="
  791. echo -e "Description:"
  792. echo -e "run monitor while server is offline with no lockfile."
  793. echo -e "Command: ./${gameservername} test-alert"
  794. requiredstatus="OFFLINE"
  795. fn_setstatus
  796. (
  797. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  798. BASH_XTRACEFD="5"
  799. set -x
  800. command_test_alert.sh
  801. )
  802. fn_test_result_fail
  803. echo -e "run order"
  804. echo -e "================="
  805. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  806. echo -e ""
  807. echo -e "6.0 - Details Tests"
  808. echo -e "=================================================================="
  809. echo -e ""
  810. echo -e "6.1 - details"
  811. echo -e "================================="
  812. echo -e "Description:"
  813. echo -e "display details."
  814. echo -e "Command: ./${gameservername} details"
  815. requiredstatus="ONLINE"
  816. fn_setstatus
  817. (
  818. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  819. BASH_XTRACEFD="5"
  820. set -x
  821. command_details.sh
  822. )
  823. fn_test_result_pass
  824. echo -e "run order"
  825. echo -e "================="
  826. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  827. echo -e ""
  828. echo -e "6.2 - postdetails"
  829. echo -e "================================="
  830. echo -e "Description:"
  831. echo -e "post details."
  832. echo -e "Command: ./${gameservername} postdetails"
  833. requiredstatus="ONLINE"
  834. fn_setstatus
  835. (
  836. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  837. BASH_XTRACEFD="5"
  838. set -x
  839. command_postdetails.sh
  840. )
  841. fn_test_result_pass
  842. echo -e "run order"
  843. echo -e "================="
  844. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  845. echo -e ""
  846. echo -e "7.0 - Backup Tests"
  847. echo -e "=================================================================="
  848. echo -e ""
  849. echo -e "7.1 - backup"
  850. echo -e "================================="
  851. echo -e "Description:"
  852. echo -e "run a backup."
  853. echo -e "Command: ./${gameservername} backup"
  854. requiredstatus="ONLINE"
  855. fn_setstatus
  856. echo -e "test de-activated until issue #1839 fixed"
  857. #(command_backup.sh)
  858. fn_test_result_pass
  859. echo -e "run order"
  860. echo -e "================="
  861. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  862. echo -e ""
  863. echo -e "8.0 - Development Tools Tests"
  864. echo -e "=================================================================="
  865. echo -e ""
  866. echo -e "8.1 - dev - detect glibc"
  867. echo -e "================================="
  868. echo -e "Description:"
  869. echo -e "detect glibc."
  870. echo -e "Command: ./${gameservername} detect-glibc"
  871. requiredstatus="ONLINE"
  872. fn_setstatus
  873. (
  874. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  875. BASH_XTRACEFD="5"
  876. set -x
  877. command_dev_detect_glibc.sh
  878. )
  879. fn_test_result_pass
  880. echo -e "run order"
  881. echo -e "================="
  882. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  883. echo -e ""
  884. echo -e "8.2 - dev - detect ldd"
  885. echo -e "================================="
  886. echo -e "Description:"
  887. echo -e "detect ldd."
  888. echo -e "Command: ./${gameservername} detect-ldd"
  889. requiredstatus="ONLINE"
  890. fn_setstatus
  891. (
  892. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  893. BASH_XTRACEFD="5"
  894. set -x
  895. command_dev_detect_ldd.sh
  896. )
  897. fn_test_result_pass
  898. echo -e "run order"
  899. echo -e "================="
  900. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  901. echo -e ""
  902. echo -e "8.3 - dev - detect deps"
  903. echo -e "================================="
  904. echo -e "Description:"
  905. echo -e "detect dependencies."
  906. echo -e "Command: ./${gameservername} detect-deps"
  907. requiredstatus="ONLINE"
  908. fn_setstatus
  909. (
  910. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  911. BASH_XTRACEFD="5"
  912. set -x
  913. command_dev_detect_deps.sh
  914. )
  915. fn_test_result_pass
  916. echo -e "run order"
  917. echo -e "================="
  918. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  919. echo -e ""
  920. echo -e "8.4 - dev - query-raw"
  921. echo -e "================================="
  922. echo -e "Description:"
  923. echo -e "raw query output."
  924. echo -e "Command: ./${gameservername} query-raw"
  925. requiredstatus="ONLINE"
  926. fn_setstatus
  927. (
  928. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  929. BASH_XTRACEFD="5"
  930. set -x
  931. command_dev_query_raw.sh
  932. )
  933. fn_test_result_na
  934. echo -e "run order"
  935. echo -e "================="
  936. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  937. echo -e ""
  938. echo -e "================================="
  939. echo -e "Server Tests - Complete!"
  940. echo -e "Using: ${gamename}"
  941. echo -e "================================="
  942. requiredstatus="OFFLINE"
  943. fn_setstatus
  944. if [ ! -v TRAVIS ]; then
  945. fn_print_info "Tidying up directories."
  946. rm -rfv "${serverfiles}"
  947. fi
  948. core_exit.sh