Skip to content

Commit

Permalink
Limit E2E test parallelism
Browse files Browse the repository at this point in the history
The current Github runner is low on resources, so running many E2E tests
can make tests more flaky then necessary. For now, it seems, we need to
leave with this.
  • Loading branch information
inancgumus committed Aug 31, 2023
1 parent 8878ebf commit 242a5a0
Showing 1 changed file with 40 additions and 9 deletions.
49 changes: 40 additions & 9 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,57 @@ jobs:
export K6_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome
fi
export K6_BROWSER_HEADLESS=true
# run only two E2E tests in parallel
# the current runner is low on resources
max_concurrent_jobs=2
current_jobs=0
declare -a pids
declare -a output_files
launch_job() {
local f="$1"
local output_file="output_$(basename "$f" .js).txt"
output_files+=("$output_file")
# Run the test in the background
./k6extension run "$f" > "$output_file" 2>&1 &
local pid=$!
pids+=($pid)
current_jobs=$((current_jobs + 1))
}
for f in examples/*.js; do
if [ "$f" == "examples/hosts.js" ] && [ "$RUNNER_OS" == "Windows" ]; then
echo "skipping $f on Windows"
continue
fi
output_file="output_$(basename "$f" .js).txt"
output_files+=("$output_file")
./k6extension run -q "$f" > "$output_file" 2>&1 &
pids+=($!)
launch_job "$f"
# If we've reached the maximum number of concurrent jobs, wait for one to finish
if [ "$current_jobs" -ge "$max_concurrent_jobs" ]; then
wait "${pids[0]}"
unset "pids[0]"
pids=("${pids[@]}")
current_jobs=$((current_jobs - 1))
fi
done
# Wait for each background job to finish and display its output
for i in "${!pids[@]}"; do
wait "${pids[$i]}"
echo "Output for job ${pids[$i]} (from file ${output_files[$i]}):"
cat "${output_files[$i]}"
# Wait for all remaining jobs to finish
for pid in "${pids[@]}"; do
wait "$pid"
done
# Output the results
for output_file in "${output_files[@]}"; do
echo "Output from file $output_file:"
cat "$output_file"
done
- name: Check screenshot
if: matrix.go != 'tip' || matrix.platform != 'windows-latest'
# TODO: Do something more sophisticated?
Expand Down

0 comments on commit 242a5a0

Please sign in to comment.