From 803fb7fe0e7a85b0f1e39528857e5e8285b7a28b Mon Sep 17 00:00:00 2001 From: 552020 Date: Thu, 23 May 2024 10:45:21 +0200 Subject: [PATCH] tests(parallel_cgi): fix tests not failing if test if failing We had to change the way the error is checked - we write the error in a file cause for the async nature of the operation the error variable was not correctly read --- tests/parallel_cgi/duration_ts.sh | 9 +++++++-- var/www.development_site/cgi-bin/duration_ts.cgi | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/parallel_cgi/duration_ts.sh b/tests/parallel_cgi/duration_ts.sh index 93f83400..0279e322 100755 --- a/tests/parallel_cgi/duration_ts.sh +++ b/tests/parallel_cgi/duration_ts.sh @@ -4,6 +4,7 @@ is_error=false URL="http://127.0.0.1:8080/cgi-bin/duration_ts.cgi" temp_file=$(mktemp) +error_file=$(mktemp) # Send requests and collect the times for i in {1..3}; do @@ -18,7 +19,8 @@ for i in {1..3}; do echo "$end_time Request $i: End time = $end_time" >> "$temp_file" else echo "Failed to parse timestamps from request $i response" - is_error=true + echo "error" >> "$error_file" + fi } & done @@ -34,8 +36,11 @@ done # Clean up temporary file rm "$temp_file" -if [ "$is_error" = true ]; then +# Check if there were any errors +if [ -s "$error_file" ]; then + rm "$error_file" exit 1 fi +rm "$error_file" exit 0 diff --git a/var/www.development_site/cgi-bin/duration_ts.cgi b/var/www.development_site/cgi-bin/duration_ts.cgi index 8573dee7..8d0fd414 100755 --- a/var/www.development_site/cgi-bin/duration_ts.cgi +++ b/var/www.development_site/cgi-bin/duration_ts.cgi @@ -4,7 +4,7 @@ import time from datetime import datetime # Define the duration of the counter in seconds -duration = 2 +duration = 8 # Print the HTTP header print("Content-Type: text/html")