Skip to content

Commit 45b4f12

Browse files
committed
feat(scaletest): add greedy agent test to runner
1 parent b83a8ce commit 45b4f12

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed

scaletest/templates/scaletest-runner/main.tf

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,50 @@ data "coder_parameter" "load_scenario_baseline_duration" {
335335
}
336336
}
337337

338+
data "coder_parameter" "greedy_agent" {
339+
order = 30
340+
type = "bool"
341+
name = "Greedy Agent"
342+
default = false
343+
description = "If true, the agent will attempt to consume all available resources."
344+
mutable = true
345+
ephemeral = true
346+
}
347+
348+
data "coder_parameter" "greedy_agent_template" {
349+
order = 31
350+
name = "Greedy Agent Template"
351+
display_name = "Greedy Agent Template"
352+
description = "The template used for the greedy agent workspace (must not be same as workspace template)."
353+
default = "kubernetes-medium"
354+
icon = "/emojis/1f4dc.png" # Scroll.
355+
mutable = true
356+
option {
357+
name = "Minimal"
358+
value = "kubernetes-minimal" # Feather.
359+
icon = "/emojis/1fab6.png"
360+
description = "Sized to fit approx. 32 per t2d-standard-8 instance."
361+
}
362+
option {
363+
name = "Small"
364+
value = "kubernetes-small"
365+
icon = "/emojis/1f42d.png" # Mouse.
366+
description = "Provisions a small-sized workspace with no persistent storage."
367+
}
368+
option {
369+
name = "Medium"
370+
value = "kubernetes-medium"
371+
icon = "/emojis/1f436.png" # Dog.
372+
description = "Provisions a medium-sized workspace with no persistent storage."
373+
}
374+
option {
375+
name = "Large"
376+
value = "kubernetes-large"
377+
icon = "/emojis/1f434.png" # Horse.
378+
description = "Provisions a large-sized workspace with no persistent storage."
379+
}
380+
}
381+
338382
data "coder_parameter" "namespace" {
339383
order = 999
340384
type = "string"
@@ -395,6 +439,8 @@ resource "coder_agent" "main" {
395439
SCALETEST_PARAM_LOAD_SCENARIO_WEB_TERMINAL_TRAFFIC_TICK_INTERVAL : "${data.coder_parameter.load_scenario_web_terminal_tick_interval.value}",
396440
SCALETEST_PARAM_LOAD_SCENARIO_DASHBOARD_TRAFFIC_DURATION : "${data.coder_parameter.load_scenario_dashboard_traffic_duration.value}",
397441
SCALETEST_PARAM_LOAD_SCENARIO_BASELINE_DURATION : "${data.coder_parameter.load_scenario_baseline_duration.value}",
442+
SCALETEST_PARAM_GREEDY_AGENT : data.coder_parameter.greedy_agent.value ? "1" : "0",
443+
SCALETEST_PARAM_GREEDY_AGENT_TEMPLATE : data.coder_parameter.greedy_agent_template.value,
398444

399445
GRAFANA_URL : local.grafana_url,
400446

scaletest/templates/scaletest-runner/scripts/run.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,53 @@ end_phase
2626

2727
wait_baseline "${SCALETEST_PARAM_LOAD_SCENARIO_BASELINE_DURATION}"
2828

29+
if [[ ${SCALETEST_PARAM_GREEDY_AGENT} != 1 ]]; then
30+
greedy_agent() { :; }
31+
else
32+
echo "WARNING: Greedy agent enabled, this may cause the load tests to fail." >&2
33+
34+
coder exp scaletest create-workspaces \
35+
--count 1 \
36+
--template "${SCALETEST_PARAM_GREEDY_AGENT_TEMPLATE}" \
37+
--concurrency 1 \
38+
--timeout 5h \
39+
--job-timeout 5h \
40+
--no-cleanup \
41+
--output json:"${SCALETEST_RESULTS_DIR}/create-workspaces-greedy-agent.json"
42+
43+
greedy_agent() {
44+
local timeout=${1} scenario=${2}
45+
# Run the greedy test for ~1/3 of the timeout.
46+
delay=$((timeout * 60 / 3))
47+
48+
local type=web-terminal
49+
args=()
50+
if [[ ${scenario} == "SSH Traffic" ]]; then
51+
type=ssh
52+
args+=(--ssh)
53+
fi
54+
55+
sleep "${delay}"
56+
annotate_grafana greedy_agent "${scenario}: Greedy agent"
57+
58+
# Produce load at about 1000MB/s.
59+
set +e
60+
coder exp scaletest workspace-traffic \
61+
--template "${SCALETEST_PARAM_GREEDY_AGENT_TEMPLATE}" \
62+
--timeout "$((delay))s" \
63+
--job-timeout "$((delay))s" \
64+
--output json:"${SCALETEST_RESULTS_DIR}/traffic-${type}-greedy-agent.json" \
65+
--bytes-per-tick $((1024 * 1000)) \
66+
--tick-interval 1ms \
67+
"${args[@]}"
68+
status=${?}
69+
70+
annotate_grafana_end greedy_agent "${scenario}: Greedy agent"
71+
72+
return ${status}
73+
}
74+
fi
75+
2976
declare -A failed=()
3077
for scenario in "${SCALETEST_PARAM_LOAD_SCENARIOS[@]}"; do
3178
start_phase "Load scenario: ${scenario}"
@@ -34,24 +81,38 @@ for scenario in "${SCALETEST_PARAM_LOAD_SCENARIOS[@]}"; do
3481
status=0
3582
case "${scenario}" in
3683
"SSH Traffic")
84+
greedy_agent "${SCALETEST_PARAM_LOAD_SCENARIO_SSH_TRAFFIC_DURATION}" "${scenario}" &
3785
coder exp scaletest workspace-traffic \
86+
--template "${SCALETEST_PARAM_TEMPLATE}" \
3887
--ssh \
3988
--bytes-per-tick "${SCALETEST_PARAM_LOAD_SCENARIO_SSH_TRAFFIC_BYTES_PER_TICK}" \
4089
--tick-interval "${SCALETEST_PARAM_LOAD_SCENARIO_SSH_TRAFFIC_TICK_INTERVAL}ms" \
4190
--timeout "${SCALETEST_PARAM_LOAD_SCENARIO_SSH_TRAFFIC_DURATION}m" \
4291
--job-timeout "${SCALETEST_PARAM_LOAD_SCENARIO_SSH_TRAFFIC_DURATION}m30s" \
4392
--output json:"${SCALETEST_RESULTS_DIR}/traffic-ssh.json"
4493
status=$?
94+
wait
95+
status2=$?
96+
if [[ ${status} == 0 ]]; then
97+
status=${status2}
98+
fi
4599
show_json "${SCALETEST_RESULTS_DIR}/traffic-ssh.json"
46100
;;
47101
"Web Terminal Traffic")
102+
greedy_agent "${SCALETEST_PARAM_LOAD_SCENARIO_WEB_TERMINAL_TRAFFIC_DURATION}" "${scenario}" &
48103
coder exp scaletest workspace-traffic \
104+
--template "${SCALETEST_PARAM_TEMPLATE}" \
49105
--bytes-per-tick "${SCALETEST_PARAM_LOAD_SCENARIO_WEB_TERMINAL_TRAFFIC_BYTES_PER_TICK}" \
50106
--tick-interval "${SCALETEST_PARAM_LOAD_SCENARIO_WEB_TERMINAL_TRAFFIC_TICK_INTERVAL}ms" \
51107
--timeout "${SCALETEST_PARAM_LOAD_SCENARIO_WEB_TERMINAL_TRAFFIC_DURATION}m" \
52108
--job-timeout "${SCALETEST_PARAM_LOAD_SCENARIO_WEB_TERMINAL_TRAFFIC_DURATION}m30s" \
53109
--output json:"${SCALETEST_RESULTS_DIR}/traffic-web-terminal.json"
54110
status=$?
111+
wait
112+
status2=$?
113+
if [[ ${status} == 0 ]]; then
114+
status=${status2}
115+
fi
55116
show_json "${SCALETEST_RESULTS_DIR}/traffic-web-terminal.json"
56117
;;
57118
"Dashboard Traffic")
@@ -65,6 +126,10 @@ for scenario in "${SCALETEST_PARAM_LOAD_SCENARIOS[@]}"; do
65126
;;
66127

67128
# Debug scenarios, for testing the runner.
129+
"debug:greedy_agent")
130+
greedy_agent 10 "${scenario}"
131+
status=$?
132+
;;
68133
"debug:success")
69134
maybedryrun "$DRY_RUN" sleep 10
70135
status=0

scaletest/templates/scaletest-runner/startup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ set -euo pipefail
33

44
[[ $VERBOSE == 1 ]] && set -x
55

6+
if [[ ${SCALETEST_PARAM_GREEDY_AGENT_TEMPLATE} == "${SCALETEST_PARAM_TEMPLATE}" ]]; then
7+
echo "ERROR: Greedy agent template must be different from the scaletest template." >&2
8+
exit 1
9+
fi
10+
611
# Unzip scripts and add to path.
712
# shellcheck disable=SC2153
813
echo "Extracting scaletest scripts into ${SCRIPTS_DIR}..."

0 commit comments

Comments
 (0)