tests_ts3server.sh 23 KB

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