tests_fctrserver.sh 27 KB

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