From d9a3b0ee393bdb34687115eccf6e28877eb9419c Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 19 Dec 2020 01:04:29 +0100 Subject: [PATCH 1/5] Trying to re-add some display of the curl output --- lib/tests.sh | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/lib/tests.sh b/lib/tests.sh index 1b23b3c..293635a 100644 --- a/lib/tests.sh +++ b/lib/tests.sh @@ -217,22 +217,17 @@ _VALIDATE_THAT_APP_CAN_BE_ACCESSED () { fi fi - log_debug "Test url: $check_domain$curl_check_path" - log_debug "Real url: $(cat "./curl_print" | cut --delimiter=';' --fields=2)" - log_debug "HTTP code: $http_code" - log_debug "$test_url_details" - log_debug "Page title: $page_title" - log_debug "Page extract:\n$page_extract" + cat << EOF > $TEST_CONTEXT/curl_result +\nTest url: $check_domain$curl_check_path" +Real url: $(cat "./curl_print" | cut --delimiter=';' --fields=2)" +HTTP code: $http_code" +Page title: $page_title" +Page extract:\n$page_extract" +EOF - if [[ $curl_error -ne 0 ]] - then - log_warning "Test url: $check_domain$curl_check_path" - log_warning "Real url: $(cat "./curl_print" | cut --delimiter=';' --fields=2)" - log_warning "HTTP code: $http_code" - log_warning "$test_url_details" - log_warning "Page title: $page_title" - log_warning "Page extract:\n$page_extract" - fi + [[ $curl_error -eq 0 ]] \ + && log_debug "$(cat $TEST_CONTEXT/curl_result)" + || log_warning "$(cat $TEST_CONTEXT/curl_result)" done # Detect the issue alias_traversal, https://github.com/yandex/gixy/blob/master/docs/en/plugins/aliastraversal.md @@ -295,6 +290,7 @@ TEST_INSTALL () { # Install the application in a LXC container _INSTALL_APP "path=$check_path" "is_public=$is_public" \ && _VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path $install_type + && log_info "$($TEST_CONTEXT/curl_result)" local install=$? @@ -371,9 +367,15 @@ TEST_UPGRADE () { LOAD_LXC_SNAPSHOT snap0 # Install the application - _INSTALL_APP "path=$check_path" + _INSTALL_APP "path=$check_path" + local ret=$? + # Test if the app can be accessed (though we don't want to report an + # error if it's not, in that context) + _VALIDATE_THAT_APP_CAN_BE_ACCESSED "$SUBDOMAIN" "$check_path" \ + && log_info "$($TEST_CONTEXT/curl_result)" + # Then replace the backup rm -rf "$package_path" mv "${package_path}_back" "$package_path" @@ -386,7 +388,8 @@ TEST_UPGRADE () { # Upgrade the application in a LXC container _RUN_YUNOHOST_CMD "app upgrade $app_id -f /app_folder" \ - && _VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path + && _VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path \ + && log_info "$($TEST_CONTEXT/curl_result)" return $? } From 22015755391ca1ce9f150965fa429e0a99b7d406 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 19 Dec 2020 01:05:27 +0100 Subject: [PATCH 2/5] Typo --- lib/tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tests.sh b/lib/tests.sh index 293635a..067a9ea 100644 --- a/lib/tests.sh +++ b/lib/tests.sh @@ -226,7 +226,7 @@ Page extract:\n$page_extract" EOF [[ $curl_error -eq 0 ]] \ - && log_debug "$(cat $TEST_CONTEXT/curl_result)" + && log_debug "$(cat $TEST_CONTEXT/curl_result)" \ || log_warning "$(cat $TEST_CONTEXT/curl_result)" done @@ -289,7 +289,7 @@ TEST_INSTALL () { # Install the application in a LXC container _INSTALL_APP "path=$check_path" "is_public=$is_public" \ - && _VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path $install_type + && _VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path $install_type \ && log_info "$($TEST_CONTEXT/curl_result)" local install=$? From 2da73598409c82202e5917f9c4afa53f1459e4d9 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 19 Dec 2020 01:18:25 +0100 Subject: [PATCH 3/5] Moar stupid typos --- lib/tests.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/tests.sh b/lib/tests.sh index 067a9ea..aa78c17 100644 --- a/lib/tests.sh +++ b/lib/tests.sh @@ -217,13 +217,12 @@ _VALIDATE_THAT_APP_CAN_BE_ACCESSED () { fi fi - cat << EOF > $TEST_CONTEXT/curl_result -\nTest url: $check_domain$curl_check_path" -Real url: $(cat "./curl_print" | cut --delimiter=';' --fields=2)" -HTTP code: $http_code" -Page title: $page_title" -Page extract:\n$page_extract" -EOF + echo -e " +\nTest url: $check_domain$curl_check_path +Real url: $(cat "./curl_print" | cut --delimiter=';' --fields=2) +HTTP code: $http_code +Page title: $page_title +Page extract:\n$page_extract" > $TEST_CONTEXT/curl_result [[ $curl_error -eq 0 ]] \ && log_debug "$(cat $TEST_CONTEXT/curl_result)" \ @@ -290,7 +289,7 @@ TEST_INSTALL () { # Install the application in a LXC container _INSTALL_APP "path=$check_path" "is_public=$is_public" \ && _VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path $install_type \ - && log_info "$($TEST_CONTEXT/curl_result)" + && log_info "$(cat $TEST_CONTEXT/curl_result)" local install=$? @@ -374,7 +373,7 @@ TEST_UPGRADE () { # Test if the app can be accessed (though we don't want to report an # error if it's not, in that context) _VALIDATE_THAT_APP_CAN_BE_ACCESSED "$SUBDOMAIN" "$check_path" \ - && log_info "$($TEST_CONTEXT/curl_result)" + && log_info "$(cat $TEST_CONTEXT/curl_result)" # Then replace the backup rm -rf "$package_path" @@ -389,7 +388,7 @@ TEST_UPGRADE () { # Upgrade the application in a LXC container _RUN_YUNOHOST_CMD "app upgrade $app_id -f /app_folder" \ && _VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path \ - && log_info "$($TEST_CONTEXT/curl_result)" + && log_info "$(cat $TEST_CONTEXT/curl_result)" return $? } From c7a2448e745daca889a382b001ae37325bbb5254 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 19 Dec 2020 01:23:46 +0100 Subject: [PATCH 4/5] Keep a message to tell about creating/loading snapshots --- lib/lxc.sh | 2 +- lib/tests.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/lxc.sh b/lib/lxc.sh index 6234615..5bb289c 100644 --- a/lib/lxc.sh +++ b/lib/lxc.sh @@ -40,7 +40,7 @@ CREATE_LXC_SNAPSHOT () { # Check if the snapshot already exist if ! LXC_SNAPSHOT_EXISTS "$snapname" then - log_debug "Creating snapshot $snapname ..." + log_info "(Creating snapshot $snapname ...)" lxc snapshot $LXC_NAME $snapname fi diff --git a/lib/tests.sh b/lib/tests.sh index aa78c17..17c35ed 100644 --- a/lib/tests.sh +++ b/lib/tests.sh @@ -83,11 +83,10 @@ _LOAD_SNAPSHOT_OR_INSTALL_APP () { log_warning "Expected to find an existing snapshot $snapname but it doesn't exist yet .. will attempt to create it" LOAD_LXC_SNAPSHOT snap0 \ &&_INSTALL_APP "path=$check_path" \ - && 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_info "(Reusing an existing snapshot $snapname.)" \ && LOAD_LXC_SNAPSHOT $snapname fi } From 8942ceca44ed4dbf4ffe69f0f7a36297ef1a4973 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 19 Dec 2020 02:24:21 +0100 Subject: [PATCH 5/5] Fix check of qualify_for_level_7/8/9 in level computation --- lib/analyze_test_results.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/analyze_test_results.py b/lib/analyze_test_results.py index f70d601..1bec269 100644 --- a/lib/analyze_test_results.py +++ b/lib/analyze_test_results.py @@ -125,7 +125,7 @@ def level_7(tests): return all(t["results"]["main_result"] == "success" for t in tests) \ and linter_tests != [] \ - and "qualify_for_level_7" in linter_tests[0]["results"]["success"] + and "App.qualify_for_level_7" in linter_tests[0]["results"]["success"] @level(8, "Maintained and long-term good quality") @@ -138,7 +138,7 @@ def level_8(tests): linter_tests = [t for t in tests if t["test_type"] == "PACKAGE_LINTER"] return linter_tests != [] \ - and "qualify_for_level_8" in linter_tests[0]["results"]["success"] + and "App.qualify_for_level_8" in linter_tests[0]["results"]["success"] @level(9, "Flagged high-quality in app catalog") @@ -150,7 +150,7 @@ def level_9(tests): linter_tests = [t for t in tests if t["test_type"] == "PACKAGE_LINTER"] return linter_tests != [] \ - and "qualify_for_level_9" in linter_tests[0]["results"]["success"] + and "App.qualify_for_level_9" in linter_tests[0]["results"]["success"] tests = list(load_tests(sys.argv[1]))