tests_fctrserver.sh 26 KB

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