diff --git a/docs/changelog.rst b/docs/changelog.rst index 0957f139c4..03de8b16b0 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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) diff --git a/locust/html.py b/locust/html.py index 1f88839bac..7aa2fb062f 100644 --- a/locust/html.py +++ b/locust/html.py @@ -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) diff --git a/locust/stats.py b/locust/stats.py index 0a38b77c77..23009ee0bd 100644 --- a/locust/stats.py +++ b/locust/stats.py @@ -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, @@ -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) diff --git a/locust/test/test_stats.py b/locust/test/test_stats.py index 71c38d1537..afc7a5a9ad 100644 --- a/locust/test/test_stats.py +++ b/locust/test/test_stats.py @@ -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)