tests_ts3server.sh 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106
  1. #!/bin/bash
  2. # Project: Game Server Managers - LinuxGSM
  3. # Author: Daniel Gibbs
  4. # License: MIT License, Copyright (c) 2020 Daniel Gibbs
  5. # Purpose: Travis CI Tests: Teamspeak 3 | Linux Game Server Management Script
  6. # Contributors: https://linuxgsm.com/contrib
  7. # Documentation: https://docs.linuxgsm.com
  8. # Website: https://linuxgsm.com
  9. # DO NOT EDIT THIS FILE
  10. # LinuxGSM configuration is no longer edited here
  11. # To update your LinuxGSM config go to:
  12. # lgsm/config-lgsm
  13. # https://docs.linuxgsm.com/configuration/linuxgsm-config
  14. # Debugging
  15. if [ -f ".dev-debug" ]; then
  16. exec 5>dev-debug.log
  17. BASH_XTRACEFD="5"
  18. set -x
  19. fi
  20. version="v20.2.0"
  21. shortname="ts3"
  22. gameservername="ts3server"
  23. rootdir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
  24. selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
  25. lgsmdir="${rootdir}/lgsm"
  26. logdir="${rootdir}/log"
  27. lgsmlogdir="${logdir}/lgsm"
  28. steamcmddir="${HOME}/.steam/steamcmd"
  29. serverfiles="${rootdir}/serverfiles"
  30. functionsdir="${lgsmdir}/functions"
  31. tmpdir="${lgsmdir}/tmp"
  32. datadir="${lgsmdir}/data"
  33. lockdir="${lgsmdir}/lock"
  34. serverlist="${datadir}/serverlist.csv"
  35. serverlistmenu="${datadir}/serverlistmenu.csv"
  36. configdir="${lgsmdir}/config-lgsm"
  37. configdirserver="${configdir}/${gameservername}"
  38. configdirdefault="${lgsmdir}/config-default"
  39. userinput="${1}"
  40. # Allows for testing not on Travis CI.
  41. # if using travis for tests
  42. if [ -n "${TRAVIS}" ]; then
  43. selfname="travis"
  44. # if not using travis for tests
  45. else
  46. TRAVIS_BRANCH="develop"
  47. TRAVIS_BUILD_DIR="${rootdir}"
  48. fi
  49. travistest="1"
  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[0]}"
  59. fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5"
  60. }
  61. # Bootstrap
  62. # Fetches the core functions required before passed off to core_dl.sh.
  63. fn_bootstrap_fetch_file(){
  64. remote_fileurl="${1}"
  65. local_filedir="${2}"
  66. local_filename="${3}"
  67. chmodx="${4:-0}"
  68. run="${5:-0}"
  69. forcedl="${6:-0}"
  70. md5="${7:-0}"
  71. # Download file if missing or download forced.
  72. if [ ! -f "${local_filedir}/${local_filename}" ]||[ "${forcedl}" == "forcedl" ]; then
  73. if [ ! -d "${local_filedir}" ]; then
  74. mkdir -p "${local_filedir}"
  75. fi
  76. # If curl exists download file.
  77. if [ "$(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 [ "${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 [ "$(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. # LinuxGSM installer mode.
  261. if [ "${shortname}" == "core" ]; then
  262. # Download the latest serverlist. This is the complete list of all supported servers.
  263. fn_bootstrap_fetch_file_github "lgsm/data" "serverlist.csv" "${datadir}" "nochmodx" "norun" "forcedl" "nomd5"
  264. if [ ! -f "${serverlist}" ]; then
  265. echo -e "[ FAIL ] serverlist.csv could not be loaded."
  266. exit 1
  267. fi
  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 [ "${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. # shellcheck source=/dev/null
  335. source "${configdirserver}/_default.cfg"
  336. # Load the common.cfg config. If missing download it.
  337. if [ ! -f "${configdirserver}/common.cfg" ]; then
  338. fn_fetch_config "lgsm/config-default/config-lgsm" "common-template.cfg" "${configdirserver}" "common.cfg" "${chmodx}" "nochmodx" "norun" "noforcedl" "nomd5"
  339. # shellcheck source=/dev/null
  340. source "${configdirserver}/common.cfg"
  341. else
  342. # shellcheck source=/dev/null
  343. source "${configdirserver}/common.cfg"
  344. fi
  345. # Load the instance.cfg config. If missing download it.
  346. if [ ! -f "${configdirserver}/${selfname}.cfg" ]; then
  347. fn_fetch_config "lgsm/config-default/config-lgsm" "instance-template.cfg" "${configdirserver}" "${selfname}.cfg" "nochmodx" "norun" "noforcedl" "nomd5"
  348. # shellcheck source=/dev/null
  349. source "${configdirserver}/${selfname}.cfg"
  350. else
  351. # shellcheck source=/dev/null
  352. source "${configdirserver}/${selfname}.cfg"
  353. fi
  354. # Load the linuxgsm.sh in to tmpdir. If missing download it.
  355. if [ ! -f "${tmpdir}/linuxgsm.sh" ]; then
  356. fn_fetch_file_github "" "linuxgsm.sh" "${tmpdir}" "chmodx" "norun" "noforcedl" "nomd5"
  357. fi
  358. fi
  359. # Enables ANSI colours from core_messages.sh. Can be disabled with ansi=off.
  360. fn_ansi_loader
  361. # Prevents running of core_exit.sh for Travis-CI.
  362. if [ "${travistest}" != "1" ]; then
  363. getopt=$1
  364. core_getopt.sh
  365. fi
  366. fi
  367. fn_currentstatus_tmux(){
  368. check_status.sh
  369. if [ "${status}" != "0" ]; then
  370. currentstatus="ONLINE"
  371. else
  372. currentstatus="OFFLINE"
  373. fi
  374. }
  375. fn_setstatus(){
  376. fn_currentstatus_tmux
  377. echo""
  378. echo -e "Required status: ${requiredstatus}"
  379. counter=0
  380. echo -e "Current status: ${currentstatus}"
  381. while [ "${requiredstatus}" != "${currentstatus}" ]; do
  382. counter=$((counter+1))
  383. fn_currentstatus_tmux
  384. echo -en "New status: ${currentstatus}\\r"
  385. if [ "${requiredstatus}" == "ONLINE" ]; then
  386. (command_start.sh > /dev/null 2>&1)
  387. else
  388. (command_stop.sh > /dev/null 2>&1)
  389. fi
  390. if [ "${counter}" -gt "5" ]; then
  391. currentstatus="FAIL"
  392. echo -e "Current status: ${currentstatus}"
  393. echo -e ""
  394. echo -e "Unable to start or stop server."
  395. exit 1
  396. fi
  397. done
  398. echo -en "New status: ${currentstatus}\\r"
  399. echo -e "\n"
  400. echo -e "Test starting:"
  401. echo -e ""
  402. }
  403. # End of every test will expect the result to either pass or fail
  404. # If the script does not do as intended the whole test will fail
  405. # if expecting a pass
  406. fn_test_result_pass(){
  407. if [ $? != 0 ]; then
  408. echo -e "================================="
  409. echo -e "Expected result: PASS"
  410. echo -e "Actual result: FAIL"
  411. fn_print_fail_nl "TEST FAILED"
  412. exitcode=1
  413. core_exit.sh
  414. else
  415. echo -e "================================="
  416. echo -e "Expected result: PASS"
  417. echo -e "Actual result: PASS"
  418. fn_print_ok_nl "TEST PASSED"
  419. echo -e ""
  420. fi
  421. }
  422. # if expecting a fail
  423. fn_test_result_fail(){
  424. if [ $? == 0 ]; then
  425. echo -e "================================="
  426. echo -e "Expected result: FAIL"
  427. echo -e "Actual result: PASS"
  428. fn_print_fail_nl "TEST FAILED"
  429. exitcode=1
  430. core_exit.sh
  431. else
  432. echo -e "================================="
  433. echo -e "Expected result: FAIL"
  434. echo -e "Actual result: FAIL"
  435. fn_print_ok_nl "TEST PASSED"
  436. echo -e ""
  437. fi
  438. }
  439. # test result n/a
  440. fn_test_result_na(){
  441. echo -e "================================="
  442. echo -e "Expected result: N/A"
  443. echo -e "Actual result: N/A"
  444. fn_print_fail_nl "TEST N/A"
  445. }
  446. sleeptime="0"
  447. echo -e "================================="
  448. echo -e "Travis CI Tests"
  449. echo -e "Linux Game Server Manager"
  450. echo -e "by Daniel Gibbs"
  451. echo -e "Contributors: http://goo.gl/qLmitD"
  452. echo -e "https://linuxgsm.com"
  453. echo -e "================================="
  454. echo -e ""
  455. echo -e "================================="
  456. echo -e "Server Tests"
  457. echo -e "Using: ${gamename}"
  458. echo -e "Testing Branch: ${TRAVIS_BRANCH}"
  459. echo -e "================================="
  460. echo -e ""
  461. echo -e "Tests Summary"
  462. echo -e "================================="
  463. echo -e "0.0 - Pre-test Tasks"
  464. echo -e "0.1 - Create log dir's"
  465. echo -e "0.2 - Enable dev-debug"
  466. echo -e ""
  467. echo -e "1.0 - Pre-install tests"
  468. echo -e "1.1 - start - no files"
  469. echo -e "1.2 - getopt"
  470. echo -e "1.3 - getopt with incorrect args"
  471. echo -e ""
  472. echo -e "2.0 - Installation"
  473. echo -e "2.1 - install"
  474. echo -e ""
  475. echo -e "3.0 - Start/Stop/Restart Tests"
  476. echo -e "3.1 - start"
  477. echo -e "3.2 - start - online"
  478. echo -e "3.3 - start - updateonstart"
  479. echo -e "3.4 - stop"
  480. echo -e "3.5 - stop - offline"
  481. echo -e "3.6 - restart"
  482. echo -e "3.7 - restart - offline"
  483. echo -e ""
  484. echo -e "4.0 - Update Tests"
  485. echo -e "4.1 - update"
  486. echo -e "4.2 - update-lgsm"
  487. echo -e ""
  488. echo -e "5.0 - Monitor Tests"
  489. echo -e "5.1 - monitor - online"
  490. echo -e "5.2 - monitor - offline - with lockfile"
  491. echo -e "5.3 - monitor - offline - no lockfile"
  492. echo -e "5.4 - test-alert"
  493. echo -e ""
  494. echo -e "6.0 - Details Tests"
  495. echo -e "6.1 - details"
  496. echo -e "6.2 - postdetails"
  497. echo -e ""
  498. echo -e "7.0 - Backup Tests"
  499. echo -e "7.1 - backup"
  500. echo -e ""
  501. echo -e "8.0 - Development Tools Tests"
  502. echo -e "8.1 - dev - detect glibc"
  503. echo -e "8.2 - dev - detect ldd"
  504. echo -e "8.3 - dev - detect deps"
  505. echo -e "8.4 - dev - query-raw"
  506. echo -e ""
  507. echo -e "9.0 - Donate"
  508. echo -e "9.1 - donate"
  509. echo -e ""
  510. echo -e "0.0 - Pre-test Tasks"
  511. echo -e "=================================================================="
  512. echo -e "Description:"
  513. echo -e "Create log dir's"
  514. echo -e ""
  515. echo -e ""
  516. echo -e "0.1 - Create log dir's"
  517. echo -e "================================="
  518. echo -e ""
  519. (
  520. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  521. BASH_XTRACEFD="5"
  522. set -x
  523. install_logs.sh
  524. )
  525. echo -e "run order"
  526. echo -e "================="
  527. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  528. echo -e ""
  529. echo -e "0.2 - Enable dev-debug"
  530. echo -e "================================="
  531. echo -e "Description:"
  532. echo -e "Enable dev-debug"
  533. echo -e ""
  534. (
  535. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  536. BASH_XTRACEFD="5"
  537. set -x
  538. command_dev_debug.sh
  539. )
  540. fn_test_result_pass
  541. echo -e "run order"
  542. echo -e "================="
  543. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  544. echo -e ""
  545. echo -e "1.0 - Pre-install tests"
  546. echo -e "=================================================================="
  547. echo -e ""
  548. echo -e "1.1 - start - no files"
  549. echo -e "================================="
  550. echo -e "Description:"
  551. echo -e "test script reaction to missing server files."
  552. echo -e "Command: ./${gameservername} start"
  553. echo -e ""
  554. # Allows for testing not on Travis CI
  555. if [ -z "${TRAVIS}" ]; then
  556. (
  557. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  558. BASH_XTRACEFD="5"
  559. set -x
  560. command_start.sh
  561. )
  562. fn_test_result_fail
  563. else
  564. echo -e "Test bypassed"
  565. fi
  566. echo -e "run order"
  567. echo -e "================="
  568. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  569. echo -e ""
  570. echo -e "1.2 - getopt"
  571. echo -e "================================="
  572. echo -e "Description:"
  573. echo -e "displaying options messages."
  574. echo -e "Command: ./${gameservername}"
  575. echo -e ""
  576. (
  577. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  578. BASH_XTRACEFD="5"
  579. set -x
  580. core_getopt.sh
  581. )
  582. fn_test_result_pass
  583. echo -e "run order"
  584. echo -e "================="
  585. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  586. echo -e ""
  587. echo -e "1.3 - getopt with incorrect args"
  588. echo -e "================================="
  589. echo -e "Description:"
  590. echo -e "displaying options messages."
  591. echo -e "Command: ./${gameservername} abc123"
  592. echo -e ""
  593. getopt="abc123"
  594. (
  595. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  596. BASH_XTRACEFD="5"
  597. set -x
  598. core_getopt.sh
  599. )
  600. fn_test_result_pass
  601. echo -e "run order"
  602. echo -e "================="
  603. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  604. echo -e ""
  605. echo -e "2.0 - Installation"
  606. echo -e "=================================================================="
  607. echo -e ""
  608. echo -e "2.1 - install"
  609. echo -e "================================="
  610. echo -e "Description:"
  611. echo -e "install ${gamename} server."
  612. echo -e "Command: ./${gameservername} auto-install"
  613. (
  614. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  615. BASH_XTRACEFD="5"
  616. set -x
  617. fn_autoinstall
  618. )
  619. fn_test_result_pass
  620. echo -e "run order"
  621. echo -e "================="
  622. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  623. echo -e ""
  624. echo -e "3.0 - Start/Stop/Restart Tests"
  625. echo -e "=================================================================="
  626. echo -e ""
  627. echo -e "3.1 - start"
  628. echo -e "================================="
  629. echo -e "Description:"
  630. echo -e "start ${gamename} server."
  631. echo -e "Command: ./${gameservername} start"
  632. requiredstatus="OFFLINE"
  633. fn_setstatus
  634. (
  635. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  636. BASH_XTRACEFD="5"
  637. set -x
  638. command_start.sh
  639. )
  640. fn_test_result_pass
  641. echo -e "run order"
  642. echo -e "================="
  643. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  644. echo -e ""
  645. echo -e "3.2 - start - online"
  646. echo -e "================================="
  647. echo -e "Description:"
  648. echo -e "start ${gamename} server while already running."
  649. echo -e "Command: ./${gameservername} start"
  650. requiredstatus="ONLINE"
  651. fn_setstatus
  652. (
  653. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  654. BASH_XTRACEFD="5"
  655. set -x
  656. command_start.sh
  657. )
  658. fn_test_result_fail
  659. echo -e "run order"
  660. echo -e "================="
  661. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  662. echo -e ""
  663. echo -e "3.3 - start - updateonstart"
  664. echo -e "================================="
  665. echo -e "Description:"
  666. echo -e "will update server on start."
  667. echo -e "Command: ./${gameservername} start"
  668. requiredstatus="OFFLINE"
  669. fn_setstatus
  670. (
  671. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  672. BASH_XTRACEFD="5"
  673. set -x
  674. updateonstart="on";command_start.sh
  675. )
  676. fn_test_result_pass
  677. echo -e "run order"
  678. echo -e "================="
  679. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  680. echo -e ""
  681. echo -e "3.4 - stop"
  682. echo -e "================================="
  683. echo -e "Description:"
  684. echo -e "stop ${gamename} server."
  685. echo -e "Command: ./${gameservername} stop"
  686. requiredstatus="ONLINE"
  687. fn_setstatus
  688. (
  689. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  690. BASH_XTRACEFD="5"
  691. set -x
  692. command_stop.sh
  693. )
  694. fn_test_result_pass
  695. echo -e "run order"
  696. echo -e "================="
  697. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  698. echo -e ""
  699. echo -e "3.5 - stop - offline"
  700. echo -e "================================="
  701. echo -e "Description:"
  702. echo -e "stop ${gamename} server while already stopped."
  703. echo -e "Command: ./${gameservername} stop"
  704. requiredstatus="OFFLINE"
  705. fn_setstatus
  706. (
  707. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  708. BASH_XTRACEFD="5"
  709. set -x
  710. command_stop.sh
  711. )
  712. fn_test_result_fail
  713. echo -e "run order"
  714. echo -e "================="
  715. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  716. echo -e ""
  717. echo -e "3.6 - restart"
  718. echo -e "================================="
  719. echo -e "Description:"
  720. echo -e "restart ${gamename}."
  721. echo -e "Command: ./${gameservername} restart"
  722. requiredstatus="ONLINE"
  723. fn_setstatus
  724. (
  725. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  726. BASH_XTRACEFD="5"
  727. set -x
  728. command_restart.sh
  729. )
  730. fn_test_result_pass
  731. echo -e "run order"
  732. echo -e "================="
  733. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  734. echo -e ""
  735. echo -e "3.7 - restart - offline"
  736. echo -e "================================="
  737. echo -e "Description:"
  738. echo -e "restart ${gamename} while already stopped."
  739. echo -e "Command: ./${gameservername} restart"
  740. requiredstatus="OFFLINE"
  741. fn_setstatus
  742. (
  743. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  744. BASH_XTRACEFD="5"
  745. set -x
  746. command_restart.sh
  747. )
  748. fn_test_result_pass
  749. echo -e "run order"
  750. echo -e "================="
  751. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  752. echo -e ""
  753. echo -e "4.0 - Update Tests"
  754. echo -e "=================================================================="
  755. echo -e ""
  756. echo -e "4.1 - update"
  757. echo -e "================================="
  758. echo -e "Description:"
  759. echo -e "check for updates."
  760. echo -e "Command: ./${gameservername} update"
  761. requiredstatus="OFFLINE"
  762. fn_setstatus
  763. (
  764. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  765. BASH_XTRACEFD="5"
  766. set -x
  767. command_update.sh
  768. )
  769. fn_test_result_pass
  770. echo -e "run order"
  771. echo -e "================="
  772. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  773. echo -e ""
  774. echo -e "4.2 - update-lgsm"
  775. echo -e "================================="
  776. echo -e "Description:"
  777. echo -e "update LinuxGSM."
  778. echo -e ""
  779. echo -e "Command: ./jc2server update-lgam"
  780. requiredstatus="ONLINE"
  781. fn_setstatus
  782. (
  783. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  784. BASH_XTRACEFD="5"
  785. set -x
  786. command_update_linuxgsm.sh
  787. )
  788. fn_test_result_pass
  789. echo -e "run order"
  790. echo -e "================="
  791. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  792. echo -e ""
  793. echo -e "5.0 - Monitor Tests"
  794. echo -e "=================================================================="
  795. echo -e ""
  796. info_config.sh
  797. echo -e "Server IP - Port: ${ip}:${port}"
  798. echo -e "Server IP - Query Port: ${ip}:${queryport}"
  799. echo -e ""
  800. echo -e "5.1 - monitor - online"
  801. echo -e "================================="
  802. echo -e "Description:"
  803. echo -e "run monitor server while already running."
  804. echo -e "Command: ./${gameservername} monitor"
  805. requiredstatus="ONLINE"
  806. fn_setstatus
  807. (
  808. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  809. BASH_XTRACEFD="5"
  810. set -x
  811. command_monitor.sh
  812. )
  813. fn_test_result_pass
  814. echo -e "run order"
  815. echo -e "================="
  816. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  817. echo -e ""
  818. echo -e "5.2 - monitor - offline - with lockfile"
  819. echo -e "================================="
  820. echo -e "Description:"
  821. echo -e "run monitor while server is offline with lockfile."
  822. echo -e "Command: ./${gameservername} monitor"
  823. requiredstatus="OFFLINE"
  824. fn_setstatus
  825. fn_print_info_nl "creating lockfile."
  826. date '+%s' > "${lockdir}/${selfname}.lock"
  827. (
  828. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  829. BASH_XTRACEFD="5"
  830. set -x
  831. command_monitor.sh
  832. )
  833. fn_test_result_pass
  834. echo -e "run order"
  835. echo -e "================="
  836. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  837. echo -e ""
  838. echo -e "5.3 - monitor - offline - no lockfile"
  839. echo -e "================================="
  840. echo -e "Description:"
  841. echo -e "run monitor while server is offline with no lockfile."
  842. echo -e "Command: ./${gameservername} monitor"
  843. requiredstatus="OFFLINE"
  844. fn_setstatus
  845. (
  846. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  847. BASH_XTRACEFD="5"
  848. set -x
  849. command_monitor.sh
  850. )
  851. fn_test_result_fail
  852. echo -e "run order"
  853. echo -e "================="
  854. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  855. echo -e ""
  856. echo -e "5.4 - test-alert"
  857. echo -e "================================="
  858. echo -e "Description:"
  859. echo -e "run monitor while server is offline with no lockfile."
  860. echo -e "Command: ./${gameservername} test-alert"
  861. requiredstatus="OFFLINE"
  862. fn_setstatus
  863. (
  864. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  865. BASH_XTRACEFD="5"
  866. set -x
  867. command_test_alert.sh
  868. )
  869. fn_test_result_fail
  870. echo -e "run order"
  871. echo -e "================="
  872. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  873. echo -e ""
  874. echo -e "6.0 - Details Tests"
  875. echo -e "=================================================================="
  876. echo -e ""
  877. echo -e "6.1 - details"
  878. echo -e "================================="
  879. echo -e "Description:"
  880. echo -e "display details."
  881. echo -e "Command: ./${gameservername} details"
  882. requiredstatus="ONLINE"
  883. fn_setstatus
  884. (
  885. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  886. BASH_XTRACEFD="5"
  887. set -x
  888. command_details.sh
  889. )
  890. fn_test_result_pass
  891. echo -e "run order"
  892. echo -e "================="
  893. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  894. echo -e ""
  895. echo -e "6.2 - postdetails"
  896. echo -e "================================="
  897. echo -e "Description:"
  898. echo -e "post details."
  899. echo -e "Command: ./${gameservername} postdetails"
  900. requiredstatus="ONLINE"
  901. fn_setstatus
  902. (
  903. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  904. BASH_XTRACEFD="5"
  905. set -x
  906. command_postdetails.sh
  907. )
  908. fn_test_result_pass
  909. echo -e "run order"
  910. echo -e "================="
  911. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  912. echo -e ""
  913. echo -e "7.0 - Backup Tests"
  914. echo -e "=================================================================="
  915. echo -e ""
  916. echo -e "7.1 - backup"
  917. echo -e "================================="
  918. echo -e "Description:"
  919. echo -e "run a backup."
  920. echo -e "Command: ./${gameservername} backup"
  921. requiredstatus="ONLINE"
  922. fn_setstatus
  923. echo -e "test de-activated until issue #1839 fixed"
  924. #(command_backup.sh)
  925. fn_test_result_pass
  926. echo -e "run order"
  927. echo -e "================="
  928. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  929. echo -e ""
  930. echo -e "8.0 - Development Tools Tests"
  931. echo -e "=================================================================="
  932. echo -e ""
  933. echo -e "8.1 - dev - detect glibc"
  934. echo -e "================================="
  935. echo -e "Description:"
  936. echo -e "detect glibc."
  937. echo -e "Command: ./${gameservername} detect-glibc"
  938. requiredstatus="ONLINE"
  939. fn_setstatus
  940. (
  941. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  942. BASH_XTRACEFD="5"
  943. set -x
  944. command_dev_detect_glibc.sh
  945. )
  946. fn_test_result_pass
  947. echo -e "run order"
  948. echo -e "================="
  949. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  950. echo -e ""
  951. echo -e "8.2 - dev - detect ldd"
  952. echo -e "================================="
  953. echo -e "Description:"
  954. echo -e "detect ldd."
  955. echo -e "Command: ./${gameservername} detect-ldd"
  956. requiredstatus="ONLINE"
  957. fn_setstatus
  958. (
  959. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  960. BASH_XTRACEFD="5"
  961. set -x
  962. command_dev_detect_ldd.sh
  963. )
  964. fn_test_result_pass
  965. echo -e "run order"
  966. echo -e "================="
  967. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  968. echo -e ""
  969. echo -e "8.3 - dev - detect deps"
  970. echo -e "================================="
  971. echo -e "Description:"
  972. echo -e "detect dependencies."
  973. echo -e "Command: ./${gameservername} detect-deps"
  974. requiredstatus="ONLINE"
  975. fn_setstatus
  976. (
  977. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  978. BASH_XTRACEFD="5"
  979. set -x
  980. command_dev_detect_deps.sh
  981. )
  982. fn_test_result_pass
  983. echo -e "run order"
  984. echo -e "================="
  985. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  986. echo -e ""
  987. echo -e "8.4 - dev - query-raw"
  988. echo -e "================================="
  989. echo -e "Description:"
  990. echo -e "raw query output."
  991. echo -e "Command: ./${gameservername} query-raw"
  992. requiredstatus="ONLINE"
  993. fn_setstatus
  994. (
  995. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  996. BASH_XTRACEFD="5"
  997. set -x
  998. command_dev_query_raw.sh
  999. )
  1000. fn_test_result_na
  1001. echo -e "run order"
  1002. echo -e "================="
  1003. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1004. echo -e ""
  1005. echo -e "9.0 - Donate"
  1006. echo -e "=================================================================="
  1007. echo -e ""
  1008. echo -e "9.1 - donate"
  1009. echo -e "================================="
  1010. echo -e "Description:"
  1011. echo -e "donate."
  1012. echo -e "Command: ./${gameservername} donate"
  1013. requiredstatus="ONLINE"
  1014. fn_setstatus
  1015. (
  1016. exec 5>"${TRAVIS_BUILD_DIR}/dev-debug.log"
  1017. BASH_XTRACEFD="5"
  1018. set -x
  1019. command_donate.sh
  1020. )
  1021. fn_test_result_pass
  1022. echo -e "run order"
  1023. echo -e "================="
  1024. grep functionfile= "${TRAVIS_BUILD_DIR}/dev-debug.log" | sed 's/functionfile=//g'
  1025. echo -e ""
  1026. echo -e "================================="
  1027. echo -e "Server Tests - Complete!"
  1028. echo -e "Using: ${gamename}"
  1029. echo -e "================================="
  1030. requiredstatus="OFFLINE"
  1031. fn_setstatus
  1032. core_exit.sh