diff options
author | KatolaZ <katolaz@freaknet.org> | 2017-08-09 21:29:45 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2017-08-09 21:29:45 +0100 |
commit | 33b7c33ab447a0463e414c6cf8f9a2cd2d047a20 (patch) | |
tree | baeaae3eca65536bbe17ad9fe196c7383eafd4da | |
parent | 231beb5c3fc50f40e31b9e00237c67f267188057 (diff) |
added more tests about basic scorsh setup
-rwxr-xr-x | test/configure_app.sh | 39 | ||||
-rwxr-xr-x | test/create_testbed.sh | 12 | ||||
-rw-r--r-- | test/scorsh_functions | 19 | ||||
-rwxr-xr-x[-rw-r--r--] | test/scorsh_testsuite | 14 | ||||
-rwxr-xr-x | test/start_scorsh.sh | 27 | ||||
-rwxr-xr-x | test/stop_scorsh.sh | 20 | ||||
-rw-r--r-- | test/test_spec | 5 |
7 files changed, 119 insertions, 17 deletions
diff --git a/test/configure_app.sh b/test/configure_app.sh new file mode 100755 index 0000000..e0a8f2e --- /dev/null +++ b/test/configure_app.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +. ./scorsh_functions + + +### create spool directory +mkdir "${SCORSH_APP}/spool" +check_fatal "[ -$? -eq 0 ]" $0 "create_spool_folder" + + +### configure the remote to be used with scorsh +cd ${REMOTE_REPO} +SPOOL_DIR="${SCORSH_APP}/spool" +git config -f scorsh scorsh.spooldir $(realpath "${SPOOL_DIR}") +ret=$(git config -f scorsh scorsh.spooldir) +check_fatal "[ \"${ret}\" = \"${SPOOL_DIR}\" ]" $0 "config_remote_repo" +cd - > /dev/null +### + + +### copy the post-receive hook in REMOTE_REPO/hooks +cp ${SCORSH_REPO}/hooks/post-receive ${REMOTE_REPO}/hooks/ +check_fatal "[ $? -eq 0 ]" $0 "copy_post-receive_hook" + + +### copy the scorshd program under SCORSH_APP +cp ${SCORSH_REPO}/scorshd ${SCORSH_APP} +check_fatal "[ $? -eq 0 ]" $0 "copy_scorshd" + +### copy the files under "examples" into SCORSH_APP +cp -a ${SCORSH_REPO}/examples/* ${SCORSH_APP} +check_fatal "[ $? -eq 0 ]" $0 "copy_scorsh_config" + + + + +##check_fatal "[ 1 -eq 0 ]" $0 "aborting_on_purpose" + +return_results diff --git a/test/create_testbed.sh b/test/create_testbed.sh index 42fc0a7..c7e9a6d 100755 --- a/test/create_testbed.sh +++ b/test/create_testbed.sh @@ -46,16 +46,4 @@ mkdir ${SCORSH_APP} check "[ $? -eq 0 ]" $0 "create_scorsh_app_folder" -### create spool directory -mkdir "${SCORSH_APP}/spool" -check "[ -$? -eq 0 ]" $0 "create_spool_folder" - - -### configure the remote to be used with scorsh -cd ${REMOTE_REPO} -git config -f scorsh scorsh.spooldir $(realpath "${SCORSH_APP}/spool") -check "[ $? -eq 0 ]" $0 "config_remote_repo" -cd - - - return_results diff --git a/test/scorsh_functions b/test/scorsh_functions index 1917188..7f4fb1b 100644 --- a/test/scorsh_functions +++ b/test/scorsh_functions @@ -41,6 +41,25 @@ check(){ } ## func +check_fatal(){ + EXPR="$1" + TEST_NAME="$2" + TEST_SECTION="$3" + + TOT_TESTS=$((${TOT_TESTS} + 1)) + + ##echo "EXPR: ${EXPR}" + if $(echo ${EXPR}) ; then + passed ${TEST_NAME} ${TEST_SECTION} + else + failed ${TEST_NAME} ${TEST_SECTION} + echo "Fatal test failed -- Aborting" + exit 1 + fi +} + + +## func report_results(){ echo -n "TOTAL_TESTS: ${TOT_TESTS} -- " diff --git a/test/scorsh_testsuite b/test/scorsh_testsuite index 57954f7..a631a29 100644..100755 --- a/test/scorsh_testsuite +++ b/test/scorsh_testsuite @@ -22,10 +22,10 @@ trap cleanup 0 HUP INT TRAP TERM QUIT ## func cleanup(){ ## do stuff here - rm -rf ${SCORSH_REPO} - rm -rf ${SCORSH_APP} - rm -rf ${REMOTE_REPO} - rm -rf ${LOCAL_REPO} + # rm -rf ${SCORSH_REPO} + # rm -rf ${SCORSH_APP} + # rm -rf ${REMOTE_REPO} + # rm -rf ${LOCAL_REPO} echo "Exiting..." } @@ -37,6 +37,10 @@ run_tests(){ export PASSED_TESTS FAILED_TESTS TOT_TESTS echo "\033[4;7;36m-+-+- running tests in $t -+-+-\033[0m" $t + if [ $? -ne 0 ]; then + echo "test $t aborted unexpectedly. Aborting" + exit 2 + fi eval $(cat ${STATUS_FILE}) echo "\033[35m-------------------------------------------------------------\033[0m" @@ -52,6 +56,8 @@ PASSED_TESTS=0 FAILED_TESTS=0 TOT_TESTS=0 +rm ${STATUS_FILE} + run_tests report_results diff --git a/test/start_scorsh.sh b/test/start_scorsh.sh new file mode 100755 index 0000000..40a9754 --- /dev/null +++ b/test/start_scorsh.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +. ./scorsh_functions + +## start the scorsh daemon +cd ${SCORSH_APP} +./scorshd -c scorsh_example.cfg & +echo "$!" > scorsh.pid +is_running=$(ps $(cat scorsh.pid) | grep -c scorshd ) +cd - >/dev/null +check_fatal "[ \"${is_running}\" = \"1\" ]" $0 "start_scorshd" + +##check_fatal "[ 1 -eq 0 ]" $0 "exit_on_purpose" + +## check if workers were started +cd ${SCORSH_APP} +ret=$(grep -c "Workers started correctly" scorsh.log) +cd - > /dev/null +check_fatal "[ \"$ret\" = \"1\" ]" $0 "workers_started" + +## check if spooler was started +cd ${SCORSH_APP} +ret=$(grep -c "Spooler started correctly" scorsh.log) +cd - > /dev/null +check_fatal "[ \"$ret\" = \"1\" ]" $0 "spooler_started" + +return_results diff --git a/test/stop_scorsh.sh b/test/stop_scorsh.sh new file mode 100755 index 0000000..353b027 --- /dev/null +++ b/test/stop_scorsh.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +. ./scorsh_functions + +## is the daemon running? +cd ${SCORSH_APP} +is_running=$(ps $(cat scorsh.pid) | grep -c scorshd ) +cd - >/dev/null +check "[ \"${is_running}\" = \"1\" ]" $0 "is_scorshd_running" + + +## stop the scorsh daemon +cd ${SCORSH_APP} +kill -15 $(cat scorsh.pid) +ret=$? +rm scorsh.pid +cd - >/dev/null +check "[ $ret -eq 0 ]" $0 "" + +return_results diff --git a/test/test_spec b/test/test_spec index ba0ba55..f085e9f 100644 --- a/test/test_spec +++ b/test/test_spec @@ -20,7 +20,10 @@ LOCAL_REPO=$(realpath "./testbed_repo") TESTS="\ -./create_testbed.sh \ +./create_testbed.sh \ +./configure_app.sh \ +./start_scorsh.sh \ +./stop_scorsh.sh \ ./destroy_testbed.sh \ " |