Skip to content

Fix false "--run-time limit reached" log message when shape test completes#3382

Merged
cyberw merged 1 commit intolocustio:masterfrom
Krishnachaitanyakc:fix/false-run-time-limit-log-message
Mar 25, 2026
Merged

Fix false "--run-time limit reached" log message when shape test completes#3382
cyberw merged 1 commit intolocustio:masterfrom
Krishnachaitanyakc:fix/false-run-time-limit-log-message

Conversation

@Krishnachaitanyakc
Copy link
Copy Markdown
Contributor

Summary

  • Fixes the misleading --run-time limit reached log message that appears when a LoadTestShape test completes naturally or is interrupted, even though the stop was not caused by the --run-time limit.
  • Adds a reason parameter to stop_and_optionally_quit() (defaults to "--run-time limit reached" for backward compatibility) and passes "Shape test completed" from the shape class finally block.
  • Updates corresponding tests to expect the corrected log message.

Fixes #3178

Context

As noted in #3178, calling stop() / quit() or letting a LoadTestShape finish naturally would print --run-time limit reached, shutting down (or stopping test), which is incorrect and confusing since the stop was not triggered by --run-time. A maintainer acknowledged this as a valid bug but it was closed as stale with no fix applied.

Changes

  • locust/main.py: stop_and_optionally_quit() now takes an optional reason parameter. The timer-based call (spawn_run_time_quit_greenlet) still passes the default "--run-time limit reached". The shape class finally block now passes "Shape test completed".
  • locust/test/test_main.py: Updated two shape-class integration tests (test_autostart_w_load_shape and test_autostart_multiple_locustfiles_with_shape) to expect "Shape test completed" instead of "--run-time limit reached".

Test plan

  • Existing tests in test_main.py and test_log.py that verify --run-time limit reached for actual timer-triggered stops remain unchanged and should pass
  • The two updated shape-class tests should now correctly expect "Shape test completed"
  • Manual test: run a LoadTestShape with --autostart and verify the log says "Shape test completed, stopping test" instead of "--run-time limit reached, stopping test"

…letes

When a LoadTestShape test finishes naturally or is interrupted,
stop_and_optionally_quit() logs "--run-time limit reached" even though
the stop was not caused by the --run-time limit. This is misleading
for users.

Add a `reason` parameter to stop_and_optionally_quit() that defaults
to "--run-time limit reached" (preserving existing behavior for the
timer-based call) and pass "Shape test completed" when called from
the shape class finally block.

Fixes locustio#3178
@cyberw cyberw merged commit 92b5bc6 into locustio:master Mar 25, 2026
19 of 20 checks passed
@cyberw
Copy link
Copy Markdown
Collaborator

cyberw commented Mar 25, 2026

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False "--run-time limit reached" log on stopping

2 participants