tests_fctrserver.sh 27 KB

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