tests_mcserver.sh 27 KB

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