diff --git a/lib/analyze_test_results.py b/lib/analyze_test_results.py index 4a72a13..cc7cbe7 100644 --- a/lib/analyze_test_results.py +++ b/lib/analyze_test_results.py @@ -168,8 +168,7 @@ test_types = { OK = ' \033[1m\033[92mOK\033[0m ' FAIL = '\033[91mfail\033[0m' -print("Tests summary") -print("=============") +print() for test in tests: test_display_name = test_types[test["test_type"]] if test["test_arg"]: diff --git a/lib/lxc.sh b/lib/lxc.sh index 2524245..f22d098 100644 --- a/lib/lxc.sh +++ b/lib/lxc.sh @@ -14,7 +14,7 @@ LXC_CREATE () { } LXC_SNAPSHOT_EXISTS() { - lxc info $LXC_NAME 2>/dev/null | grep -A10 Snapshots | tail -n -1 | awk '{print $1}' | grep -q -w "$1" + sudo lxc info $LXC_NAME 2>/dev/null | grep -A10 Snapshots | tail -n -1 | awk '{print $1}' | grep -q -w "$1" } CREATE_LXC_SNAPSHOT () { @@ -36,7 +36,7 @@ CREATE_LXC_SNAPSHOT () { # 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 + log_debug "Creating snapshot $snapname ..." sudo lxc snapshot $LXC_NAME $snapname fi @@ -45,6 +45,7 @@ CREATE_LXC_SNAPSHOT () { LOAD_LXC_SNAPSHOT () { snapname=$1 + log_debug "Loading snapshot $snapname ..." sudo lxc stop --timeout 15 $LXC_NAME 2>/dev/null sudo lxc restore $LXC_NAME $snapname sudo lxc start $LXC_NAME diff --git a/lib/tests.sh b/lib/tests.sh index b99d327..a661eb2 100644 --- a/lib/tests.sh +++ b/lib/tests.sh @@ -67,15 +67,15 @@ _LOAD_SNAPSHOT_OR_INSTALL_APP () { local _install_type=$(path_to_install_type $check_path) local snapname="snap_${_install_type}install" - if [ ! -e "$LXC_SNAPSHOTS/$snapname" ] + if ! LXC_SNAPSHOT_EXISTS $snapname then LOAD_LXC_SNAPSHOT snap0 \ &&_INSTALL_APP "path=$check_path" \ - && log_debug "Creating a snapshot for $_install_type installation." \ + && log_debug "(Creating a snapshot for $_install_type installation.)" \ && CREATE_LXC_SNAPSHOT $snapname else # Or uses an existing snapshot - log_debug "Reusing an existing snapshot for $_install_type installation." \ + log_debug "(Reusing an existing snapshot for $_install_type installation.)" \ && LOAD_LXC_SNAPSHOT $snapname fi } @@ -315,7 +315,7 @@ _TEST_MULTI_INSTANCE () { LOAD_LXC_SNAPSHOT snap0 log_small_title "First installation: path=$DOMAIN$check_path" \ - &&_INSTALL_APP "domain=$DOMAIN" "path=$check_path" \ + && _LOAD_SNAPSHOT_OR_INSTALL_APP "$check_path" \ && log_small_title "Second installation: path=$SUBDOMAIN$check_path" \ && _INSTALL_APP "path=$check_path" \ && _VALIDATE_THAT_APP_CAN_BE_ACCESSED $DOMAIN $check_path \ @@ -470,7 +470,7 @@ TEST_BACKUP_RESTORE () { RUN_INSIDE_LXC rm -f /rootfs/home/yunohost.backup/archives/* # Place the copy of the backup archive in the container. - sudo lxc file push -r ./ynh_backups $LXC_NAME/home/yunohost.backup/archives/ + sudo lxc file push -r ./ynh_backups/archives/* $LXC_NAME/home/yunohost.backup/archives/ RUN_INSIDE_LXC ls -l /home/yunohost.backup/archives/ log_small_title "Restore on a clean YunoHost system..." diff --git a/lib/tests_coordination.sh b/lib/tests_coordination.sh index 0e9cab2..942daa5 100644 --- a/lib/tests_coordination.sh +++ b/lib/tests_coordination.sh @@ -84,10 +84,10 @@ parse_check_process() { local configpanel_infos=$( extract_check_process_section "^; Config_panel" "^; " $test_serie_rawconf) # Add (empty) special args if they ain't provided in check_process - echo "$install_args" | tr '&' '\n' | grep -q "^domain=" ||install_args+="&domain=" - echo "$install_args" | tr '&' '\n' | grep -q "^path=" ||install_args+="&path=" - echo "$install_args" | tr '&' '\n' | grep -q "^admin=" ||install_args+="&admin=" - echo "$install_args" | tr '&' '\n' | grep -q "^is_public=" ||install_args+="&is_public=" + echo "$install_args" | tr '&' '\n' | grep -q "^domain=" ||install_args+="domain=&" + echo "$install_args" | tr '&' '\n' | grep -q "^path=" ||install_args+="path=&" + echo "$install_args" | tr '&' '\n' | grep -q "^admin=" ||install_args+="admin=&" + echo "$install_args" | tr '&' '\n' | grep -q "^is_public=" ||install_args+="is_public=&" extract_check_process_section "^; Checks" "^; " $test_serie_rawconf > $TEST_CONTEXT/check_process.tests_infos @@ -142,7 +142,7 @@ parse_check_process() { grep "^upgrade=1" "$TEST_CONTEXT/check_process.tests_infos" | while IFS= read -r LINE; do - commit=$(echo $LINE | grep -o "from_commit=.*" | awk -F= '{print $2}') + commit="$(echo $LINE | grep -o "from_commit=.*" | awk -F= '{print $2}')" [ -n "$commit" ] || continue add_test "TEST_UPGRADE" "$commit" done @@ -164,7 +164,7 @@ parse_check_process() { grep "^upgrade=1" "$TEST_CONTEXT/check_process.tests_infos" | while IFS= read -r LINE; do - commit=$(echo $LINE | grep -o "from_commit=.*" | awk -F= '{print $2}') + commit="$(echo $LINE | grep -o "from_commit=.*" | awk -F= '{print $2}')" add_test "TEST_UPGRADE" "$commit" done @@ -281,6 +281,8 @@ run_all_tests() { done # Print the final results of the tests + log_title "Tests summary" + python3 lib/analyze_test_results.py $TEST_CONTEXT 2>$TEST_CONTEXT/summary.json # Restore the started time for the timer