@@ -12,11 +12,12 @@ terraform {
12
12
}
13
13
14
14
resource "time_static" "start_time" {
15
- # We con 't set `count = data.coder_workspace.me.start_count` here because then
16
- # we can't use this value in `locals`. The permission check is recreated on
17
- # start, which will update the timestamp .
15
+ # We don 't set `count = data.coder_workspace.me.start_count` here because then
16
+ # we can't use this value in `locals`, but we want to trigger recreation when
17
+ # the scaletest is restarted .
18
18
triggers = {
19
- count : length (null_resource. permission_check )
19
+ count : data.coder_workspace.me.start_count
20
+ token : data.coder_workspace.me.owner_session_token # Rely on this being re-generated every start.
20
21
}
21
22
}
22
23
@@ -39,8 +40,6 @@ locals {
39
40
workspace_pod_instance = " coder-workspace-${ lower (data. coder_workspace . me . owner )} -${ lower (data. coder_workspace . me . name )} "
40
41
workspace_pod_termination_grace_period_seconds = 5 * 60 * 60 # 5 hours (cleanup timeout).
41
42
service_account_name = " scaletest-sa"
42
- cpu = 16
43
- memory = 64
44
43
home_disk_size = 10
45
44
scaletest_run_id = " scaletest-${ replace (time_static. start_time . rfc3339 , " :" , " -" )} "
46
45
scaletest_run_dir = " /home/coder/${ local . scaletest_run_id } "
@@ -171,6 +170,16 @@ data "coder_parameter" "cleanup_strategy" {
171
170
}
172
171
}
173
172
173
+ data "coder_parameter" "cleanup_prepare" {
174
+ order = 14
175
+ type = " bool"
176
+ name = " Cleanup before scaletest"
177
+ default = true
178
+ description = " Cleanup existing scaletest users and workspaces before the scaletest starts (prepare phase)."
179
+ mutable = true
180
+ ephemeral = true
181
+ }
182
+
174
183
175
184
data "coder_parameter" "workspace_template" {
176
185
order = 20
@@ -226,9 +235,18 @@ data "coder_parameter" "num_workspaces" {
226
235
}
227
236
}
228
237
238
+ data "coder_parameter" "skip_create_workspaces" {
239
+ order = 22
240
+ type = " bool"
241
+ name = " DEBUG: Skip creating workspaces"
242
+ default = false
243
+ description = " Skip creating workspaces (for resuming failed scaletests or debugging)"
244
+ mutable = true
245
+ }
246
+
229
247
230
248
data "coder_parameter" "load_scenarios" {
231
- order = 22
249
+ order = 23
232
250
name = " Load Scenarios"
233
251
type = " list(string)"
234
252
description = " The load scenarios to run."
@@ -237,12 +255,31 @@ data "coder_parameter" "load_scenarios" {
237
255
default = jsonencode ([
238
256
" SSH Traffic" ,
239
257
" Web Terminal Traffic" ,
258
+ " App Traffic" ,
240
259
" Dashboard Traffic" ,
241
260
])
242
261
}
243
262
263
+ data "coder_parameter" "load_scenario_run_concurrently" {
264
+ order = 24
265
+ name = " Run Load Scenarios Concurrently"
266
+ type = " bool"
267
+ default = false
268
+ description = " Run all load scenarios concurrently, this setting enables the load scenario percentages so that they can be assigned a percentage of 1-100%."
269
+ mutable = true
270
+ }
271
+
272
+ data "coder_parameter" "load_scenario_concurrency_stagger_delay_mins" {
273
+ order = 25
274
+ name = " Load Scenario Concurrency Stagger Delay"
275
+ type = " number"
276
+ default = 3
277
+ description = " The number of minutes to wait between starting each load scenario when run concurrently."
278
+ mutable = true
279
+ }
280
+
244
281
data "coder_parameter" "load_scenario_ssh_traffic_duration" {
245
- order = 23
282
+ order = 30
246
283
name = " SSH Traffic Duration"
247
284
type = " number"
248
285
description = " The duration of the SSH traffic load scenario in minutes."
@@ -255,7 +292,7 @@ data "coder_parameter" "load_scenario_ssh_traffic_duration" {
255
292
}
256
293
257
294
data "coder_parameter" "load_scenario_ssh_bytes_per_tick" {
258
- order = 24
295
+ order = 31
259
296
name = " SSH Bytes Per Tick"
260
297
type = " number"
261
298
description = " The number of bytes to send per tick in the SSH traffic load scenario."
@@ -267,7 +304,7 @@ data "coder_parameter" "load_scenario_ssh_bytes_per_tick" {
267
304
}
268
305
269
306
data "coder_parameter" "load_scenario_ssh_tick_interval" {
270
- order = 25
307
+ order = 32
271
308
name = " SSH Tick Interval"
272
309
type = " number"
273
310
description = " The number of milliseconds between each tick in the SSH traffic load scenario."
@@ -278,8 +315,21 @@ data "coder_parameter" "load_scenario_ssh_tick_interval" {
278
315
}
279
316
}
280
317
318
+ data "coder_parameter" "load_scenario_ssh_traffic_percentage" {
319
+ order = 33
320
+ name = " SSH Traffic Percentage"
321
+ type = " number"
322
+ description = " The percentage of workspaces that should be targeted for SSH traffic."
323
+ mutable = true
324
+ default = 100
325
+ validation {
326
+ min = 1
327
+ max = 100
328
+ }
329
+ }
330
+
281
331
data "coder_parameter" "load_scenario_web_terminal_traffic_duration" {
282
- order = 26
332
+ order = 40
283
333
name = " Web Terminal Traffic Duration"
284
334
type = " number"
285
335
description = " The duration of the web terminal traffic load scenario in minutes."
@@ -292,7 +342,7 @@ data "coder_parameter" "load_scenario_web_terminal_traffic_duration" {
292
342
}
293
343
294
344
data "coder_parameter" "load_scenario_web_terminal_bytes_per_tick" {
295
- order = 27
345
+ order = 41
296
346
name = " Web Terminal Bytes Per Tick"
297
347
type = " number"
298
348
description = " The number of bytes to send per tick in the web terminal traffic load scenario."
@@ -304,7 +354,7 @@ data "coder_parameter" "load_scenario_web_terminal_bytes_per_tick" {
304
354
}
305
355
306
356
data "coder_parameter" "load_scenario_web_terminal_tick_interval" {
307
- order = 28
357
+ order = 42
308
358
name = " Web Terminal Tick Interval"
309
359
type = " number"
310
360
description = " The number of milliseconds between each tick in the web terminal traffic load scenario."
@@ -315,8 +365,94 @@ data "coder_parameter" "load_scenario_web_terminal_tick_interval" {
315
365
}
316
366
}
317
367
368
+ data "coder_parameter" "load_scenario_web_terminal_traffic_percentage" {
369
+ order = 43
370
+ name = " Web Terminal Traffic Percentage"
371
+ type = " number"
372
+ description = " The percentage of workspaces that should be targeted for web terminal traffic."
373
+ mutable = true
374
+ default = 100
375
+ validation {
376
+ min = 1
377
+ max = 100
378
+ }
379
+ }
380
+
381
+ data "coder_parameter" "load_scenario_app_traffic_duration" {
382
+ order = 50
383
+ name = " App Traffic Duration"
384
+ type = " number"
385
+ description = " The duration of the app traffic load scenario in minutes."
386
+ mutable = true
387
+ default = 30
388
+ validation {
389
+ min = 1
390
+ max = 1440 // 24 hours.
391
+ }
392
+ }
393
+
394
+ data "coder_parameter" "load_scenario_app_bytes_per_tick" {
395
+ order = 51
396
+ name = " App Bytes Per Tick"
397
+ type = " number"
398
+ description = " The number of bytes to send per tick in the app traffic load scenario."
399
+ mutable = true
400
+ default = 1024
401
+ validation {
402
+ min = 1
403
+ }
404
+ }
405
+
406
+ data "coder_parameter" "load_scenario_app_tick_interval" {
407
+ order = 52
408
+ name = " App Tick Interval"
409
+ type = " number"
410
+ description = " The number of milliseconds between each tick in the app traffic load scenario."
411
+ mutable = true
412
+ default = 100
413
+ validation {
414
+ min = 1
415
+ }
416
+ }
417
+
418
+ data "coder_parameter" "load_scenario_app_traffic_percentage" {
419
+ order = 53
420
+ name = " App Traffic Percentage"
421
+ type = " number"
422
+ description = " The percentage of workspaces that should be targeted for app traffic."
423
+ mutable = true
424
+ default = 100
425
+ validation {
426
+ min = 1
427
+ max = 100
428
+ }
429
+ }
430
+
431
+ data "coder_parameter" "load_scenario_app_traffic_mode" {
432
+ order = 54
433
+ name = " App Traffic Mode"
434
+ default = " wsec"
435
+ description = " The mode of the app traffic load scenario."
436
+ mutable = true
437
+ option {
438
+ name = " WebSocket Echo"
439
+ value = " wsec"
440
+ description = " Send traffic to the workspace via the app websocket and read it back."
441
+ }
442
+ option {
443
+ name = " WebSocket Read (Random)"
444
+ value = " wsra"
445
+ description = " Read traffic from the workspace via the app websocket."
446
+ }
447
+ option {
448
+ name = " WebSocket Write (Discard)"
449
+ value = " wsdi"
450
+ description = " Send traffic to the workspace via the app websocket."
451
+ }
452
+ }
453
+
318
454
data "coder_parameter" "load_scenario_dashboard_traffic_duration" {
319
- order = 29
455
+ order = 60
320
456
name = " Dashboard Traffic Duration"
321
457
type = " number"
322
458
description = " The duration of the dashboard traffic load scenario in minutes."
@@ -328,8 +464,21 @@ data "coder_parameter" "load_scenario_dashboard_traffic_duration" {
328
464
}
329
465
}
330
466
467
+ data "coder_parameter" "load_scenario_dashboard_traffic_percentage" {
468
+ order = 61
469
+ name = " Dashboard Traffic Percentage"
470
+ type = " number"
471
+ description = " The percentage of users that should be targeted for dashboard traffic."
472
+ mutable = true
473
+ default = 100
474
+ validation {
475
+ min = 1
476
+ max = 100
477
+ }
478
+ }
479
+
331
480
data "coder_parameter" "load_scenario_baseline_duration" {
332
- order = 26
481
+ order = 100
333
482
name = " Baseline Wait Duration"
334
483
type = " number"
335
484
description = " The duration to wait before starting a load scenario in minutes."
@@ -342,7 +491,7 @@ data "coder_parameter" "load_scenario_baseline_duration" {
342
491
}
343
492
344
493
data "coder_parameter" "greedy_agent" {
345
- order = 30
494
+ order = 200
346
495
type = " bool"
347
496
name = " Greedy Agent"
348
497
default = false
@@ -352,7 +501,7 @@ data "coder_parameter" "greedy_agent" {
352
501
}
353
502
354
503
data "coder_parameter" "greedy_agent_template" {
355
- order = 31
504
+ order = 201
356
505
name = " Greedy Agent Template"
357
506
display_name = " Greedy Agent Template"
358
507
description = " The template used for the greedy agent workspace (must not be same as workspace template)."
@@ -432,6 +581,7 @@ resource "coder_agent" "main" {
432
581
SCALETEST_RUN_ID : local.scaletest_run_id,
433
582
SCALETEST_RUN_DIR : local.scaletest_run_dir,
434
583
SCALETEST_RUN_START_TIME : local.scaletest_run_start_time,
584
+ SCALETEST_PROMETHEUS_START_PORT : " 21112" ,
435
585
436
586
# Comment is a scaletest param, but we want to surface it separately from
437
587
# the rest, so we use a different name.
@@ -440,16 +590,28 @@ resource "coder_agent" "main" {
440
590
SCALETEST_PARAM_TEMPLATE : data.coder_parameter.workspace_template.value,
441
591
SCALETEST_PARAM_REPO_BRANCH : data.coder_parameter.repo_branch.value,
442
592
SCALETEST_PARAM_NUM_WORKSPACES : data.coder_parameter.num_workspaces.value,
593
+ SCALETEST_PARAM_SKIP_CREATE_WORKSPACES : data.coder_parameter.skip_create_workspaces.value ? " 1" : " 0" ,
443
594
SCALETEST_PARAM_CREATE_CONCURRENCY : " ${ data . coder_parameter . create_concurrency . value } " ,
444
595
SCALETEST_PARAM_CLEANUP_STRATEGY : data.coder_parameter.cleanup_strategy.value,
596
+ SCALETEST_PARAM_CLEANUP_PREPARE : data.coder_parameter.cleanup_prepare.value ? " 1" : " 0" ,
445
597
SCALETEST_PARAM_LOAD_SCENARIOS : data.coder_parameter.load_scenarios.value,
598
+ SCALETEST_PARAM_LOAD_SCENARIO_RUN_CONCURRENTLY : data.coder_parameter.load_scenario_run_concurrently.value ? " 1" : " 0" ,
599
+ SCALETEST_PARAM_LOAD_SCENARIO_CONCURRENCY_STAGGER_DELAY_MINS : " ${ data . coder_parameter . load_scenario_concurrency_stagger_delay_mins . value } " ,
446
600
SCALETEST_PARAM_LOAD_SCENARIO_SSH_TRAFFIC_DURATION : " ${ data . coder_parameter . load_scenario_ssh_traffic_duration . value } " ,
447
601
SCALETEST_PARAM_LOAD_SCENARIO_SSH_TRAFFIC_BYTES_PER_TICK : " ${ data . coder_parameter . load_scenario_ssh_bytes_per_tick . value } " ,
448
602
SCALETEST_PARAM_LOAD_SCENARIO_SSH_TRAFFIC_TICK_INTERVAL : " ${ data . coder_parameter . load_scenario_ssh_tick_interval . value } " ,
603
+ SCALETEST_PARAM_LOAD_SCENARIO_SSH_TRAFFIC_PERCENTAGE : " ${ data . coder_parameter . load_scenario_ssh_traffic_percentage . value } " ,
449
604
SCALETEST_PARAM_LOAD_SCENARIO_WEB_TERMINAL_TRAFFIC_DURATION : " ${ data . coder_parameter . load_scenario_web_terminal_traffic_duration . value } " ,
450
605
SCALETEST_PARAM_LOAD_SCENARIO_WEB_TERMINAL_TRAFFIC_BYTES_PER_TICK : " ${ data . coder_parameter . load_scenario_web_terminal_bytes_per_tick . value } " ,
451
606
SCALETEST_PARAM_LOAD_SCENARIO_WEB_TERMINAL_TRAFFIC_TICK_INTERVAL : " ${ data . coder_parameter . load_scenario_web_terminal_tick_interval . value } " ,
607
+ SCALETEST_PARAM_LOAD_SCENARIO_WEB_TERMINAL_TRAFFIC_PERCENTAGE : " ${ data . coder_parameter . load_scenario_web_terminal_traffic_percentage . value } " ,
608
+ SCALETEST_PARAM_LOAD_SCENARIO_APP_TRAFFIC_DURATION : " ${ data . coder_parameter . load_scenario_app_traffic_duration . value } " ,
609
+ SCALETEST_PARAM_LOAD_SCENARIO_APP_TRAFFIC_BYTES_PER_TICK : " ${ data . coder_parameter . load_scenario_app_bytes_per_tick . value } " ,
610
+ SCALETEST_PARAM_LOAD_SCENARIO_APP_TRAFFIC_TICK_INTERVAL : " ${ data . coder_parameter . load_scenario_app_tick_interval . value } " ,
611
+ SCALETEST_PARAM_LOAD_SCENARIO_APP_TRAFFIC_PERCENTAGE : " ${ data . coder_parameter . load_scenario_app_traffic_percentage . value } " ,
612
+ SCALETEST_PARAM_LOAD_SCENARIO_APP_TRAFFIC_MODE : data.coder_parameter.load_scenario_app_traffic_mode.value,
452
613
SCALETEST_PARAM_LOAD_SCENARIO_DASHBOARD_TRAFFIC_DURATION : " ${ data . coder_parameter . load_scenario_dashboard_traffic_duration . value } " ,
614
+ SCALETEST_PARAM_LOAD_SCENARIO_DASHBOARD_TRAFFIC_PERCENTAGE : " ${ data . coder_parameter . load_scenario_dashboard_traffic_percentage . value } " ,
453
615
SCALETEST_PARAM_LOAD_SCENARIO_BASELINE_DURATION : " ${ data . coder_parameter . load_scenario_baseline_duration . value } " ,
454
616
SCALETEST_PARAM_GREEDY_AGENT : data.coder_parameter.greedy_agent.value ? " 1" : " 0" ,
455
617
SCALETEST_PARAM_GREEDY_AGENT_TEMPLATE : data.coder_parameter.greedy_agent_template.value,
@@ -693,26 +855,24 @@ resource "kubernetes_pod" "main" {
693
855
}
694
856
}
695
857
resources {
696
- # Set requests and limits values such that we can do performant
697
- # execution of `coder scaletest` commands.
698
858
requests = {
699
859
" cpu" = " 250m"
700
860
" memory" = " 512Mi"
701
861
}
702
- limits = {
703
- " cpu" = " ${ local . cpu } "
704
- " memory" = " ${ local . memory } Gi"
705
- }
706
862
}
707
863
volume_mount {
708
864
mount_path = " /home/coder"
709
865
name = " home"
710
866
read_only = false
711
867
}
712
- port {
713
- container_port = 21112
714
- name = " prometheus-http"
715
- protocol = " TCP"
868
+ dynamic "port" {
869
+ for_each = data. coder_parameter . load_scenario_run_concurrently . value ? jsondecode (data. coder_parameter . load_scenarios . value ) : [" " ]
870
+ iterator = it
871
+ content {
872
+ container_port = 21112 + it. key
873
+ name = " prom-http${ it . key } "
874
+ protocol = " TCP"
875
+ }
716
876
}
717
877
}
718
878
@@ -787,8 +947,12 @@ resource "kubernetes_manifest" "pod_monitor" {
787
947
}
788
948
}
789
949
podMetricsEndpoints = [
790
- {
791
- port = " prometheus-http"
950
+ # NOTE(mafredri): We could add more information here by including the
951
+ # scenario name in the port name (although it's limited to 15 chars so
952
+ # it needs to be short). That said, someone looking at the stats can
953
+ # assume that there's a 1-to-1 mapping between scenario# and port.
954
+ for i , _ in data . coder_parameter . load_scenario_run_concurrently . value ? jsondecode (data. coder_parameter . load_scenarios . value ) : [" " ] : {
955
+ port = " prom-http${ i } "
792
956
interval = " 15s"
793
957
}
794
958
]
0 commit comments