Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 5 additions & 2 deletions monitoring/benchmarker/configurations/loads.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,14 @@ class LoadCompletionCriteria(ImplicitDict):


class UserRampLoad(ImplicitDict):
"""Ramps up users of a specified type, observing resulting throughput."""
"""Ramps up users of specified type(s), observing resulting throughput."""

user_type: BenchmarkUserName
user_type: Optional[BenchmarkUserName]
"""Type of user to instantiate."""

user_types: Optional[list[BenchmarkUserName]]
"""Types of users to instantiate, cycling through them in order as load increases."""

initial_users: int = 1
"""Number of users to start with."""

Expand Down
24 changes: 18 additions & 6 deletions monitoring/benchmarker/engine/loads/user_ramp/user_ramp.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,21 @@ async def run_user_ramp_load(
scenario_name: BenchmarkScenarioName,
) -> tuple[list[ExecutedOperation], list[BenchmarkScenarioStepReport]]:
"""Apply a load by driving virtual user workflows and monitoring step criteria."""
ramp_user_type = ramp.user_type
if ramp_user_type not in user_specs_map:
raise ValueError(
f"User type '{ramp_user_type}' for UserRampLoad.user_type not found in configuration.user_types"
)
user_spec = user_specs_map[ramp_user_type]
if "user_types" in ramp and ramp.user_types:
user_types_list = ramp.user_types
for ut in user_types_list:
if ut not in user_specs_map:
raise ValueError(
f"User type '{ut}' for UserRampLoad.user_types not found in configuration.user_types"
)
elif "user_type" in ramp and ramp.user_type:
if ramp.user_type not in user_specs_map:
raise ValueError(
f"User type '{ramp.user_type}' for UserRampLoad.user_type not found in configuration.user_types"
)
user_types_list = [ramp.user_type]
else:
raise ValueError("Neither user_type nor user_types specified for UserRampLoad")

random = (
Random(ramp.random_seed)
Expand Down Expand Up @@ -113,6 +122,9 @@ async def _periodic_summary_logger() -> None:
first_user_spawned = None
last_user_spawned = None
while len(virtual_users) < current_load_factor:
user_spec = user_specs_map[
user_types_list[len(virtual_users) % len(user_types_list)]
]
user_id = f"{user_spec.name}_{len(virtual_users) + 1}"
if first_user_spawned is None:
first_user_spawned = user_id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$id": "https://github.com/interuss/monitoring/blob/main/schemas/monitoring/benchmarker/configurations/loads/UserRampLoad.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"description": "Ramps up users of a specified type, observing resulting throughput.\n\nmonitoring.benchmarker.configurations.loads.UserRampLoad, as defined in monitoring/benchmarker/configurations/loads.py",
"description": "Ramps up users of specified type(s), observing resulting throughput.\n\nmonitoring.benchmarker.configurations.loads.UserRampLoad, as defined in monitoring/benchmarker/configurations/loads.py",
"properties": {
"$ref": {
"description": "Path to content that replaces the $ref",
Expand Down Expand Up @@ -47,14 +47,26 @@
},
"user_type": {
"description": "Type of user to instantiate.",
"type": "string"
"type": [
"string",
"null"
]
},
"user_types": {
"description": "Types of users to instantiate, cycling through them in order as load increases.",
"items": {
"type": "string"
},
"type": [
"array",
"null"
]
}
},
"required": [
"load_completion_criteria",
"step_completion_criteria",
"throughput_stability_criteria",
"user_type"
"throughput_stability_criteria"
],
"type": "object"
}
Loading