tests_fctrserver.sh 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  1. #!/bin/bash
  2. # Project: Game Server Managers - LinuxGSM
  3. # Author: Daniel Gibbs
  4. # License: MIT License, Copyright (c) 2017 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://github.com/GameServerManagers/LinuxGSM/wiki
  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="${selfname}"
  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. sleep 0.5
  385. }
  386. # End of every test will expect the result to either pass or fail
  387. # If the script does not do as intended the whole test will fail
  388. # if expecting a pass
  389. fn_test_result_pass(){
  390. if [ $? != 0 ]; then
  391. echo "================================="
  392. echo "Expected result: PASS"
  393. echo "Actual result: FAIL"
  394. fn_print_fail_nl "TEST FAILED"
  395. exitcode=1
  396. core_exit.sh
  397. else
  398. echo "================================="
  399. echo "Expected result: PASS"
  400. echo "Actual result: PASS"
  401. fn_print_ok_nl "TEST PASSED"
  402. echo ""
  403. fi
  404. }
  405. # if expecting a fail
  406. fn_test_result_fail(){
  407. if [ $? == 0 ]; then
  408. echo "================================="
  409. echo "Expected result: FAIL"
  410. echo "Actual result: PASS"
  411. fn_print_fail_nl "TEST FAILED"
  412. exitcode=1
  413. core_exit.sh
  414. else
  415. echo "================================="
  416. echo "Expected result: FAIL"
  417. echo "Actual result: FAIL"
  418. fn_print_ok_nl "TEST PASSED"
  419. echo ""
  420. fi
  421. }
  422. echo "================================="
  423. echo "Travis CI Tests"
  424. echo "Linux Game Server Manager"
  425. echo "by Daniel Gibbs"
  426. echo "Contributors: http://goo.gl/qLmitD"
  427. echo "https://linuxgsm.com"
  428. echo "================================="
  429. echo ""
  430. echo "================================="
  431. echo "Server Tests"
  432. echo "Using: ${gamename}"
  433. echo "Testing Branch: $TRAVIS_BRANCH"
  434. echo "================================="
  435. echo ""
  436. echo "0.1 - Create log dir's"
  437. echo "================================="
  438. echo "Description:"
  439. echo "Create log dir's"
  440. echo ""
  441. (
  442. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  443. BASH_XTRACEFD="5"
  444. set -x
  445. install_logs.sh
  446. )
  447. echo "run order"
  448. echo "================="
  449. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  450. echo ""
  451. echo "0.2 - Enable dev-debug"
  452. echo "================================="
  453. echo "Description:"
  454. echo "Enable dev-debug"
  455. echo ""
  456. (
  457. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  458. BASH_XTRACEFD="5"
  459. set -x
  460. command_dev_debug.sh
  461. )
  462. fn_test_result_pass
  463. echo "run order"
  464. echo "================="
  465. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  466. echo ""
  467. echo "1.0 - start - no files"
  468. echo "================================="
  469. echo "Description:"
  470. echo "test script reaction to missing server files."
  471. echo "Command: ./fctrserver start"
  472. echo ""
  473. # Allows for testing not on Travis CI
  474. if [ ! -v TRAVIS ]; then
  475. (
  476. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  477. BASH_XTRACEFD="5"
  478. set -x
  479. command_start.sh
  480. )
  481. fn_test_result_fail
  482. else
  483. echo "Test bypassed"
  484. fi
  485. echo "run order"
  486. echo "================="
  487. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  488. echo ""
  489. echo "1.1 - getopt"
  490. echo "================================="
  491. echo "Description:"
  492. echo "displaying options messages."
  493. echo "Command: ./fctrserver"
  494. echo ""
  495. (
  496. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  497. BASH_XTRACEFD="5"
  498. set -x
  499. core_getopt.sh
  500. )
  501. fn_test_result_pass
  502. echo "run order"
  503. echo "================="
  504. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  505. echo ""
  506. echo "1.2 - getopt with incorrect args"
  507. echo "================================="
  508. echo "Description:"
  509. echo "displaying options messages."
  510. echo "Command: ./fctrserver abc123"
  511. echo ""
  512. getopt="abc123"
  513. (
  514. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  515. BASH_XTRACEFD="5"
  516. set -x
  517. core_getopt.sh
  518. )
  519. fn_test_result_fail
  520. echo "run order"
  521. echo "================="
  522. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  523. echo ""
  524. echo "2.0 - install"
  525. echo "================================="
  526. echo "Description:"
  527. echo "install ${gamename} server."
  528. echo "Command: ./fctrserver auto-install"
  529. (
  530. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  531. BASH_XTRACEFD="5"
  532. set -x
  533. fn_autoinstall
  534. )
  535. fn_test_result_pass
  536. echo "run order"
  537. echo "================="
  538. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  539. echo ""
  540. echo "3.1 - start"
  541. echo "================================="
  542. echo "Description:"
  543. echo "start ${gamename} server."
  544. echo "Command: ./fctrserver start"
  545. requiredstatus="OFFLINE"
  546. fn_setstatus
  547. (
  548. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  549. BASH_XTRACEFD="5"
  550. set -x
  551. command_start.sh
  552. )
  553. fn_test_result_pass
  554. echo "run order"
  555. echo "================="
  556. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  557. echo ""
  558. echo "3.2 - start - online"
  559. echo "================================="
  560. echo "Description:"
  561. echo "start ${gamename} server while already running."
  562. echo "Command: ./fctrserver start"
  563. requiredstatus="ONLINE"
  564. fn_setstatus
  565. (
  566. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  567. BASH_XTRACEFD="5"
  568. set -x
  569. command_start.sh
  570. )
  571. fn_test_result_fail
  572. echo "run order"
  573. echo "================="
  574. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  575. echo ""
  576. echo "3.3 - start - updateonstart"
  577. echo "================================="
  578. echo "Description:"
  579. echo "will update server on start."
  580. echo "Command: ./fctrserver start"
  581. requiredstatus="OFFLINE"
  582. fn_setstatus
  583. (
  584. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  585. BASH_XTRACEFD="5"
  586. set -x
  587. updateonstart="on";command_start.sh
  588. )
  589. fn_test_result_pass
  590. echo "run order"
  591. echo "================="
  592. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  593. echo ""
  594. echo "3.4 - stop"
  595. echo "================================="
  596. echo "Description:"
  597. echo "stop ${gamename} server."
  598. echo "Command: ./fctrserver stop"
  599. requiredstatus="ONLINE"
  600. fn_setstatus
  601. (
  602. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  603. BASH_XTRACEFD="5"
  604. set -x
  605. command_stop.sh
  606. )
  607. fn_test_result_pass
  608. echo "run order"
  609. echo "================="
  610. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  611. echo ""
  612. echo "3.5 - stop - offline"
  613. echo "================================="
  614. echo "Description:"
  615. echo "stop ${gamename} server while already stopped."
  616. echo "Command: ./fctrserver stop"
  617. requiredstatus="OFFLINE"
  618. fn_setstatus
  619. (
  620. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  621. BASH_XTRACEFD="5"
  622. set -x
  623. command_stop.sh
  624. )
  625. fn_test_result_fail
  626. echo "run order"
  627. echo "================="
  628. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  629. echo ""
  630. echo "3.6 - restart"
  631. echo "================================="
  632. echo "Description:"
  633. echo "restart ${gamename}."
  634. echo "Command: ./fctrserver restart"
  635. requiredstatus="ONLINE"
  636. fn_setstatus
  637. (
  638. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  639. BASH_XTRACEFD="5"
  640. set -x
  641. command_restart.sh
  642. )
  643. fn_test_result_pass
  644. echo "run order"
  645. echo "================="
  646. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  647. echo ""
  648. echo "3.7 - restart - offline"
  649. echo "================================="
  650. echo "Description:"
  651. echo "restart ${gamename} while already stopped."
  652. echo "Command: ./fctrserver restart"
  653. requiredstatus="OFFLINE"
  654. fn_setstatus
  655. (
  656. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  657. BASH_XTRACEFD="5"
  658. set -x
  659. command_restart.sh
  660. )
  661. fn_test_result_pass
  662. echo "run order"
  663. echo "================="
  664. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  665. echo ""
  666. echo "4.1 - update"
  667. echo "================================="
  668. echo "Description:"
  669. echo "check for updates."
  670. echo "Command: ./fctrserver update"
  671. requiredstatus="OFFLINE"
  672. fn_setstatus
  673. (
  674. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  675. BASH_XTRACEFD="5"
  676. set -x
  677. command_update.sh
  678. )
  679. fn_test_result_pass
  680. echo "run order"
  681. echo "================="
  682. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  683. echo ""
  684. echo "5.1 - monitor - online"
  685. echo "================================="
  686. echo "Description:"
  687. echo "run monitor server while already running."
  688. echo "Command: ./fctrserver monitor"
  689. requiredstatus="ONLINE"
  690. fn_setstatus
  691. (
  692. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  693. BASH_XTRACEFD="5"
  694. set -x
  695. command_monitor.sh
  696. )
  697. fn_test_result_pass
  698. echo "run order"
  699. echo "================="
  700. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  701. echo ""
  702. echo "5.2 - monitor - offline - with lockfile"
  703. echo "================================="
  704. echo "Description:"
  705. echo "run monitor while server is offline with lockfile."
  706. echo "Command: ./fctrserver monitor"
  707. requiredstatus="OFFLINE"
  708. fn_setstatus
  709. fn_print_info_nl "creating lockfile."
  710. date > "${rootdir}/${lockselfname}"
  711. (
  712. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  713. BASH_XTRACEFD="5"
  714. set -x
  715. command_monitor.sh
  716. )
  717. fn_test_result_pass
  718. echo "run order"
  719. echo "================="
  720. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  721. echo ""
  722. echo "5.3 - monitor - offline - no lockfile"
  723. echo "================================="
  724. echo "Description:"
  725. echo "run monitor while server is offline with no lockfile."
  726. echo "Command: ./fctrserver monitor"
  727. requiredstatus="OFFLINE"
  728. fn_setstatus
  729. (
  730. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  731. BASH_XTRACEFD="5"
  732. set -x
  733. command_monitor.sh
  734. )
  735. fn_test_result_fail
  736. echo "run order"
  737. echo "================="
  738. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  739. echo ""
  740. echo "6.0 - details"
  741. echo "================================="
  742. echo "Description:"
  743. echo "display details."
  744. echo "Command: ./fctrserver details"
  745. requiredstatus="ONLINE"
  746. fn_setstatus
  747. (
  748. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  749. BASH_XTRACEFD="5"
  750. set -x
  751. command_details.sh
  752. )
  753. fn_test_result_pass
  754. echo "run order"
  755. echo "================="
  756. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  757. echo ""
  758. echo "6.1 - post details"
  759. echo "================================="
  760. echo "Description:"
  761. echo "post details."
  762. echo "Command: ./fctrserver postdetails"
  763. requiredstatus="ONLINE"
  764. fn_setstatus
  765. (
  766. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  767. BASH_XTRACEFD="5"
  768. set -x
  769. command_postdetails.sh
  770. )
  771. fn_test_result_pass
  772. echo "run order"
  773. echo "================="
  774. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  775. echo ""
  776. echo "7.0 - backup"
  777. echo "================================="
  778. echo "Description:"
  779. echo "run a backup."
  780. echo "Command: ./fctrserver backup"
  781. requiredstatus="ONLINE"
  782. fn_setstatus
  783. echo "test de-activated until issue #1839 fixed"
  784. #(command_backup.sh)
  785. fn_test_result_pass
  786. echo "run order"
  787. echo "================="
  788. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  789. echo ""
  790. echo "8.0 - dev - detect glibc"
  791. echo "================================="
  792. echo "Description:"
  793. echo "detect glibc."
  794. echo "Command: ./fctrserver detect-glibc"
  795. requiredstatus="ONLINE"
  796. fn_setstatus
  797. (
  798. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  799. BASH_XTRACEFD="5"
  800. set -x
  801. command_dev_detect_glibc.sh
  802. )
  803. fn_test_result_pass
  804. echo "run order"
  805. echo "================="
  806. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  807. echo ""
  808. echo "8.1 - dev - detect ldd"
  809. echo "================================="
  810. echo "Description:"
  811. echo "detect ldd."
  812. echo "Command: ./fctrserver detect-ldd"
  813. requiredstatus="ONLINE"
  814. fn_setstatus
  815. (
  816. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  817. BASH_XTRACEFD="5"
  818. set -x
  819. command_dev_detect_ldd.sh
  820. )
  821. fn_test_result_pass
  822. echo "run order"
  823. echo "================="
  824. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  825. echo ""
  826. echo "8.2 - dev - detect deps"
  827. echo "================================="
  828. echo "Description:"
  829. echo "detect dependencies."
  830. echo "Command: ./fctrserver detect-deps"
  831. requiredstatus="ONLINE"
  832. fn_setstatus
  833. (
  834. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  835. BASH_XTRACEFD="5"
  836. set -x
  837. command_dev_detect_deps.sh
  838. )
  839. fn_test_result_pass
  840. echo "run order"
  841. echo "================="
  842. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  843. echo ""
  844. echo "================================="
  845. echo "Server Tests - Complete!"
  846. echo "Using: ${gamename}"
  847. echo "================================="
  848. requiredstatus="OFFLINE"
  849. fn_setstatus
  850. fn_print_info "Tidying up directories."
  851. rm -rfv "${serverfiles}"
  852. core_exit.sh