From eb22dafade5a54a2ea6f63d2a3627a75cacf00c7 Mon Sep 17 00:00:00 2001 From: Rick Newton-Rogers Date: Tue, 24 Feb 2026 17:41:28 +0000 Subject: [PATCH] Add parallel execution mode for integration tests Motivation: Integration tests regularly take 21m in CI; they're the long pole. Modifications: * Allocation count tests are now run in parallel if `NIO_ALLOC_COUNTER_TESTS_PARALLEL` is `true`, tests in a given file are still in serial. * Test output is catted to different files and recovered and printed in the order in which the tests were started. Result: Integration test execution goes from 21m to 10m --- .github/workflows/main.yml | 1 + .github/workflows/pull_request.yml | 1 + .../run-allocation-counter.sh | 33 ++++++++++++++++--- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1667f395e..014f39251 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,6 +49,7 @@ jobs: env: MATRIX_LINUX_SETUP_COMMAND: "apt-get update -y -q && apt-get install -y -q lsof dnsutils netcat-openbsd net-tools curl jq" MATRIX_LINUX_COMMAND: "./scripts/integration_tests.sh" + MATRIX_LINUX_ENV_VARS_JSON: '{"NIO_ALLOC_COUNTER_TESTS_PARALLEL": "true"}' integration-tests: name: Integration tests diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 8684bf8fe..00fc70c44 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -55,6 +55,7 @@ jobs: env: MATRIX_LINUX_SETUP_COMMAND: "apt-get update -y -q && apt-get install -y -q lsof dnsutils netcat-openbsd net-tools curl jq" MATRIX_LINUX_COMMAND: "./scripts/integration_tests.sh" + MATRIX_LINUX_ENV_VARS_JSON: '{"NIO_ALLOC_COUNTER_TESTS_PARALLEL": "true"}' integration-tests: name: Integration tests diff --git a/IntegrationTests/allocation-counter-tests-framework/run-allocation-counter.sh b/IntegrationTests/allocation-counter-tests-framework/run-allocation-counter.sh index 6d52c7c0d..97b771ea2 100755 --- a/IntegrationTests/allocation-counter-tests-framework/run-allocation-counter.sh +++ b/IntegrationTests/allocation-counter-tests-framework/run-allocation-counter.sh @@ -289,8 +289,33 @@ build_package \ set -eu cd "$working_dir" swift build "${build_opts[@]}" -for f in "${files[@]}"; do - echo "- $f" - swift run "${build_opts[@]}" "$(module_name_from_path "$f")" -done +bin_path=$(swift build "${build_opts[@]}" --show-bin-path) +if [[ "${NIO_ALLOC_COUNTER_TESTS_PARALLEL:-false}" == "true" ]]; then + out_dir=$(mktemp -d) + trap 'rm -rf "$out_dir"' EXIT + pids=() + for f in "${files[@]}"; do + module=$(module_name_from_path "$f") + "$bin_path/$module" > "$out_dir/$module" & + pids+=($!) + done + all_ok=true + for i in "${!pids[@]}"; do + module=$(module_name_from_path "${files[$i]}") + if wait "${pids[$i]}"; then + echo "- ${files[$i]}" + cat "$out_dir/$module" + else + all_ok=false + echo "- ${files[$i]} FAILED" >&2 + cat "$out_dir/$module" >&2 + fi + done + "$all_ok" +else + for f in "${files[@]}"; do + echo "- $f" + "$bin_path/$(module_name_from_path "$f")" + done +fi )