Skip to content

feat(scaletest/templates): add support for concurrent scenarios #11753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
minor cleanup
  • Loading branch information
mafredri committed Jan 30, 2024
commit 23d936e2927e371e65fcebb3f0ddb52c6cbdf35d
35 changes: 17 additions & 18 deletions scaletest/templates/scaletest-runner/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,10 @@ else
fi
annotate_grafana_end greedy_agent "${scenario}: Greedy agent traffic"

return ${status}
return "${status}"
}
fi

if [[ ${SCALETEST_PARAM_LOAD_SCENARIO_RUN_CONCURRENTLY} == 1 ]]; then
start_phase "Load scenarios: ${SCALETEST_PARAM_LOAD_SCENARIOS[*]}"
fi

run_scenario_cmd() {
local scenario=${1}
shift
Expand Down Expand Up @@ -127,6 +123,9 @@ declare -A failed=()
target_start=0
target_end=-1

if [[ ${SCALETEST_PARAM_LOAD_SCENARIO_RUN_CONCURRENTLY} == 1 ]]; then
start_phase "Load scenarios: ${SCALETEST_PARAM_LOAD_SCENARIOS[*]}"
fi
for scenario in "${SCALETEST_PARAM_LOAD_SCENARIOS[@]}"; do
if [[ ${SCALETEST_PARAM_LOAD_SCENARIO_RUN_CONCURRENTLY} == 0 ]]; then
start_phase "Load scenario: ${scenario}"
Expand Down Expand Up @@ -320,24 +319,24 @@ for scenario in "${SCALETEST_PARAM_LOAD_SCENARIOS[@]}"; do
# scenario is run concurrently and all percentages add up to 100.
target_start=${target_end}

if [[ ${SCALETEST_PARAM_LOAD_SCENARIO_RUN_CONCURRENTLY} == 0 ]]; then
if ((status > 0)); then
log "Load scenario failed: ${scenario} (exit=${status})"
failed+=(["${scenario}"]="$status")
PHASE_ADD_TAGS=error end_phase
else
end_phase
fi

wait_baseline "${SCALETEST_PARAM_LOAD_SCENARIO_BASELINE_DURATION}"
else
if [[ ${SCALETEST_PARAM_LOAD_SCENARIO_RUN_CONCURRENTLY} == 1 ]]; then
pid_to_scenario+=(["${pids[-1]}"]="${scenario}")
# Stagger the start of each scenario to avoid a burst of load and deted
# problematic scenarios.
sleep $((SCALETEST_PARAM_LOAD_SCENARIO_CONCURRENCY_STAGGERING * 60))
continue
fi
done

if ((status > 0)); then
log "Load scenario failed: ${scenario} (exit=${status})"
failed+=(["${scenario}"]="${status}")
PHASE_ADD_TAGS=error end_phase
else
end_phase
fi

wait_baseline "${SCALETEST_PARAM_LOAD_SCENARIO_BASELINE_DURATION}"
done
if [[ ${SCALETEST_PARAM_LOAD_SCENARIO_RUN_CONCURRENTLY} == 1 ]]; then
wait "${pids[@]}"
# Wait on all pids will wait until all have exited, but we need to
Expand All @@ -348,7 +347,7 @@ if [[ ${SCALETEST_PARAM_LOAD_SCENARIO_RUN_CONCURRENTLY} == 1 ]]; then
scenario=${pid_to_scenario[${pid}]}
if ((status > 0)); then
log "Load scenario failed: ${scenario} (exit=${status})"
failed+=(["${scenario}"]="$status")
failed+=(["${scenario}"]="${status}")
fi
done
if ((${#failed[@]} > 0)); then
Expand Down