Skip to content
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

feat(49): Added stop_timeout parameter for locust command #52

Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ The project uses [mkdocs.org](https://www.mkdocs.org) to build and maintain its
from `pyproject.toml` and `poetry.lock`. Add `--group test` or `--group dev` to uninstall a CI or development dependency, respectively.
- Run `poetry update` from within the development environment to upgrade all dependencies to the latest versions allowed by `pyproject.toml`.
- Run `cz bump` to bump the package's version, update the `CHANGELOG.md`, and create a git tag.
- Project has a protection against pushing to `main/msater` branches by utilizing pre-commit hooks.
- Project has a protection against pushing to `main/master` branches by utilizing pre-commit hooks.
</details>
7 changes: 6 additions & 1 deletion docs/test-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ configurations:
- Users spawn rate
- Test duration
- Target host of the test
- Timeout to end all current tasks if run_time was reached [Optional field]

```yaml title="test-config.yaml"
configurations:
Expand All @@ -52,6 +53,8 @@ configurations:
run_time: str # (1)!
# * Test target URL
target_host: str
# * Timeout to end current task (sec)
termination_timeout: int
```

1. This field support different was of expressing duration e.g. (`300s`, `20m`, `3h`, `1h30m`, etc.). Default value is `30s`.
Expand Down Expand Up @@ -192,6 +195,8 @@ configurations:
run_time: str # (4)!
# Test target URL
target_host: str # (5)!
# * Timeout to end current task (sec) # (11)!
termination_timeout: int
aleks-vodolazko marked this conversation as resolved.
Show resolved Hide resolved

# Custom load shapes support.
custom_load_shapes: bool
Expand Down Expand Up @@ -237,7 +242,7 @@ configurations:
8. This field maps to the `image` section of the _LocustTest custom resource_.
9. This field directly maps to the `affinity` section of the _LocustTest custom resource_.
10. This field directly maps to the `tolerations` section of the _LocustTest custom resource_.

11. This field maps to the `--stop-timeout` locust switch and appears in `masterCommandSeed` of the _LocustTest custom resource_.



Expand Down
348 changes: 73 additions & 275 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/intensive_brew/core/custom_resource/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

CUSTOM_LOAD_SHAPE_COMMAND_TEMPLATE = "--locustfile {file}"

VANILLA_SPECS_COMMAND_TEMPLATE = "--locustfile {file} --host {host_url} --users {users} --spawn-rate {spawn_rate} --run-time {run_time}"
VANILLA_SPECS_COMMAND_TEMPLATE = "--locustfile {file} --host {host_url} --users {users} --spawn-rate {spawn_rate} --run-time {run_time} --stop-timeout {termination_timeout}"

# For this iteration, `worker` command template and `custom shapes` command template are identical
WORKER_COMMAND_TEMPLATE = CUSTOM_LOAD_SHAPE_COMMAND_TEMPLATE
Expand Down
1 change: 1 addition & 0 deletions src/intensive_brew/core/custom_resource/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def _generate_master_command_seed(test_config: TestConfig) -> str:
users=test_config.vanilla_specs.users, # type: ignore[union-attr]
spawn_rate=test_config.vanilla_specs.spawn_rate, # type: ignore[union-attr]
run_time=test_config.vanilla_specs.run_time, # type: ignore[union-attr]
termination_timeout=test_config.vanilla_specs.termination_timeout, # type: ignore[union-attr]
)

log.debug(f"Generated 'MASTER' node command seed: {command}")
Expand Down
3 changes: 3 additions & 0 deletions src/intensive_brew/core/dto/yaml/vanilla_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class Config:
# * Test duration: Stop after the specified amount of time, e.g. (300s, 20m, 3h, 1h30m, etc.). Default: 30s.
run_time: str = "30s"

# * Number of seconds to wait for a simulated user to complete any executing task before exiting. Default: 0.
termination_timeout: int = 0

# * Target URL of the test
target_host: AnyUrl

Expand Down
3 changes: 3 additions & 0 deletions tests/generation/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
DEFAULT_TEST_USERS = 10000
DEFAULT_ENTRY_POINT = "src/my_test.py"
DEFAULT_TARGET_HOST = "http://localhost:8080"
DEFAULT_TERMINATION_TIMEOUT = 10
DEFAULT_EXPERT_MODE_SEED_CMD = "--locustfile src/my_test.py --u 1000"


Expand Down Expand Up @@ -95,6 +96,7 @@ def prepare_test_config(mode: str = "custom") -> TestConfig:
spawn_rate=DEFAULT_SPAWN_RATE,
run_time=DEFAULT_RUN_TIME,
target_host=DEFAULT_TARGET_HOST, # type: ignore[arg-type]
termination_timeout=DEFAULT_TERMINATION_TIMEOUT,
),
)
else:
Expand Down Expand Up @@ -142,6 +144,7 @@ def prepare_vanilla_spec_command_seed(team_config: TestConfig) -> str:
users=team_config.vanilla_specs.users, # type: ignore[union-attr]
spawn_rate=team_config.vanilla_specs.spawn_rate, # type: ignore[union-attr]
run_time=team_config.vanilla_specs.run_time, # type: ignore[union-attr]
termination_timeout=team_config.vanilla_specs.termination_timeout, # type: ignore[union-attr]
)


Expand Down
14 changes: 14 additions & 0 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ def test_vanilla_specs() -> None:
)


def test_vanilla_specs_with_termination_timeout() -> None:
"""Check creating an object configuration termination_timeout parameter for vanilla_specs."""
assert TestConfig(
entry_point="my_script.py",
vanilla_specs=VanillaSpecs(
users=1000,
spawn_rate=10,
run_time="60s",
target_host="http://localhost:8080", # type: ignore[arg-type]
termination_timeout=5,
),
)


def test_custom_load_shap() -> None:
"""Check creating an object with bare-minimum configuration for custom_load_shap."""
assert TestConfig(entry_point="my_script.py", custom_load_shapes=True)
Expand Down