diff --git a/package_check.sh b/package_check.sh index 0c1f4d7..4320195 100755 --- a/package_check.sh +++ b/package_check.sh @@ -11,7 +11,7 @@ complete_log="./Complete.log" > "$complete_log" > "./lxc_boot.log" -TEST_CONTEXT=$(mktemp -d) +TEST_CONTEXT=$(mktemp -d /tmp/package_check.XXXXXX) # Redirect fd 3 (=debug steam) to complete log exec 3>>$complete_log @@ -165,7 +165,7 @@ echo "start:$(date +%s):$$" > "$lock_file" assert_we_are_the_setup_user assert_we_are_connected_to_the_internets -self_upgrade +#self_upgrade fetch_or_upgrade_package_linter # Reset and create a fresh container to work with @@ -176,7 +176,7 @@ LXC_CREATE # Pick up the package #================================================= -function FETCH_PACKAGE_TO_TEST() { +FETCH_PACKAGE_TO_TEST() { local path_to_package_to_test="$1" @@ -226,7 +226,7 @@ function FETCH_PACKAGE_TO_TEST() { } FETCH_PACKAGE_TO_TEST $path_to_package_to_test -readonly app_id="$(cat $package_path/manifest.json | jq .id | tr -d '"')" +readonly app_id="$(cat $package_path/manifest.json | jq -r .id)" #================================================= @@ -235,223 +235,225 @@ readonly app_id="$(cat $package_path/manifest.json | jq .id | tr -d '"')" COMPUTE_RESULTS_SUMMARY () { - local test_serie_id=$1 - source $TEST_CONTEXT/$test_serie_id/results - - # Print the test result - print_result () { - - # Print the result of this test - # we use printf to force the length to 30 (filled with space) - testname=$(printf %-30.30s "$1:") - if [ $2 -eq 1 ] - then - echo "$testname ${BOLD}${GREEN}SUCCESS${NORMAL}" - elif [ $2 -eq -1 ] - then - echo "$testname ${BOLD}${RED}FAIL${NORMAL}" - else - echo "$testname Not evaluated." - fi - } - - # Print the result for each test - echo -e "\n\n" - print_result "Package linter" $RESULT_linter - print_result "Install (root)" $RESULT_check_root - print_result "Install (subpath)" $RESULT_check_subdir - print_result "Install (no url)" $RESULT_check_nourl - print_result "Install (private)" $RESULT_check_private - print_result "Install (multi-instance)" $RESULT_check_multi_instance - print_result "Upgrade" $RESULT_check_upgrade - print_result "Backup" $RESULT_check_backup - print_result "Restore" $RESULT_check_restore - print_result "Change URL" $RESULT_change_url - print_result "Port already used" $RESULT_check_port - print_result "Actions and config-panel" $RESULT_action_config_panel - - # Determine the level for this app - - # Each level can has 5 different values - # 0 -> If this level can't be validated - # 1 -> If this level is forced. Even if the tests fails - # 2 -> Indicates the tests had previously validated this level - # auto -> This level has not a value yet. - # na -> This level will not be checked, but it'll be ignored in the final sum - - # Set default values for level, if they're empty. - test -n "${level[1]}" || level[1]=auto - test -n "${level[2]}" || level[2]=auto - test -n "${level[3]}" || level[3]=auto - test -n "${level[4]}" || level[4]=auto - test -n "${level[5]}" || level[5]=auto - test -n "${level[5]}" || level[5]=auto - test -n "${level[6]}" || level[6]=auto - test -n "${level[7]}" || level[7]=auto - test -n "${level[8]}" || level[8]=auto - test -n "${level[9]}" || level[9]=0 - test -n "${level[10]}" || level[10]=0 - - pass_level_1() { - # FIXME FIXME #FIXME - return 0 - } - - pass_level_2() { - # -> The package can be install and remove in all tested configurations. - # Validated if none install failed - [ $RESULT_check_subdir -ne -1 ] && \ - [ $RESULT_check_root -ne -1 ] && \ - [ $RESULT_check_private -ne -1 ] && \ - [ $RESULT_check_multi_instance -ne -1 ] - } - - pass_level_3() { - # -> The package can be upgraded from the same version. - # Validated if the upgrade is ok. Or if the upgrade has been not tested but already validated before. - [ $RESULT_check_upgrade -eq 1 ] || \ - ( [ $RESULT_check_upgrade -ne -1 ] && \ - [ "${level[3]}" == "2" ] ) - } - - pass_level_4() { - # -> The package can be backup and restore without error - # Validated if backup and restore are ok. Or if backup and restore have been not tested but already validated before. - ( [ $RESULT_check_backup -eq 1 ] && \ - [ $RESULT_check_restore -eq 1 ] ) || \ - ( [ $RESULT_check_backup -ne -1 ] && \ - [ $RESULT_check_restore -ne -1 ] && \ - [ "${level[4]}" == "2" ] ) - } - - pass_level_5() { - # -> The package have no error with package linter - # -> The package does not have any alias_traversal error - # Validated if Linter is ok. Or if Linter has been not tested but already validated before. - [ $RESULT_alias_traversal -ne 1 ] && \ - ([ $RESULT_linter -ge 1 ] || \ - ( [ $RESULT_linter -eq 0 ] && \ - [ "${level[5]}" == "2" ] ) ) - } - - pass_level_6() { - # -> The package can be backup and restore without error - # This is from the linter, tests if app is the Yunohost-apps organization - [ $RESULT_linter_level_6 -eq 1 ] || \ - ([ $RESULT_linter_level_6 -eq 0 ] && \ - [ "${level[6]}" == "2" ] ) - } - - pass_level_7() { - # -> None errors in all tests performed - # Validated if none errors is happened. - [ $RESULT_check_subdir -ne -1 ] && \ - [ $RESULT_check_upgrade -ne -1 ] && \ - [ $RESULT_check_private -ne -1 ] && \ - [ $RESULT_check_multi_instance -ne -1 ] && \ - [ $RESULT_check_port -ne -1 ] && \ - [ $RESULT_check_backup -ne -1 ] && \ - [ $RESULT_check_restore -ne -1 ] && \ - [ $RESULT_change_url -ne -1 ] && \ - [ $RESULT_action_config_panel -ne -1 ] && \ - ([ $RESULT_linter_level_7 -ge 1 ] || - ([ $RESULT_linter_level_7 -eq 0 ] && \ - [ "${level[8]}" == "2" ] )) - } - - pass_level_8() { - # This happens in the linter - # When writing this, defined as app being maintained + long term quality (= - # certain amount of time level 5+ in the last year) - [ $RESULT_linter_level_8 -ge 1 ] || \ - ([ $RESULT_linter_level_8 -eq 0 ] && \ - [ "${level[8]}" == "2" ] ) - } - - pass_level_9() { - list_url="https://raw.githubusercontent.com/YunoHost/apps/master/apps.json" - curl --silent $list_url | jq ".[\"$app_id\"].high_quality" | grep -q "true" - } - - # Check if the level can be changed - level_can_change () { - # If the level is set at auto, it's waiting for a change - # And if it's set at 2, its value can be modified by a new result - [ "${level[$1]}" == "auto" ] || [ "${level[$1]}" -eq 2 ] - } - - if level_can_change 1; then pass_level_1 && level[1]=2 || level[1]=0; fi - if level_can_change 2; then pass_level_2 && level[2]=2 || level[2]=0; fi - if level_can_change 3; then pass_level_3 && level[3]=2 || level[3]=0; fi - if level_can_change 4; then pass_level_4 && level[4]=2 || level[4]=0; fi - if level_can_change 5; then pass_level_5 && level[5]=2 || level[5]=0; fi - if level_can_change 6; then pass_level_6 && level[6]=2 || level[6]=0; fi - if level_can_change 7; then pass_level_7 && level[7]=2 || level[7]=0; fi - if level_can_change 8; then pass_level_8 && level[8]=2 || level[8]=0; fi - if level_can_change 9; then pass_level_9 && level[9]=2 || level[9]=0; fi - - # Level 10 has no definition yet - level[10]=0 - - # Initialize the global level - global_level=0 - - # Calculate the final level - for i in `seq 1 10` - do - - # If there is a level still at 'auto', it's a mistake. - if [ "${level[i]}" == "auto" ] - then - # So this level will set at 0. - level[i]=0 - - # If the level is at 1 or 2. The global level will be set at this level - elif [ "${level[i]}" -ge 1 ] - then - global_level=$i - - # But, if the level is at 0, the loop stop here - # Like that, the global level rise while none level have failed - else - break - fi - done - - # If some witness files was missing, it's a big error ! So, the level fall immediately at 0. - if [ $RESULT_witness -eq 1 ] - then - log_error "Some witness files has been deleted during those tests ! It's a very bad thing !" - global_level=0 - fi - - # If the package linter returned a critical error, the app is flagged as broken / level 0 - if [ $RESULT_linter_broken -eq 1 ] - then - log_error "The package linter reported a critical failure ! App is considered broken !" - global_level=0 - fi - - if [ $RESULT_alias_traversal -eq 1 ] - then - log_error "Issue alias_traversal was detected ! Please see here https://github.com/YunoHost/example_ynh/pull/45 to fix that." - fi - - # Then, print the levels - # Print the global level - verbose_level=$(grep "^$global_level " "./levels.list" | cut -c4-) - - log_info "Level of this application: $global_level ($verbose_level)" - - # And print the value for each level - for i in `seq 1 10` - do - display="0" - if [ "${level[$i]}" -ge 1 ]; then - display="1" - fi - echo -e "\t Level $i: $display" - done + return +# +# local test_serie_id=$1 +# source $TEST_CONTEXT/$test_serie_id/results +# +# # Print the test result +# print_result () { +# +# # Print the result of this test +# # we use printf to force the length to 30 (filled with space) +# testname=$(printf %-30.30s "$1:") +# if [ $2 -eq 1 ] +# then +# echo "$testname ${BOLD}${GREEN}SUCCESS${NORMAL}" +# elif [ $2 -eq -1 ] +# then +# echo "$testname ${BOLD}${RED}FAIL${NORMAL}" +# else +# echo "$testname Not evaluated." +# fi +# } +# +# # Print the result for each test +# echo -e "\n\n" +# print_result "Package linter" $RESULT_linter +# print_result "Install (root)" $RESULT_check_root +# print_result "Install (subpath)" $RESULT_check_subdir +# print_result "Install (no url)" $RESULT_check_nourl +# print_result "Install (private)" $RESULT_check_private +# print_result "Install (multi-instance)" $RESULT_check_multi_instance +# print_result "Upgrade" $RESULT_check_upgrade +# print_result "Backup" $RESULT_check_backup +# print_result "Restore" $RESULT_check_restore +# print_result "Change URL" $RESULT_change_url +# print_result "Port already used" $RESULT_check_port +# print_result "Actions and config-panel" $RESULT_action_config_panel +# +# # Determine the level for this app +# +# # Each level can has 5 different values +# # 0 -> If this level can't be validated +# # 1 -> If this level is forced. Even if the tests fails +# # 2 -> Indicates the tests had previously validated this level +# # auto -> This level has not a value yet. +# # na -> This level will not be checked, but it'll be ignored in the final sum +# +# # Set default values for level, if they're empty. +# test -n "${level[1]}" || level[1]=auto +# test -n "${level[2]}" || level[2]=auto +# test -n "${level[3]}" || level[3]=auto +# test -n "${level[4]}" || level[4]=auto +# test -n "${level[5]}" || level[5]=auto +# test -n "${level[5]}" || level[5]=auto +# test -n "${level[6]}" || level[6]=auto +# test -n "${level[7]}" || level[7]=auto +# test -n "${level[8]}" || level[8]=auto +# test -n "${level[9]}" || level[9]=0 +# test -n "${level[10]}" || level[10]=0 +# +# pass_level_1() { +# # FIXME FIXME #FIXME +# return 0 +# } +# +# pass_level_2() { +# # -> The package can be install and remove in all tested configurations. +# # Validated if none install failed +# [ $RESULT_check_subdir -ne -1 ] && \ +# [ $RESULT_check_root -ne -1 ] && \ +# [ $RESULT_check_private -ne -1 ] && \ +# [ $RESULT_check_multi_instance -ne -1 ] +# } +# +# pass_level_3() { +# # -> The package can be upgraded from the same version. +# # Validated if the upgrade is ok. Or if the upgrade has been not tested but already validated before. +# [ $RESULT_check_upgrade -eq 1 ] || \ +# ( [ $RESULT_check_upgrade -ne -1 ] && \ +# [ "${level[3]}" == "2" ] ) +# } +# +# pass_level_4() { +# # -> The package can be backup and restore without error +# # Validated if backup and restore are ok. Or if backup and restore have been not tested but already validated before. +# ( [ $RESULT_check_backup -eq 1 ] && \ +# [ $RESULT_check_restore -eq 1 ] ) || \ +# ( [ $RESULT_check_backup -ne -1 ] && \ +# [ $RESULT_check_restore -ne -1 ] && \ +# [ "${level[4]}" == "2" ] ) +# } +# +# pass_level_5() { +# # -> The package have no error with package linter +# # -> The package does not have any alias_traversal error +# # Validated if Linter is ok. Or if Linter has been not tested but already validated before. +# [ $RESULT_alias_traversal -ne 1 ] && \ +# ([ $RESULT_linter -ge 1 ] || \ +# ( [ $RESULT_linter -eq 0 ] && \ +# [ "${level[5]}" == "2" ] ) ) +# } +# +# pass_level_6() { +# # -> The package can be backup and restore without error +# # This is from the linter, tests if app is the Yunohost-apps organization +# [ $RESULT_linter_level_6 -eq 1 ] || \ +# ([ $RESULT_linter_level_6 -eq 0 ] && \ +# [ "${level[6]}" == "2" ] ) +# } +# +# pass_level_7() { +# # -> None errors in all tests performed +# # Validated if none errors is happened. +# [ $RESULT_check_subdir -ne -1 ] && \ +# [ $RESULT_check_upgrade -ne -1 ] && \ +# [ $RESULT_check_private -ne -1 ] && \ +# [ $RESULT_check_multi_instance -ne -1 ] && \ +# [ $RESULT_check_port -ne -1 ] && \ +# [ $RESULT_check_backup -ne -1 ] && \ +# [ $RESULT_check_restore -ne -1 ] && \ +# [ $RESULT_change_url -ne -1 ] && \ +# [ $RESULT_action_config_panel -ne -1 ] && \ +# ([ $RESULT_linter_level_7 -ge 1 ] || +# ([ $RESULT_linter_level_7 -eq 0 ] && \ +# [ "${level[8]}" == "2" ] )) +# } +# +# pass_level_8() { +# # This happens in the linter +# # When writing this, defined as app being maintained + long term quality (= +# # certain amount of time level 5+ in the last year) +# [ $RESULT_linter_level_8 -ge 1 ] || \ +# ([ $RESULT_linter_level_8 -eq 0 ] && \ +# [ "${level[8]}" == "2" ] ) +# } +# +# pass_level_9() { +# list_url="https://raw.githubusercontent.com/YunoHost/apps/master/apps.json" +# curl --silent $list_url | jq ".[\"$app_id\"].high_quality" | grep -q "true" +# } +# +# # Check if the level can be changed +# level_can_change () { +# # If the level is set at auto, it's waiting for a change +# # And if it's set at 2, its value can be modified by a new result +# [ "${level[$1]}" == "auto" ] || [ "${level[$1]}" -eq 2 ] +# } +# +# if level_can_change 1; then pass_level_1 && level[1]=2 || level[1]=0; fi +# if level_can_change 2; then pass_level_2 && level[2]=2 || level[2]=0; fi +# if level_can_change 3; then pass_level_3 && level[3]=2 || level[3]=0; fi +# if level_can_change 4; then pass_level_4 && level[4]=2 || level[4]=0; fi +# if level_can_change 5; then pass_level_5 && level[5]=2 || level[5]=0; fi +# if level_can_change 6; then pass_level_6 && level[6]=2 || level[6]=0; fi +# if level_can_change 7; then pass_level_7 && level[7]=2 || level[7]=0; fi +# if level_can_change 8; then pass_level_8 && level[8]=2 || level[8]=0; fi +# if level_can_change 9; then pass_level_9 && level[9]=2 || level[9]=0; fi +# +# # Level 10 has no definition yet +# level[10]=0 +# +# # Initialize the global level +# global_level=0 +# +# # Calculate the final level +# for i in `seq 1 10` +# do +# +# # If there is a level still at 'auto', it's a mistake. +# if [ "${level[i]}" == "auto" ] +# then +# # So this level will set at 0. +# level[i]=0 +# +# # If the level is at 1 or 2. The global level will be set at this level +# elif [ "${level[i]}" -ge 1 ] +# then +# global_level=$i +# +# # But, if the level is at 0, the loop stop here +# # Like that, the global level rise while none level have failed +# else +# break +# fi +# done +# +# # If some witness files was missing, it's a big error ! So, the level fall immediately at 0. +# if [ $RESULT_witness -eq 1 ] +# then +# log_error "Some witness files has been deleted during those tests ! It's a very bad thing !" +# global_level=0 +# fi +# +# # If the package linter returned a critical error, the app is flagged as broken / level 0 +# if [ $RESULT_linter_broken -eq 1 ] +# then +# log_error "The package linter reported a critical failure ! App is considered broken !" +# global_level=0 +# fi +# +# if [ $RESULT_alias_traversal -eq 1 ] +# then +# log_error "Issue alias_traversal was detected ! Please see here https://github.com/YunoHost/example_ynh/pull/45 to fix that." +# fi +# +# # Then, print the levels +# # Print the global level +# verbose_level=$(grep "^$global_level " "./levels.list" | cut -c4-) +# +# log_info "Level of this application: $global_level ($verbose_level)" +# +# # And print the value for each level +# for i in `seq 1 10` +# do +# display="0" +# if [ "${level[$i]}" -ge 1 ]; then +# display="1" +# fi +# echo -e "\t Level $i: $display" +# done } #================================================= @@ -549,7 +551,7 @@ parse_check_process() { then local specific_upgrade_install_args="$(grep "^manifest_arg=" "$TEST_CONTEXT/upgrades/$commit" | cut -d'=' -f2-)" [[ -n "$specific_upgrade_install_args" ]] && _install_args="$specific_upgrade_install_args" - + local upgrade_name="$(grep "^name=" "$TEST_CONTEXT/upgrades/$commit" | cut -d'=' -f2)" extra="$(jq -n --arg upgrade_name "$upgrade_name" '{ $upgrade_name }')" elif [[ "$test_type" == "ACTIONS_CONFIG_PANEL" ]] && [[ "$test_arg" == "actions" ]] @@ -560,14 +562,15 @@ parse_check_process() { extra="$(jq -n --arg configpanel "$configpanel_infos" '{ $configpanel }')" fi - jq -n -f "$TEST_CONTEXT/tests/$test_id.json" \ + jq -n \ --arg test_serie "$test_serie" \ --arg test_type "$test_type" \ --arg test_arg "$test_arg" \ --arg preinstall_template "$preinstall_template" \ --arg install_args "$_install_args" \ - --argjson "$extra" \ - '{ $test_serie, $test_type, $test_arg, $preinstall_template, $install_args, $extra }' + --argjson extra "$extra" \ + '{ $test_serie, $test_type, $test_arg, $preinstall_template, $install_args, $extra }' \ + > "$TEST_CONTEXT/tests/$test_id.json" } # For not-the-main-test-serie, we only consider testing the install and @@ -603,7 +606,6 @@ parse_check_process() { while IFS= read -r LINE; do commit=$(echo $LINE | grep -o "from_commit=.*" | awk -F= '{print $2}') - [ -n "$commit" ] || commit="current" add_test "TEST_UPGRADE" "$commit" done @@ -640,14 +642,15 @@ guess_test_configuration() { test_id="$((test_id+1))" local extra="{}" - jq -n -f "$TEST_CONTEXT/tests/$test_id.json" + jq -n \ --arg test_serie "default" \ --arg test_type "$test_type" \ --arg test_arg "$test_arg" \ --arg preinstall_template "" \ --arg install_args "$install_args" \ - --argjson "$extra" \ - '{ $test_serie, $test_type, $test_arg, $preinstall_template, $install_args, $extra }' + --argjson extra "$extra" \ + '{ $test_serie, $test_type, $test_arg, $preinstall_template, $install_args, $extra }' \ + > "$TEST_CONTEXT/tests/$test_id.json" } local install_args=$(python "./sub_scripts/manifest_parsing.py" "$package_path/manifest.json" | cut -d ':' -f1,2 | tr ':' '=' | tr '\n' '&') @@ -664,7 +667,7 @@ guess_test_configuration() { add_test "TEST_MULTI_INSTANCE" fi add_test "TEST_BACKUP_RESTORE" - add_test "TEST_UPGRADE current" + add_test "TEST_UPGRADE" } #================================================= @@ -697,6 +700,9 @@ run_all_tests() { } +mkdir -p $TEST_CONTEXT/tests +mkdir -p $TEST_CONTEXT/results + [ -e "$check_process" ] \ && parse_check_process \ || guess_test_configuration diff --git a/sub_scripts/common.sh b/sub_scripts/common.sh index 3c17fcf..10b1f01 100755 --- a/sub_scripts/common.sh +++ b/sub_scripts/common.sh @@ -15,7 +15,7 @@ SUBDOMAIN="sub.$DOMAIN" # User de test TEST_USER="package_checker" -LXC_NAME="ynh-appci" +LXC_NAME="ynh-appci-$DEFAULT_DIST" [[ -e "./config" ]] && source "./config" diff --git a/sub_scripts/lxc.sh b/sub_scripts/lxc.sh index f2e02a4..610dc69 100755 --- a/sub_scripts/lxc.sh +++ b/sub_scripts/lxc.sh @@ -19,7 +19,7 @@ LXC_CREATE () { } LXC_SNAPSHOT_EXISTS() { - lxc info $LXC_NAME | grep -A10 Snapshots | tail -n -1 | awk '{print $1}' | greq -q -w "$1" + lxc info $LXC_NAME 2>/dev/null | grep -A10 Snapshots | tail -n -1 | awk '{print $1}' | grep -q -w "$1" } CREATE_LXC_SNAPSHOT () { @@ -33,26 +33,25 @@ CREATE_LXC_SNAPSHOT () { [ $snapname != "snap0" ] && check_witness_files >&2 # Remove swap files to avoid killing the CI with huge snapshots. - sudo lxc exec $LXC_NAME -- bash -c 'for swapfile in $(ls /swap_*); do swapoff $swapfile; done' - sudo lxc exec $LXC_NAME -- bash -c 'for swapfile in $(ls /swap_*); do rm -f $swapfile; done' - - # Stop the container, before its snapshot + sudo lxc exec $LXC_NAME -- bash -c 'for swapfile in $(ls /swap_* 2>/dev/null); do swapoff $swapfile; done' + sudo lxc exec $LXC_NAME -- bash -c 'for swapfile in $(ls /swap_* 2>/dev/null); do rm -f $swapfile; done' + sudo lxc stop --timeout 15 $LXC_NAME 2>/dev/null # Check if the snapshot already exist if ! LXC_SNAPSHOT_EXISTS "$snapname" then log_debug "$snapname doesn't exist, its first creation can takes a little while." >&2 - sudo lxc snapshot $LXC_NAME $snapname --stateful + sudo lxc snapshot $LXC_NAME $snapname fi - + stop_timer 1 } LOAD_LXC_SNAPSHOT () { snapname=$1 sudo lxc stop --timeout 15 $LXC_NAME 2>/dev/null - sudo lxc restore $LXC_NAME $snapname --stateful + sudo lxc restore $LXC_NAME $snapname _LXC_START_AND_WAIT $LXC_NAME } @@ -62,7 +61,6 @@ LXC_START () { # Start the lxc container and execute the given command in it local cmd=$1 - sudo lxc start $LXC_NAME _LXC_START_AND_WAIT $LXC_NAME start_timer @@ -90,7 +88,7 @@ LXC_STOP () { LXC_RESET () { sudo lxc stop --timeout 15 $LXC_NAME 2>/dev/null - sudo lxc delete $LXC_NAME + sudo lxc delete $LXC_NAME 2>/dev/null } @@ -98,8 +96,8 @@ _LXC_START_AND_WAIT() { restart_container() { - lxc stop "$1" - lxc start "$1" + sudo lxc stop "$1" + sudo lxc start "$1" } # Try to start the container 3 times. @@ -118,7 +116,8 @@ _LXC_START_AND_WAIT() { fi if [ "$j" == "10" ]; then - error 'Failed to start the container' + log_error 'Failed to start the container' + lxc info $1 failstart=1 restart_container "$1" @@ -134,7 +133,7 @@ _LXC_START_AND_WAIT() { fi if [ "$j" == "10" ]; then - error 'Failed to access the internet' + log_error 'Failed to access the internet' failstart=1 restart_container "$1" diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index 56b2a3d..f93098e 100755 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -58,8 +58,8 @@ default_install_path() { #================================================= INSTALL_APP () { - local install_args="$(jq '.install_args' $current_test_infos)" - local preinstall_template="$(jq '.preinstall_template' $current_test_infos)" + local install_args="$(jq -r '.install_args' $current_test_infos)" + local preinstall_template="$(jq -r '.preinstall_template' $current_test_infos)" # We have default values for domain, user and is_public, but these # may still be overwritten by the args ($@) @@ -319,7 +319,7 @@ TEST_INSTALL () { # Create the snapshot that'll be used by other tests later [ "$install_type" != "private" ] \ - && ! LXC_SNAPSHOT_EXISTS $snapname + && ! LXC_SNAPSHOT_EXISTS $snapname \ && log_debug "Create a snapshot after app install" \ && CREATE_LXC_SNAPSHOT $snapname @@ -340,7 +340,7 @@ TEST_UPGRADE () { then start_test "Upgrade from the same version" else - upgrade_name="$(jq '.extra.upgrade_name' $current_test_infos)" + upgrade_name="$(jq -r '.extra.upgrade_name' $current_test_infos)" [ -n "$upgrade_name" ] || upgrade_name="commit $commit" start_test "Upgrade from $upgrade_name" fi @@ -1054,13 +1054,13 @@ TEST_LAUNCHER () { # And keep this value separately local global_start_timer=$starttime - current_test_id=$(basename $test | cut -d. -f1) + current_test_id=$(basename $testfile | cut -d. -f1) current_test_infos="$TEST_CONTEXT/tests/$current_test_id.json" current_test_results="$TEST_CONTEXT/results/$current_test_id.json" echo "{}" > $current_test_results - local test_type=$(jq '.test_type' $testfile) - local test_arg=$(jq '.test_arg' $testfile) + local test_type=$(jq -r '.test_type' $testfile) + local test_arg=$(jq -r '.test_arg' $testfile) # Execute the test $test_type $test_arg @@ -1084,7 +1084,7 @@ TEST_LAUNCHER () { SET_RESULT() { local result=$1 local name=$2 - [ $result -eq "success" ] && log_report_test_success || log_report_test_failed + [ "$result" == "success" ] && log_report_test_success || log_report_test_failed local current_results="$(cat $current_test_results)" echo "$current_results" | jq --arg result $result ".$name=\$result" > $current_test_results } @@ -1094,8 +1094,8 @@ at_least_one_install_succeeded () { for TEST in $(ls $TEST_CONTEXT/tests/*.json) do local test_id=$(basename $TEST | cut -d. -f1) - jq -e '. | select(.test_type == "TEST_INSTALL")' $TEST \ - && jq -e '. | select(.main_result == "success")' $TEST_CONTEXT/results/$test_id.json \ + jq -e '. | select(.test_type == "TEST_INSTALL")' $TEST >/dev/null \ + && jq -e '. | select(.main_result == "success")' $TEST_CONTEXT/results/$test_id.json >/dev/null \ && return 0 done