Skip to content

Commit 036aa8d

Browse files
committed
feat(scaletest/templates): add support for concurrent scenarios
1 parent 15a90f0 commit 036aa8d

File tree

3 files changed

+317
-45
lines changed

3 files changed

+317
-45
lines changed

scaletest/templates/scaletest-runner/main.tf

Lines changed: 152 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,22 @@ data "coder_parameter" "load_scenarios" {
237237
default = jsonencode([
238238
"SSH Traffic",
239239
"Web Terminal Traffic",
240+
"App Traffic",
240241
"Dashboard Traffic",
241242
])
242243
}
243244

244-
data "coder_parameter" "load_scenario_ssh_traffic_duration" {
245+
data "coder_parameter" "load_scenario_run_concurrently" {
245246
order = 23
247+
name = "Run Load Scenarios Concurrently"
248+
type = "bool"
249+
default = false
250+
description = "Run all load scenarios concurrently, this setting enables the load scenario percentages so that they can be assigned a percentage of 1-100%."
251+
mutable = true
252+
}
253+
254+
data "coder_parameter" "load_scenario_ssh_traffic_duration" {
255+
order = 30
246256
name = "SSH Traffic Duration"
247257
type = "number"
248258
description = "The duration of the SSH traffic load scenario in minutes."
@@ -255,7 +265,7 @@ data "coder_parameter" "load_scenario_ssh_traffic_duration" {
255265
}
256266

257267
data "coder_parameter" "load_scenario_ssh_bytes_per_tick" {
258-
order = 24
268+
order = 31
259269
name = "SSH Bytes Per Tick"
260270
type = "number"
261271
description = "The number of bytes to send per tick in the SSH traffic load scenario."
@@ -267,7 +277,7 @@ data "coder_parameter" "load_scenario_ssh_bytes_per_tick" {
267277
}
268278

269279
data "coder_parameter" "load_scenario_ssh_tick_interval" {
270-
order = 25
280+
order = 32
271281
name = "SSH Tick Interval"
272282
type = "number"
273283
description = "The number of milliseconds between each tick in the SSH traffic load scenario."
@@ -278,8 +288,21 @@ data "coder_parameter" "load_scenario_ssh_tick_interval" {
278288
}
279289
}
280290

291+
data "coder_parameter" "load_scenario_ssh_traffic_percentage" {
292+
order = 33
293+
name = "SSH Traffic Percentage"
294+
type = "number"
295+
description = "The percentage of workspaces that should be targeted for SSH traffic."
296+
mutable = true
297+
default = 100
298+
validation {
299+
min = 1
300+
max = 100
301+
}
302+
}
303+
281304
data "coder_parameter" "load_scenario_web_terminal_traffic_duration" {
282-
order = 26
305+
order = 40
283306
name = "Web Terminal Traffic Duration"
284307
type = "number"
285308
description = "The duration of the web terminal traffic load scenario in minutes."
@@ -292,7 +315,7 @@ data "coder_parameter" "load_scenario_web_terminal_traffic_duration" {
292315
}
293316

294317
data "coder_parameter" "load_scenario_web_terminal_bytes_per_tick" {
295-
order = 27
318+
order = 41
296319
name = "Web Terminal Bytes Per Tick"
297320
type = "number"
298321
description = "The number of bytes to send per tick in the web terminal traffic load scenario."
@@ -304,7 +327,7 @@ data "coder_parameter" "load_scenario_web_terminal_bytes_per_tick" {
304327
}
305328

306329
data "coder_parameter" "load_scenario_web_terminal_tick_interval" {
307-
order = 28
330+
order = 42
308331
name = "Web Terminal Tick Interval"
309332
type = "number"
310333
description = "The number of milliseconds between each tick in the web terminal traffic load scenario."
@@ -315,8 +338,94 @@ data "coder_parameter" "load_scenario_web_terminal_tick_interval" {
315338
}
316339
}
317340

341+
data "coder_parameter" "load_scenario_web_terminal_traffic_percentage" {
342+
order = 43
343+
name = "Web Terminal Traffic Percentage"
344+
type = "number"
345+
description = "The percentage of workspaces that should be targeted for web terminal traffic."
346+
mutable = true
347+
default = 100
348+
validation {
349+
min = 1
350+
max = 100
351+
}
352+
}
353+
354+
data "coder_parameter" "load_scenario_app_traffic_duration" {
355+
order = 50
356+
name = "App Traffic Duration"
357+
type = "number"
358+
description = "The duration of the app traffic load scenario in minutes."
359+
mutable = true
360+
default = 30
361+
validation {
362+
min = 1
363+
max = 1440 // 24 hours.
364+
}
365+
}
366+
367+
data "coder_parameter" "load_scenario_app_bytes_per_tick" {
368+
order = 51
369+
name = "App Bytes Per Tick"
370+
type = "number"
371+
description = "The number of bytes to send per tick in the app traffic load scenario."
372+
mutable = true
373+
default = 1024
374+
validation {
375+
min = 1
376+
}
377+
}
378+
379+
data "coder_parameter" "load_scenario_app_tick_interval" {
380+
order = 52
381+
name = "App Tick Interval"
382+
type = "number"
383+
description = "The number of milliseconds between each tick in the app traffic load scenario."
384+
mutable = true
385+
default = 100
386+
validation {
387+
min = 1
388+
}
389+
}
390+
391+
data "coder_parameter" "load_scenario_app_traffic_percentage" {
392+
order = 53
393+
name = "App Traffic Percentage"
394+
type = "number"
395+
description = "The percentage of workspaces that should be targeted for app traffic."
396+
mutable = true
397+
default = 100
398+
validation {
399+
min = 1
400+
max = 100
401+
}
402+
}
403+
404+
data "coder_parameter" "load_scenario_app_traffic_mode" {
405+
order = 54
406+
name = "App Traffic Mode"
407+
default = "wsec"
408+
description = "The mode of the app traffic load scenario."
409+
mutable = true
410+
option {
411+
name = "WebSocket Echo"
412+
value = "wsec"
413+
description = "Send traffic to the workspace via the app websocket and read it back."
414+
}
415+
option {
416+
name = "WebSocket Read (Random)"
417+
value = "wsra"
418+
description = "Read traffic from the workspace via the app websocket."
419+
}
420+
option {
421+
name = "WebSocket Write (Discard)"
422+
value = "wsdi"
423+
description = "Send traffic to the workspace via the app websocket."
424+
}
425+
}
426+
318427
data "coder_parameter" "load_scenario_dashboard_traffic_duration" {
319-
order = 29
428+
order = 60
320429
name = "Dashboard Traffic Duration"
321430
type = "number"
322431
description = "The duration of the dashboard traffic load scenario in minutes."
@@ -328,8 +437,21 @@ data "coder_parameter" "load_scenario_dashboard_traffic_duration" {
328437
}
329438
}
330439

440+
data "coder_parameter" "load_scenario_dashboard_traffic_percentage" {
441+
order = 61
442+
name = "Dashboard Traffic Percentage"
443+
type = "number"
444+
description = "The percentage of users that should be targeted for dashboard traffic."
445+
mutable = true
446+
default = 100
447+
validation {
448+
min = 1
449+
max = 100
450+
}
451+
}
452+
331453
data "coder_parameter" "load_scenario_baseline_duration" {
332-
order = 26
454+
order = 100
333455
name = "Baseline Wait Duration"
334456
type = "number"
335457
description = "The duration to wait before starting a load scenario in minutes."
@@ -342,7 +464,7 @@ data "coder_parameter" "load_scenario_baseline_duration" {
342464
}
343465

344466
data "coder_parameter" "greedy_agent" {
345-
order = 30
467+
order = 200
346468
type = "bool"
347469
name = "Greedy Agent"
348470
default = false
@@ -352,7 +474,7 @@ data "coder_parameter" "greedy_agent" {
352474
}
353475

354476
data "coder_parameter" "greedy_agent_template" {
355-
order = 31
477+
order = 201
356478
name = "Greedy Agent Template"
357479
display_name = "Greedy Agent Template"
358480
description = "The template used for the greedy agent workspace (must not be same as workspace template)."
@@ -432,6 +554,7 @@ resource "coder_agent" "main" {
432554
SCALETEST_RUN_ID : local.scaletest_run_id,
433555
SCALETEST_RUN_DIR : local.scaletest_run_dir,
434556
SCALETEST_RUN_START_TIME : local.scaletest_run_start_time,
557+
SCALETEST_PROMETHEUS_START_PORT : "21112",
435558

436559
# Comment is a scaletest param, but we want to surface it separately from
437560
# the rest, so we use a different name.
@@ -443,13 +566,22 @@ resource "coder_agent" "main" {
443566
SCALETEST_PARAM_CREATE_CONCURRENCY : "${data.coder_parameter.create_concurrency.value}",
444567
SCALETEST_PARAM_CLEANUP_STRATEGY : data.coder_parameter.cleanup_strategy.value,
445568
SCALETEST_PARAM_LOAD_SCENARIOS : data.coder_parameter.load_scenarios.value,
569+
SCALETEST_PARAM_LOAD_SCENARIO_RUN_CONCURRENTLY : data.coder_parameter.load_scenario_run_concurrently.value ? "1" : "0",
446570
SCALETEST_PARAM_LOAD_SCENARIO_SSH_TRAFFIC_DURATION : "${data.coder_parameter.load_scenario_ssh_traffic_duration.value}",
447571
SCALETEST_PARAM_LOAD_SCENARIO_SSH_TRAFFIC_BYTES_PER_TICK : "${data.coder_parameter.load_scenario_ssh_bytes_per_tick.value}",
448572
SCALETEST_PARAM_LOAD_SCENARIO_SSH_TRAFFIC_TICK_INTERVAL : "${data.coder_parameter.load_scenario_ssh_tick_interval.value}",
573+
SCALETEST_PARAM_LOAD_SCENARIO_SSH_TRAFFIC_PERCENTAGE : "${data.coder_parameter.load_scenario_ssh_traffic_percentage.value}",
449574
SCALETEST_PARAM_LOAD_SCENARIO_WEB_TERMINAL_TRAFFIC_DURATION : "${data.coder_parameter.load_scenario_web_terminal_traffic_duration.value}",
450575
SCALETEST_PARAM_LOAD_SCENARIO_WEB_TERMINAL_TRAFFIC_BYTES_PER_TICK : "${data.coder_parameter.load_scenario_web_terminal_bytes_per_tick.value}",
451576
SCALETEST_PARAM_LOAD_SCENARIO_WEB_TERMINAL_TRAFFIC_TICK_INTERVAL : "${data.coder_parameter.load_scenario_web_terminal_tick_interval.value}",
577+
SCALETEST_PARAM_LOAD_SCENARIO_WEB_TERMINAL_TRAFFIC_PERCENTAGE : "${data.coder_parameter.load_scenario_web_terminal_traffic_percentage.value}",
578+
SCALETEST_PARAM_LOAD_SCENARIO_APP_TRAFFIC_DURATION : "${data.coder_parameter.load_scenario_app_traffic_duration.value}",
579+
SCALETEST_PARAM_LOAD_SCENARIO_APP_TRAFFIC_BYTES_PER_TICK : "${data.coder_parameter.load_scenario_app_bytes_per_tick.value}",
580+
SCALETEST_PARAM_LOAD_SCENARIO_APP_TRAFFIC_TICK_INTERVAL : "${data.coder_parameter.load_scenario_app_tick_interval.value}",
581+
SCALETEST_PARAM_LOAD_SCENARIO_APP_TRAFFIC_PERCENTAGE : "${data.coder_parameter.load_scenario_app_traffic_percentage.value}",
582+
SCALETEST_PARAM_LOAD_SCENARIO_APP_TRAFFIC_MODE : data.coder_parameter.load_scenario_app_traffic_mode.value,
452583
SCALETEST_PARAM_LOAD_SCENARIO_DASHBOARD_TRAFFIC_DURATION : "${data.coder_parameter.load_scenario_dashboard_traffic_duration.value}",
584+
SCALETEST_PARAM_LOAD_SCENARIO_DASHBOARD_TRAFFIC_PERCENTAGE : "${data.coder_parameter.load_scenario_dashboard_traffic_percentage.value}",
453585
SCALETEST_PARAM_LOAD_SCENARIO_BASELINE_DURATION : "${data.coder_parameter.load_scenario_baseline_duration.value}",
454586
SCALETEST_PARAM_GREEDY_AGENT : data.coder_parameter.greedy_agent.value ? "1" : "0",
455587
SCALETEST_PARAM_GREEDY_AGENT_TEMPLATE : data.coder_parameter.greedy_agent_template.value,
@@ -709,10 +841,14 @@ resource "kubernetes_pod" "main" {
709841
name = "home"
710842
read_only = false
711843
}
712-
port {
713-
container_port = 21112
714-
name = "prometheus-http"
715-
protocol = "TCP"
844+
dynamic "port" {
845+
for_each = data.coder_parameter.load_scenario_run_concurrently.value ? jsondecode(data.coder_parameter.load_scenarios.value) : [""]
846+
iterator = it
847+
content {
848+
container_port = 21112 + it.key
849+
name = "prom-http${it.key}"
850+
protocol = "TCP"
851+
}
716852
}
717853
}
718854

@@ -787,8 +923,8 @@ resource "kubernetes_manifest" "pod_monitor" {
787923
}
788924
}
789925
podMetricsEndpoints = [
790-
{
791-
port = "prometheus-http"
926+
for i, _ in data.coder_parameter.load_scenario_run_concurrently.value ? jsondecode(data.coder_parameter.load_scenarios.value) : [""] : {
927+
port = "prom-http${i}"
792928
interval = "15s"
793929
}
794930
]

0 commit comments

Comments
 (0)