Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into use-fstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
tdadela committed Nov 8, 2024
2 parents f5e2e97 + 2120cc4 commit 3f49b6c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Changelog Highlights

For full details of the Locust changelog, please see https://github.com/locustio/locust/blob/master/CHANGELOG.md

2.32.2
======
* Better html report file names https://github.com/locustio/locust/pull/2947
* Fix Incorrectly Updating Stat History https://github.com/locustio/locust/pull/2972
* Various WebUI fixes (most only relevant for https://locust.cloud)

2.32.1
======
* Various WebUI fixes (most only relevant for https://locust.cloud)
Expand Down
3 changes: 2 additions & 1 deletion locust/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def get_html_report(
{**exc, "nodes": ", ".join(exc["nodes"])} for exc in environment.runner.exceptions.values()
]

update_stats_history(environment.runner)
if stats.history and stats.history[-1]["time"] < end_time:
update_stats_history(environment.runner, end_time)
history = stats.history

is_distributed = isinstance(environment.runner, MasterRunner)
Expand Down
7 changes: 4 additions & 3 deletions locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,9 @@ def sort_stats(stats: dict[Any, S]) -> list[S]:
return [stats[key] for key in sorted(stats.keys())]


def update_stats_history(runner: Runner) -> None:
def update_stats_history(runner: Runner, timestamp: str | None = None) -> None:
stats = runner.stats
timestamp = format_utc_timestamp(time.time())
timestamp = timestamp or format_utc_timestamp(time.time())
current_response_time_percentiles = {
f"response_time_percentile_{percentile}": [
timestamp,
Expand All @@ -929,7 +929,8 @@ def stats_history(runner: Runner) -> None:
while True:
if not runner.stats.total.use_response_times_cache:
break
if runner.state != "stopped":

if runner.state != "ready" and runner.state != "stopped":
update_stats_history(runner)

gevent.sleep(HISTORY_STATS_INTERVAL_SEC)
Expand Down
3 changes: 2 additions & 1 deletion locust/test/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,11 +585,12 @@ def test_requests_csv_quote_escaping(self):
def test_stats_history(self):
env1 = Environment(events=locust.events, catch_exceptions=False)
runner1 = env1.create_master_runner("127.0.0.1", 5558)
runner1.state = "running"
env2 = Environment(events=locust.events, catch_exceptions=False)
runner2 = env2.create_worker_runner("127.0.0.1", 5558)
greenlet1 = gevent.spawn(stats_history, runner1)
greenlet2 = gevent.spawn(stats_history, runner2)
gevent.sleep(1)
gevent.sleep(0.1)
hs1 = runner1.stats.history
hs2 = runner2.stats.history
gevent.kill(greenlet1)
Expand Down

0 comments on commit 3f49b6c

Please sign in to comment.