tests_ts3server.sh 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  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: Teamspeak 3 | 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="ts3"
  22. gameservername="ts3server"
  23. rootdir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
  24. selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  25. servicename="${selfname}"
  26. lockselfname=".${servicename}.lock"
  27. lgsmdir="${rootdir}/lgsm"
  28. logdir="${rootdir}/log"
  29. lgsmlogdir="${logdir}/lgsm"
  30. steamcmddir="${rootdir}/steamcmd"
  31. serverfiles="${rootdir}/serverfiles"
  32. functionsdir="${lgsmdir}/functions"
  33. libdir="${lgsmdir}/lib"
  34. tmpdir="${lgsmdir}/tmp"
  35. datadir="${lgsmdir}/data"
  36. serverlist="${datadir}/serverlist.csv"
  37. serverlistmenu="${datadir}/serverlistmenu.csv"
  38. configdir="${lgsmdir}/config-lgsm"
  39. configdirserver="${configdir}/${gameservername}"
  40. configdirdefault="${lgsmdir}/config-default"
  41. userinput="${1}"
  42. # Allows for testing not on Travis CI
  43. if [ ! -v TRAVIS ]; then
  44. TRAVIS_BRANCH="develop"
  45. TRAVIS_BUILD_DIR="${rootdir}"
  46. else
  47. servicename="travis"
  48. travistest="1"
  49. fi
  50. ## GitHub Branch Select
  51. # Allows for the use of different function files
  52. # from a different repo and/or branch.
  53. githubuser="GameServerManagers"
  54. githubrepo="LinuxGSM"
  55. githubbranch="${TRAVIS_BRANCH}"
  56. # Core function that is required first.
  57. core_functions.sh(){
  58. functionfile="${FUNCNAME}"
  59. fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5"
  60. }
  61. # Bootstrap
  62. # Fetches the core functions required before passed off to core_dl.sh.
  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 "${curlcmd}" | tee -a "${lgsmlog}"
  89. fi
  90. exit 1
  91. else
  92. echo -e "OK"
  93. fi
  94. else
  95. echo "[ 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 "${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 "${line}" | awk -F "," '{print $3}')
  171. val=$(echo "${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 "Usage: $0 [option]"
  214. echo -e ""
  215. echo "Installer - Linux Game Server Managers - Version ${version}"
  216. echo "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 "Installed ${gamename} server as ${local_filename}"
  237. echo ""
  238. if [ ! -d "${serverfiles}" ]; then
  239. echo "./${local_filename} install"
  240. else
  241. echo "Remember to check server ports"
  242. echo "./${local_filename} details"
  243. fi
  244. echo ""
  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 "[ 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 "[ 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. # LinuxGSM installer mode.
  263. if [ "${shortname}" == "core" ]; then
  264. # Download the latest serverlist. This is the complete list of all supported servers.
  265. fn_bootstrap_fetch_file_github "lgsm/data" "serverlist.csv" "${datadir}" "nochmodx" "norun" "forcedl" "nomd5"
  266. if [ ! -f "${serverlist}" ]; then
  267. echo "[ FAIL ] serverlist.csv could not be loaded."
  268. exit 1
  269. fi
  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 "Install canceled"
  284. else
  285. echo "[ FAIL ] menu result does not match gameservername"
  286. echo "result: ${result}"
  287. echo "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 "[ 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}/${servicename}.cfg" ]; then
  346. fn_fetch_config "lgsm/config-default/config-lgsm" "instance-template.cfg" "${configdirserver}" "${servicename}.cfg" "nochmodx" "norun" "noforcedl" "nomd5"
  347. source "${configdirserver}/${servicename}.cfg"
  348. else
  349. source "${configdirserver}/${servicename}.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_ts3
  382. echo""
  383. echo "Required status: ${requiredstatus}"
  384. counter=0
  385. echo "Current status: ${currentstatus}"
  386. while [ "${requiredstatus}" != "${currentstatus}" ]; do
  387. counter=$((counter+1))
  388. fn_currentstatus_ts3
  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 "Current status: ${currentstatus}"
  398. echo ""
  399. echo "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 "Test starting:"
  406. echo ""
  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 "================================="
  414. echo "Expected result: PASS"
  415. echo "Actual result: FAIL"
  416. fn_print_fail_nl "TEST FAILED"
  417. exitcode=1
  418. core_exit.sh
  419. else
  420. echo "================================="
  421. echo "Expected result: PASS"
  422. echo "Actual result: PASS"
  423. fn_print_ok_nl "TEST PASSED"
  424. echo ""
  425. fi
  426. }
  427. # if expecting a fail
  428. fn_test_result_fail(){
  429. if [ $? == 0 ]; then
  430. echo "================================="
  431. echo "Expected result: FAIL"
  432. echo "Actual result: PASS"
  433. fn_print_fail_nl "TEST FAILED"
  434. exitcode=1
  435. core_exit.sh
  436. else
  437. echo "================================="
  438. echo "Expected result: FAIL"
  439. echo "Actual result: FAIL"
  440. fn_print_ok_nl "TEST PASSED"
  441. echo ""
  442. fi
  443. }
  444. # test result n/a
  445. fn_test_result_na(){
  446. echo "================================="
  447. echo "Expected result: N/A"
  448. echo "Actual result: N/A"
  449. fn_print_fail_nl "TEST N/A"
  450. }
  451. echo "================================="
  452. echo "Travis CI Tests"
  453. echo "Linux Game Server Manager"
  454. echo "by Daniel Gibbs"
  455. echo "Contributors: http://goo.gl/qLmitD"
  456. echo "https://linuxgsm.com"
  457. echo "================================="
  458. echo ""
  459. echo "================================="
  460. echo "Server Tests"
  461. echo "Using: ${gamename}"
  462. echo "Testing Branch: $TRAVIS_BRANCH"
  463. echo "================================="
  464. echo ""
  465. echo "0.0 - Pre-test Tasks"
  466. echo "=================================================================="
  467. echo "Description:"
  468. echo "Create log dir's"
  469. echo ""
  470. echo ""
  471. echo "0.1 - Create log dir's"
  472. echo "================================="
  473. echo ""
  474. (
  475. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  476. BASH_XTRACEFD="5"
  477. set -x
  478. install_logs.sh
  479. )
  480. echo "run order"
  481. echo "================="
  482. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  483. echo ""
  484. echo "0.2 - Enable dev-debug"
  485. echo "================================="
  486. echo "Description:"
  487. echo "Enable dev-debug"
  488. echo ""
  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 "run order"
  497. echo "================="
  498. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  499. echo ""
  500. echo "1.0 - Pre-install tests"
  501. echo "=================================================================="
  502. echo ""
  503. echo "1.1 - start - no files"
  504. echo "================================="
  505. echo "Description:"
  506. echo "test script reaction to missing server files."
  507. echo "Command: ./${gameservername} start"
  508. echo ""
  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 "Test bypassed"
  520. fi
  521. echo "run order"
  522. echo "================="
  523. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  524. echo ""
  525. echo "1.2 - getopt"
  526. echo "================================="
  527. echo "Description:"
  528. echo "displaying options messages."
  529. echo "Command: ./${gameservername}"
  530. echo ""
  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 "run order"
  539. echo "================="
  540. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  541. echo ""
  542. echo "1.3 - getopt with incorrect args"
  543. echo "================================="
  544. echo "Description:"
  545. echo "displaying options messages."
  546. echo "Command: ./${gameservername} abc123"
  547. echo ""
  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 "run order"
  557. echo "================="
  558. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  559. echo ""
  560. echo "2.0 - Installation"
  561. echo "=================================================================="
  562. echo ""
  563. echo "2.0 - install"
  564. echo "================================="
  565. echo "Description:"
  566. echo "install ${gamename} server."
  567. echo "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 "run order"
  576. echo "================="
  577. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  578. echo ""
  579. echo "3.0 - Start/Stop/Restart Tests"
  580. echo "=================================================================="
  581. echo ""
  582. echo "3.1 - start"
  583. echo "================================="
  584. echo "Description:"
  585. echo "start ${gamename} server."
  586. echo "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 "run order"
  597. echo "================="
  598. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  599. echo ""
  600. echo "3.2 - start - online"
  601. echo "================================="
  602. echo "Description:"
  603. echo "start ${gamename} server while already running."
  604. echo "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 "run order"
  615. echo "================="
  616. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  617. echo ""
  618. echo "3.3 - start - updateonstart"
  619. echo "================================="
  620. echo "Description:"
  621. echo "will update server on start."
  622. echo "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 "run order"
  633. echo "================="
  634. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  635. echo ""
  636. echo "3.4 - stop"
  637. echo "================================="
  638. echo "Description:"
  639. echo "stop ${gamename} server."
  640. echo "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 "run order"
  651. echo "================="
  652. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  653. echo ""
  654. echo "3.5 - stop - offline"
  655. echo "================================="
  656. echo "Description:"
  657. echo "stop ${gamename} server while already stopped."
  658. echo "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 "run order"
  669. echo "================="
  670. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  671. echo ""
  672. echo "3.6 - restart"
  673. echo "================================="
  674. echo "Description:"
  675. echo "restart ${gamename}."
  676. echo "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 "run order"
  687. echo "================="
  688. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  689. echo ""
  690. echo "3.7 - restart - offline"
  691. echo "================================="
  692. echo "Description:"
  693. echo "restart ${gamename} while already stopped."
  694. echo "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 "run order"
  705. echo "================="
  706. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  707. echo ""
  708. echo "4.0 - Update Tests"
  709. echo "=================================================================="
  710. echo ""
  711. echo "4.1 - update"
  712. echo "================================="
  713. echo "Description:"
  714. echo "check for updates."
  715. echo "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 "run order"
  726. echo "================="
  727. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  728. echo ""
  729. echo "5.0 - Monitor Tests"
  730. echo "=================================================================="
  731. echo ""
  732. echo "Server IP - Port: ${ip}:${port}"
  733. echo "Server IP - Query Port: ${ip}:${queryport}"
  734. echo ""
  735. echo "5.1 - monitor - online"
  736. echo "================================="
  737. echo "Description:"
  738. echo "run monitor server while already running."
  739. echo "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 "run order"
  750. echo "================="
  751. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  752. echo ""
  753. echo "5.2 - monitor - offline - with lockfile"
  754. echo "================================="
  755. echo "Description:"
  756. echo "run monitor while server is offline with lockfile."
  757. echo "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 "run order"
  770. echo "================="
  771. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  772. echo ""
  773. echo "5.3 - monitor - offline - no lockfile"
  774. echo "================================="
  775. echo "Description:"
  776. echo "run monitor while server is offline with no lockfile."
  777. echo "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 "run order"
  788. echo "================="
  789. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  790. echo ""
  791. echo "5.4 - test-alert"
  792. echo "================================="
  793. echo "Description:"
  794. echo "run monitor while server is offline with no lockfile."
  795. echo "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 "run order"
  806. echo "================="
  807. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  808. echo ""
  809. echo "6.0 - Details Tests"
  810. echo "=================================================================="
  811. echo ""
  812. echo "6.1 - details"
  813. echo "================================="
  814. echo "Description:"
  815. echo "display details."
  816. echo "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 "run order"
  827. echo "================="
  828. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  829. echo ""
  830. echo "6.2 - postdetails"
  831. echo "================================="
  832. echo "Description:"
  833. echo "post details."
  834. echo "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 "run order"
  845. echo "================="
  846. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  847. echo ""
  848. echo "7.0 - Backup Tests"
  849. echo "=================================================================="
  850. echo ""
  851. echo "7.1 - backup"
  852. echo "================================="
  853. echo "Description:"
  854. echo "run a backup."
  855. echo "Command: ./${gameservername} backup"
  856. requiredstatus="ONLINE"
  857. fn_setstatus
  858. echo "test de-activated until issue #1839 fixed"
  859. #(command_backup.sh)
  860. fn_test_result_pass
  861. echo "run order"
  862. echo "================="
  863. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  864. echo ""
  865. echo "8.0 - Development Tools Tests"
  866. echo "=================================================================="
  867. echo ""
  868. echo "8.1 - dev - detect glibc"
  869. echo "================================="
  870. echo "Description:"
  871. echo "detect glibc."
  872. echo "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 "run order"
  883. echo "================="
  884. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  885. echo ""
  886. echo "8.2 - dev - detect ldd"
  887. echo "================================="
  888. echo "Description:"
  889. echo "detect ldd."
  890. echo "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 "run order"
  901. echo "================="
  902. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  903. echo ""
  904. echo "8.3 - dev - detect deps"
  905. echo "================================="
  906. echo "Description:"
  907. echo "detect dependencies."
  908. echo "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 "run order"
  919. echo "================="
  920. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  921. echo ""
  922. echo "8.4 - dev - query-raw"
  923. echo "================================="
  924. echo "Description:"
  925. echo "raw query output."
  926. echo "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 "run order"
  937. echo "================="
  938. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  939. echo ""
  940. echo "================================="
  941. echo "Server Tests - Complete!"
  942. echo "Using: ${gamename}"
  943. echo "================================="
  944. requiredstatus="OFFLINE"
  945. fn_setstatus
  946. fn_print_info "Tidying up directories."
  947. rm -rfv "${serverfiles}"
  948. core_exit.sh