tests_fctrserver.sh 27 KB

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