diff --git a/lib/common.sh b/lib/common.sh index 931db29..9663a64 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -14,10 +14,11 @@ DIST=${DIST:-buster} # Yunohost version: stable, testing or unstable YNH_BRANCH=${YNH_BRANCH:-stable} +WORKER_ID=${WORKER_ID:-0} LXC_BASE="ynh-appci-$DIST-$ARCH-$YNH_BRANCH-base" -LXC_NAME="ynh-appci-$DIST-$ARCH-$YNH_BRANCH-test" +LXC_NAME="ynh-appci-$DIST-$ARCH-$YNH_BRANCH-test-${WORKER_ID}" -readonly lock_file="./pcheck.lock" +readonly lock_file="./pcheck-${WORKER_ID}.lock" DEFAULT_PHP_VERSION="7.3" [[ "$DIST" == "bullseye" ]] && DEFAULT_PHP_VERSION="7.4" diff --git a/lib/lxc.sh b/lib/lxc.sh index f7b3049..03fcb97 100644 --- a/lib/lxc.sh +++ b/lib/lxc.sh @@ -25,7 +25,12 @@ LXC_CREATE () { else log_critical "Can't find base image $LXC_BASE, run ./package_check.sh --rebuild" fi - [[ "${PIPESTATUS[0]}" -eq 0 ]] || exit 1 + + pipestatus="${PIPESTATUS[0]}" + location=$(lxc list --format json | jq -e --arg LXC_NAME $LXC_NAME '.[] | select(.name==$LXC_NAME) | .location' | tr -d '"') + [[ "$location" != "none" ]] && log_info "... on $location" + + [[ "$pipestatus" -eq 0 ]] || exit 1 _LXC_START_AND_WAIT $LXC_NAME set_witness_files diff --git a/lib/tests.sh b/lib/tests.sh index 267bd4f..7d126ad 100644 --- a/lib/tests.sh +++ b/lib/tests.sh @@ -187,16 +187,18 @@ _VALIDATE_THAT_APP_CAN_BE_ACCESSED () { log_debug "Running curl $check_domain$curl_check_path" # Call cURL to try to access to the URL of the app - curl --location --insecure --silent --show-error \ - --header "Host: $check_domain" \ + LXC_EXEC "curl --location --insecure --silent --show-error \ + --header 'Host: $check_domain' \ --resolve $DOMAIN:80:$LXC_IP \ --resolve $DOMAIN:443:$LXC_IP \ --resolve $SUBDOMAIN:80:$LXC_IP \ --resolve $SUBDOMAIN:443:$LXC_IP \ - --write-out "%{http_code};%{url_effective}\n" \ - --output "$curl_output" \ - $check_domain$curl_check_path \ - > "./curl_print" + --write-out '%{http_code};%{url_effective}\n' \ + --output './curl_output' \ + $check_domain$curl_check_path" \ + > "$TEST_CONTEXT/curl_print" + + LXC_EXEC "cat ./curl_output" > $curl_output # Analyze the result of curl command if [ $? -ne 0 ] @@ -205,7 +207,7 @@ _VALIDATE_THAT_APP_CAN_BE_ACCESSED () { curl_error=1 fi - http_code=$(cat "./curl_print" | cut -d ';' -f1) + http_code=$(cat "$TEST_CONTEXT/curl_print" | cut -d ';' -f1) log_debug "HTTP code: $http_code" @@ -245,7 +247,7 @@ _VALIDATE_THAT_APP_CAN_BE_ACCESSED () { fi echo -e "Test URL: $check_domain$curl_check_path -Real URL: $(cat "./curl_print" | cut --delimiter=';' --fields=2) +Real URL: $(cat "$TEST_CONTEXT/curl_print" | cut --delimiter=';' --fields=2) HTTP code: $http_code Page title: $page_title Page extract:\n$page_extract" > $TEST_CONTEXT/curl_result diff --git a/lib/tests_coordination.sh b/lib/tests_coordination.sh index 1e81022..70d748c 100644 --- a/lib/tests_coordination.sh +++ b/lib/tests_coordination.sh @@ -4,7 +4,7 @@ source lib/lxc.sh source lib/tests.sh source lib/witness.sh -complete_log="./Complete.log" +readonly complete_log="./Complete-${WORKER_ID}.log" # Purge some log files rm -f "$complete_log" && touch "$complete_log" @@ -295,7 +295,7 @@ run_all_tests() { # Print the final results of the tests log_title "Tests summary" - python3 lib/analyze_test_results.py $TEST_CONTEXT 2>./results.json + python3 lib/analyze_test_results.py $TEST_CONTEXT 2> ./results-${WORKER_ID}.json [[ -e "$TEST_CONTEXT/summary.png" ]] && cp "$TEST_CONTEXT/summary.png" ./summary.png || rm -f summary.png # Restore the started time for the timer