From 2eb1fac27047b4a655021c9646ac51d584590482 Mon Sep 17 00:00:00 2001 From: petechd <53475968+petechd@users.noreply.github.com> Date: Tue, 15 Oct 2024 09:58:03 +0100 Subject: [PATCH] Add parallel runs for schemas validator (#1501) --- scripts/validate_test_schemas.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/validate_test_schemas.sh b/scripts/validate_test_schemas.sh index fc3a0b4f2f..e585590bc6 100755 --- a/scripts/validate_test_schemas.sh +++ b/scripts/validate_test_schemas.sh @@ -5,6 +5,9 @@ red="$(tput setaf 1)" default="$(tput sgr0)" checks=4 + + + until [ "$checks" == 0 ]; do response="$(curl -so /dev/null -w '%{http_code}' http://localhost:5002/status)" @@ -39,8 +42,8 @@ passed=0 file_path_name=$(find "$file_path" -name '*.json') -for schema in ${file_path_name}; do - +validate() { + schema=$1 result="$(curl -s -w 'HTTPSTATUS:%{http_code}' -X POST -H "Content-Type: application/json" -d @"$schema" http://localhost:5001/validate | tr -d '\n')" # shellcheck disable=SC2001 HTTP_BODY=$(echo "${result}" | sed -e 's/HTTPSTATUS\:.*//g') @@ -57,9 +60,17 @@ for schema in ${file_path_name}; do (( failed++ )) exit=1 fi +} + +N_TIMES_IN_PARALLEL=20 + +for schema in ${file_path_name}; do + ((i=i%N_TIMES_IN_PARALLEL)); ((i++==0)) && wait +# Spawn multiple (N_TIMES_IN_PARALLEL) processes in subshells and send to background, but keep printing outputs. + validate "$schema" & done -echo -e "\\n${green}$passed Passed${default} - ${red}$failed Failed${default}" -exit "$exit" \ No newline at end of file + +exit "$exit"