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