@@ -117,6 +117,8 @@ system_test_script="${PROJECT_ROOT}/.kokoro/system-single.sh"
117117packages_with_system_tests_pattern=$( printf " |*%s*" " ${packages_with_system_tests[@]} " )
118118packages_with_system_tests_pattern=" ${packages_with_system_tests_pattern: 1} " # Remove the leading pipe
119119
120+ declare -A pids
121+
120122# Run system tests for each package with directory packages/*/tests/system
121123for path in ` find ' packages' \
122124 \( -type d -wholename ' packages/*/tests/system' \) -o \
@@ -141,11 +143,30 @@ for path in `find 'packages' \
141143 package_modified=$( git diff " ${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH} ...${KOKORO_GITHUB_PULL_REQUEST_COMMIT} " -- ${files_to_check} | wc -l)
142144 set -e
143145
144- if [[ " ${package_modified} " -gt 0 || " $KOKORO_BUILD_ARTIFACTS_SUBDIR " == * " continuous" * ]]; then
145- # Call the function - its internal exports won't affect the next loop
146- run_package_test " $package_name " || RETVAL=$?
146+ if [[ " ${package_modified} " -gt 0 || " $KOKORO_BUILD_ARTIFACTS_SUBDIR " == * " continuous" * ]]; then
147+ echo " >>> Dispatching ${package_name} in the background <<<"
148+
149+ # Execute inside an isolated subshell ( ) to prevent GCP credential collisions
150+ (
151+ run_package_test " $package_name "
152+ ) &
153+
154+ # Capture the PID of the subshell
155+ pids[" $package_name " ]=$!
147156 else
148157 echo " No changes in ${package_name} and not a continuous build, skipping."
149158 fi
150159done
151- exit ${RETVAL}
160+
161+ echo " ============================================================"
162+ echo " Waiting for all concurrent system tests to complete..."
163+ echo " ============================================================"
164+
165+ for package in " ${! pids[@]} " ; do
166+ wait ${pids[$package]} || {
167+ echo " ERROR: System tests failed for $package "
168+ RETVAL=1
169+ }
170+ done
171+
172+ exit ${RETVAL}
0 commit comments