mirror of
https://github.com/apple/swift-nio
synced 2026-11-22 04:30:41 +00:00
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
This commit is contained in:
1 parent
8f6f8361ff
commit
eb22dafade
3 files changed
+31
-4
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
Reference in new issue
Block a user