mite 3.0.2__tar.gz → 3.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. {mite-3.0.2 → mite-3.1.0}/PKG-INFO +2 -2
  2. {mite-3.0.2 → mite-3.1.0}/cd.yml +1 -1
  3. {mite-3.0.2 → mite-3.1.0}/mite/__main__.py +18 -9
  4. {mite-3.0.2 → mite-3.1.0}/mite/_version.py +2 -2
  5. {mite-3.0.2 → mite-3.1.0}/mite/cli/test.py +179 -68
  6. mite-3.1.0/mite/har_to_mite.py +520 -0
  7. mite-3.1.0/mite/logoutput.py +487 -0
  8. {mite-3.0.2 → mite-3.1.0}/mite_browser/__init__.py +9 -0
  9. {mite-3.0.2 → mite-3.1.0}/mite_http/__init__.py +3 -0
  10. mite-3.1.0/mite_http/checks.py +51 -0
  11. {mite-3.0.2 → mite-3.1.0}/pyproject.toml +1 -1
  12. mite-3.0.2/mite/har_to_mite.py +0 -135
  13. mite-3.0.2/mite/logoutput.py +0 -246
  14. {mite-3.0.2 → mite-3.1.0}/.dockerignore +0 -0
  15. {mite-3.0.2 → mite-3.1.0}/.gitignore +0 -0
  16. {mite-3.0.2 → mite-3.1.0}/.isort.cfg +0 -0
  17. {mite-3.0.2 → mite-3.1.0}/.pre-commit-config.yaml +0 -0
  18. {mite-3.0.2 → mite-3.1.0}/CHANGELOG.md +0 -0
  19. {mite-3.0.2 → mite-3.1.0}/CODE_OF_CONDUCT.md +0 -0
  20. {mite-3.0.2 → mite-3.1.0}/CONTRIBUTING.md +0 -0
  21. {mite-3.0.2 → mite-3.1.0}/DEV.md +0 -0
  22. {mite-3.0.2 → mite-3.1.0}/Dockerfile +0 -0
  23. {mite-3.0.2 → mite-3.1.0}/LICENSE +0 -0
  24. {mite-3.0.2 → mite-3.1.0}/README.md +0 -0
  25. {mite-3.0.2 → mite-3.1.0}/cd-scripts/cdBuild.sh +0 -0
  26. {mite-3.0.2 → mite-3.1.0}/cd-scripts/cdTagRelease.py +0 -0
  27. {mite-3.0.2 → mite-3.1.0}/cd-scripts/lib.sh +0 -0
  28. {mite-3.0.2 → mite-3.1.0}/cd-scripts/manualRelease.sh +0 -0
  29. {mite-3.0.2 → mite-3.1.0}/docker_compose.yml +0 -0
  30. {mite-3.0.2 → mite-3.1.0}/docker_compose_monitoring.yml +0 -0
  31. {mite-3.0.2 → mite-3.1.0}/grafana/Dockerfile +0 -0
  32. {mite-3.0.2 → mite-3.1.0}/grafana/config.ini +0 -0
  33. {mite-3.0.2 → mite-3.1.0}/grafana/provisioning/dashboards/dashboards.yml +0 -0
  34. {mite-3.0.2 → mite-3.1.0}/grafana/provisioning/dashboards/grafana_dashboard_template.json +0 -0
  35. {mite-3.0.2 → mite-3.1.0}/grafana/provisioning/dashboards/mite_docker.json +0 -0
  36. {mite-3.0.2 → mite-3.1.0}/grafana/provisioning/datasources/datasources.yml +0 -0
  37. {mite-3.0.2 → mite-3.1.0}/local/Makefile +0 -0
  38. {mite-3.0.2 → mite-3.1.0}/local/README.md +0 -0
  39. {mite-3.0.2 → mite-3.1.0}/local/demo.py +0 -0
  40. {mite-3.0.2 → mite-3.1.0}/local/run_mite.sh +0 -0
  41. {mite-3.0.2 → mite-3.1.0}/mite/__init__.py +0 -0
  42. {mite-3.0.2 → mite-3.1.0}/mite/cli/__init__.py +0 -0
  43. {mite-3.0.2 → mite-3.1.0}/mite/cli/cat.py +0 -0
  44. {mite-3.0.2 → mite-3.1.0}/mite/cli/collector.py +0 -0
  45. {mite-3.0.2 → mite-3.1.0}/mite/cli/common.py +0 -0
  46. {mite-3.0.2 → mite-3.1.0}/mite/cli/duplicator.py +0 -0
  47. {mite-3.0.2 → mite-3.1.0}/mite/cli/influxdb.py +0 -0
  48. {mite-3.0.2 → mite-3.1.0}/mite/cli/receiver.py +0 -0
  49. {mite-3.0.2 → mite-3.1.0}/mite/cli/stats.py +0 -0
  50. {mite-3.0.2 → mite-3.1.0}/mite/collector.py +0 -0
  51. {mite-3.0.2 → mite-3.1.0}/mite/config.py +0 -0
  52. {mite-3.0.2 → mite-3.1.0}/mite/context.py +0 -0
  53. {mite-3.0.2 → mite-3.1.0}/mite/controller.py +0 -0
  54. {mite-3.0.2 → mite-3.1.0}/mite/datapools.py +0 -0
  55. {mite-3.0.2 → mite-3.1.0}/mite/example.py +0 -0
  56. {mite-3.0.2 → mite-3.1.0}/mite/exceptions.py +0 -0
  57. {mite-3.0.2 → mite-3.1.0}/mite/influxdb_processor.py +0 -0
  58. {mite-3.0.2 → mite-3.1.0}/mite/nanomsg.py +0 -0
  59. {mite-3.0.2 → mite-3.1.0}/mite/otel/__init__.py +0 -0
  60. {mite-3.0.2 → mite-3.1.0}/mite/otel/acurl_integration.py +0 -0
  61. {mite-3.0.2 → mite-3.1.0}/mite/otel/config.py +0 -0
  62. {mite-3.0.2 → mite-3.1.0}/mite/otel/context.py +0 -0
  63. {mite-3.0.2 → mite-3.1.0}/mite/otel/context_integration.py +0 -0
  64. {mite-3.0.2 → mite-3.1.0}/mite/otel/instrumentation.py +0 -0
  65. {mite-3.0.2 → mite-3.1.0}/mite/otel/tracing.py +0 -0
  66. {mite-3.0.2 → mite-3.1.0}/mite/recorder.py +0 -0
  67. {mite-3.0.2 → mite-3.1.0}/mite/runner.py +0 -0
  68. {mite-3.0.2 → mite-3.1.0}/mite/s3datapools.py +0 -0
  69. {mite-3.0.2 → mite-3.1.0}/mite/scenario.py +0 -0
  70. {mite-3.0.2 → mite-3.1.0}/mite/stats.py +0 -0
  71. {mite-3.0.2 → mite-3.1.0}/mite/test.py +0 -0
  72. {mite-3.0.2 → mite-3.1.0}/mite/utils.py +0 -0
  73. {mite-3.0.2 → mite-3.1.0}/mite/volume_model.py +0 -0
  74. {mite-3.0.2 → mite-3.1.0}/mite/web/__init__.py +0 -0
  75. {mite-3.0.2 → mite-3.1.0}/mite/web/influxdb.py +0 -0
  76. {mite-3.0.2 → mite-3.1.0}/mite/web/prometheus.py +0 -0
  77. {mite-3.0.2 → mite-3.1.0}/mite/zmq.py +0 -0
  78. {mite-3.0.2 → mite-3.1.0}/mite_amqp/README.md +0 -0
  79. {mite-3.0.2 → mite-3.1.0}/mite_amqp/__init__.py +0 -0
  80. {mite-3.0.2 → mite-3.1.0}/mite_browser/README.md +0 -0
  81. {mite-3.0.2 → mite-3.1.0}/mite_db_datapool/README.md +0 -0
  82. {mite-3.0.2 → mite-3.1.0}/mite_db_datapool/__init__.py +0 -0
  83. {mite-3.0.2 → mite-3.1.0}/mite_db_datapool/db_to_pool.py +0 -0
  84. {mite-3.0.2 → mite-3.1.0}/mite_db_datapool/mite_db_example.py +0 -0
  85. {mite-3.0.2 → mite-3.1.0}/mite_finagle/README.md +0 -0
  86. {mite-3.0.2 → mite-3.1.0}/mite_finagle/__init__.py +0 -0
  87. {mite-3.0.2 → mite-3.1.0}/mite_finagle/mux.py +0 -0
  88. {mite-3.0.2 → mite-3.1.0}/mite_finagle/stats.py +0 -0
  89. {mite-3.0.2 → mite-3.1.0}/mite_finagle/tests/__init__.py +0 -0
  90. {mite-3.0.2 → mite-3.1.0}/mite_finagle/tests/conftest.py +0 -0
  91. {mite-3.0.2 → mite-3.1.0}/mite_finagle/tests/foo_service/Foo-remote +0 -0
  92. {mite-3.0.2 → mite-3.1.0}/mite_finagle/tests/foo_service/Foo.py +0 -0
  93. {mite-3.0.2 → mite-3.1.0}/mite_finagle/tests/foo_service/__init__.py +0 -0
  94. {mite-3.0.2 → mite-3.1.0}/mite_finagle/tests/foo_service/constants.py +0 -0
  95. {mite-3.0.2 → mite-3.1.0}/mite_finagle/tests/foo_service/ttypes.py +0 -0
  96. {mite-3.0.2 → mite-3.1.0}/mite_finagle/tests/foo_service.thrift +0 -0
  97. {mite-3.0.2 → mite-3.1.0}/mite_finagle/tests/test_integration.py +0 -0
  98. {mite-3.0.2 → mite-3.1.0}/mite_finagle/tests/test_mux.py +0 -0
  99. {mite-3.0.2 → mite-3.1.0}/mite_finagle/tests/test_thrift.py +0 -0
  100. {mite-3.0.2 → mite-3.1.0}/mite_finagle/thrift.py +0 -0
  101. {mite-3.0.2 → mite-3.1.0}/mite_http/README.md +0 -0
  102. {mite-3.0.2 → mite-3.1.0}/mite_http/compat.py +0 -0
  103. {mite-3.0.2 → mite-3.1.0}/mite_http/config.py +0 -0
  104. {mite-3.0.2 → mite-3.1.0}/mite_http/stats.py +0 -0
  105. {mite-3.0.2 → mite-3.1.0}/mite_kafka/README.md +0 -0
  106. {mite-3.0.2 → mite-3.1.0}/mite_kafka/__init__.py +0 -0
  107. {mite-3.0.2 → mite-3.1.0}/mite_kafka/mite_kafka_example.py +0 -0
  108. {mite-3.0.2 → mite-3.1.0}/mite_kafka/stats.py +0 -0
  109. {mite-3.0.2 → mite-3.1.0}/mite_playwright/README.md +0 -0
  110. {mite-3.0.2 → mite-3.1.0}/mite_playwright/__init__.py +0 -0
  111. {mite-3.0.2 → mite-3.1.0}/mite_playwright/mite_playwright_example.py +0 -0
  112. {mite-3.0.2 → mite-3.1.0}/mite_playwright/stats.py +0 -0
  113. {mite-3.0.2 → mite-3.1.0}/mite_selenium/README.md +0 -0
  114. {mite-3.0.2 → mite-3.1.0}/mite_selenium/__init__.py +0 -0
  115. {mite-3.0.2 → mite-3.1.0}/mite_selenium/stats.py +0 -0
  116. {mite-3.0.2 → mite-3.1.0}/mite_websocket/README.md +0 -0
  117. {mite-3.0.2 → mite-3.1.0}/mite_websocket/__init__.py +0 -0
  118. {mite-3.0.2 → mite-3.1.0}/prometheus/Dockerfile +0 -0
  119. {mite-3.0.2 → mite-3.1.0}/prometheus/prometheus_config_docker.yml +0 -0
  120. {mite-3.0.2 → mite-3.1.0}/prometheus/prometheus_config_template.yml +0 -0
  121. {mite-3.0.2 → mite-3.1.0}/test.har +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: mite
3
- Version: 3.0.2
3
+ Version: 3.1.0
4
4
  Summary: A Python Performance Testing Framework
5
5
  Project-URL: Homepage, https://github.com/sky-uk/mite/
6
6
  Project-URL: Documentation, https://sky-uk.github.io/mite/
@@ -64,7 +64,7 @@ Requires-Dist: pytest-cov; extra == 'dev'
64
64
  Requires-Dist: pytest-httpbin; extra == 'dev'
65
65
  Requires-Dist: pytest-httpserver; extra == 'dev'
66
66
  Requires-Dist: ruff>=0.1.0; extra == 'dev'
67
- Requires-Dist: werkzeug==3.1.3; extra == 'dev'
67
+ Requires-Dist: werkzeug==3.1.9; extra == 'dev'
68
68
  Provides-Extra: docs
69
69
  Requires-Dist: furo; extra == 'docs'
70
70
  Requires-Dist: myst-parser; extra == 'docs'
@@ -14,7 +14,7 @@ context: sky-identity
14
14
  triggering: multibranch
15
15
 
16
16
  defaultNodes:
17
- default: sky-identity-nonprod-mite-slave-buildkit
17
+ default: sky-identity-nonprod-mite-java21-slave-buildkit
18
18
 
19
19
  modules:
20
20
  mite-ci:
@@ -14,7 +14,7 @@ Usage:
14
14
  mite [options] receiver RECEIVE_SOCKET [--processor=PROCESSOR]...
15
15
  mite [options] prometheus_exporter [--stats-out-socket=SOCKET] [--web-address=HOST_PORT]
16
16
  mite [options] influxdb_exporter [--stats-out-socket=SOCKET]
17
- mite [options] har HAR_FILE_PATH CONVERTED_FILE_PATH [--sleep-time=SLEEP]
17
+ mite [options] har HAR_FILE_PATH CONVERTED_FILE_PATH [--host=HOST]... [--include-static] [--sleep-time=SLEEP]
18
18
  mite [options] cat [--prettify-timestamps] MSGPACK_FILE_PATH
19
19
  mite [options] uncat
20
20
  mite [options] influxdb init [--influxdb=N]
@@ -88,7 +88,9 @@ Options:
88
88
  --collector-roll=NUM_LINES How many lines per collector output file [default: 100000]
89
89
  --collector-use-json Output in json format rather than msgpack
90
90
  --recorder-dir=DIRECTORY Set the recorders output directory [default: recorder_data]
91
- --sleep-time=SLEEP Set the second to await between each request [default: 1]
91
+ --sleep-time=SLEEP Seconds between request starts; 0 uses the recorded gaps [default: 1]
92
+ --host=HOST Host to keep when converting a HAR (repeatable, globs like *.example.com allowed)
93
+ --include-static Keep static assets and CORS preflights when converting a HAR
92
94
  --logging-webhook=URL URL of an HTTP server to log test runs to
93
95
  --message-processors=PROCESSORS Classes to connect to the message bus for local testing [default: mite.logoutput:HttpStatsOutput,mite.logoutput:MsgOutput]
94
96
  --prettify-timestamps Reformat unix timestamps to human readable dates
@@ -100,7 +102,7 @@ Options:
100
102
  --mean-response-time-threshold=THRESHOLD Set the mean response time accepted before setting exit status to 1 [default: 0]
101
103
  --standard-deviation-response-time-threshold=THRESHOLD Set the response time standard deviation accepted before setting exit status to 1 [default: 0]
102
104
  --standard-deviation-req-sec-threshold=THRESHOLD Set the request per second standard deviation accepted before setting exit status to 1 [default: 0]
103
- --benchmark-percentiles=NEW_VALUE Percentiles(int):threshold(int in milliseconds) pairs separated by commas [default: 50:0,90:0,98:0,99:0]
105
+ --benchmark-percentiles=NEW_VALUE Percentiles(int):threshold(int in milliseconds) pairs separated by commas, or a spec (module:attribute) naming a dict of per-transaction percentiles and error thresholds [default: 50:0,90:0,98:0,99:0]
104
106
  --influxdb=N Send stats to N number of InfluxDB instances
105
107
  --include-buckets Include histogram buckets when sending stats to InfluxDB
106
108
  """
@@ -359,13 +361,20 @@ def configure_python_path(opts):
359
361
  def har_converter(opts):
360
362
  # Deferred, this import is only needed by this one command.
361
363
  # mite runner/controller/duplicator/collector never call it.
362
- from .har_to_mite import har_convert_to_mite
364
+ from .har_to_mite import HarConversionError, har_convert_to_mite
363
365
 
364
- har_convert_to_mite(
365
- opts["HAR_FILE_PATH"],
366
- opts["CONVERTED_FILE_PATH"],
367
- opts["--sleep-time"],
368
- )
366
+ try:
367
+ requests = har_convert_to_mite(
368
+ opts["HAR_FILE_PATH"],
369
+ opts["CONVERTED_FILE_PATH"],
370
+ opts["--sleep-time"],
371
+ hosts=opts["--host"],
372
+ include_static=opts["--include-static"],
373
+ )
374
+ except HarConversionError as e:
375
+ print(e, file=sys.stderr)
376
+ sys.exit(1)
377
+ print(f"Wrote {len(requests)} requests to {opts['CONVERTED_FILE_PATH']}")
369
378
 
370
379
 
371
380
  def main():
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '3.0.2'
22
- __version_tuple__ = version_tuple = (3, 0, 2)
21
+ __version__ = version = '3.1.0'
22
+ __version_tuple__ = version_tuple = (3, 1, 0)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -8,7 +8,7 @@ from prettytable import PrettyTable
8
8
 
9
9
  from mite.datapools import SingleRunDataPoolWrapper
10
10
  from mite.influxdb_processor import InfluxDBProcessor
11
- from mite.logoutput import DebugMessageOutput, HttpStatsOutput
11
+ from mite.logoutput import ALL_TRANSACTIONS_KEY, DebugMessageOutput, HttpStatsOutput
12
12
 
13
13
  from ..collector import Collector
14
14
  from ..controller import Controller
@@ -185,12 +185,12 @@ def test_scenarios(test_name, opts, scenarios, config_manager):
185
185
  if hasattr(processor, "close"):
186
186
  processor.close()
187
187
 
188
+ http_stats_output.finalise()
188
189
  http_stats_output._scenarios_completed_time = time.time()
189
190
  has_error = False
190
191
 
191
- if int(opts.get("--max-errors-threshold")) < http_stats_output.error_total:
192
+ if _check_error_thresholds(http_stats_output):
192
193
  has_error = True
193
- logging.error("Error count exceeded: %s", http_stats_output.error_total)
194
194
 
195
195
  if opts.get("--max-response-time-threshold") != "0":
196
196
  max_response_time = http_stats_output._resp_time_max * 1000
@@ -218,23 +218,69 @@ def test_scenarios(test_name, opts, scenarios, config_manager):
218
218
  has_error = True
219
219
  logging.error("Request per second exceeded: %s", req_sec_stddev)
220
220
 
221
+
221
222
  if opts.get("--report"):
222
- benchmark_report(http_stats_output)
223
- for (
224
- percentile,
225
- threshold,
226
- result,
227
- ) in http_stats_output.percentiles_list_resp_time_store:
228
- if threshold != 0 and result * 1000 >= threshold:
229
- has_error = True
230
- logging.error(
231
- f"Response time at {percentile}th percentile exceeded {threshold}ms: {time_unit_format(result)}"
223
+ percentile_results = (
224
+ http_stats_output.percentiles_list_resp_time_store,
225
+ http_stats_output.percentiles_by_transaction,
226
+ )
227
+ benchmark_report(http_stats_output, percentile_results)
228
+ global_results, transaction_results = percentile_results
229
+ if _check_percentile_thresholds(global_results):
230
+ has_error = True
231
+ for transaction, results in transaction_results.items():
232
+ if http_stats_output.transaction_stats[transaction].req_total == 0:
233
+ logging.warning(
234
+ f"[{transaction}] No responses recorded for this transaction; "
235
+ "check the name matches the transaction exactly"
232
236
  )
237
+ continue
238
+ if _check_percentile_thresholds(results, transaction):
239
+ has_error = True
233
240
 
234
241
  if has_error:
235
242
  raise Exception("Mite test failed")
236
243
 
237
244
 
245
+ def _check_error_thresholds(http_stats_output):
246
+ """Log error threshold breaches; return True if any were breached.
247
+
248
+ An error threshold of 0 allows no errors.
249
+ """
250
+ breached = False
251
+ if http_stats_output.max_errors_threshold < http_stats_output.error_total:
252
+ breached = True
253
+ logging.error("Error count exceeded: %s", http_stats_output.error_total)
254
+
255
+ error_thresholds = http_stats_output.transaction_max_errors_thresholds
256
+ for transaction, threshold in error_thresholds.items():
257
+ errors = http_stats_output.transaction_stats[transaction].error_total
258
+ if errors > threshold:
259
+ breached = True
260
+ logging.error(f"[{transaction}] Error count exceeded {threshold}: {errors}")
261
+ return breached
262
+
263
+
264
+ def _check_percentile_thresholds(results, transaction=None):
265
+ """Log percentile threshold breaches; return True if any were breached."""
266
+ prefix = f"[{transaction}] " if transaction else ""
267
+ breached = False
268
+ for percentile, threshold, result in results:
269
+ if threshold == 0:
270
+ continue
271
+ if result is None:
272
+ logging.warning(
273
+ f"{prefix}Not enough samples to check the {percentile}th percentile "
274
+ f"against {threshold}ms"
275
+ )
276
+ elif result * 1000 >= threshold:
277
+ breached = True
278
+ logging.error(
279
+ f"{prefix}Response time at {percentile}th percentile exceeded {threshold}ms: {time_unit_format(result)}"
280
+ )
281
+ return breached
282
+
283
+
238
284
  def human_readable_bytes(size):
239
285
  for unit in ["B", "KB", "MB", "GB", "TB"]:
240
286
  if size < 1024.0:
@@ -243,75 +289,140 @@ def human_readable_bytes(size):
243
289
  return size, "PB"
244
290
 
245
291
 
292
+ def _mark(text, passed):
293
+ if passed:
294
+ return f"\033[92m{text} \u2713\033[0m" # green, tick
295
+ return f"\033[91m{text} \u2717\033[0m" # red, cross
296
+
297
+
298
+ def _with_limit(text, passed, limit):
299
+ """A cell showing a result, marked pass/fail, with its limit underneath."""
300
+ if passed is None:
301
+ return f"{text}\n{limit}"
302
+ return f"{_mark(text, passed)}\n{limit}"
303
+
304
+
246
305
  def colorise_result(result, threshold):
247
- formatted_result = time_unit_format(result)
248
- if threshold != 0:
249
- result_ms = result * 1000
250
- if result_ms >= threshold:
251
- return f"\033[91m{formatted_result}\033[0m" # red
252
- else:
253
- return f"\033[92m{formatted_result}\033[0m" # green
254
- return formatted_result
306
+ """A percentile cell; a threshold of 0 means report only."""
307
+ text = "N/A" if result is None else time_unit_format(result)
308
+ if threshold == 0:
309
+ return text
310
+ passed = None if result is None else result * 1000 < threshold
311
+ return _with_limit(text, passed, f"<{threshold}ms")
255
312
 
256
313
 
257
- def benchmark_report(http_stats_output):
258
- perctile_thresh_results_list = http_stats_output.percentiles_list_resp_time_store
314
+ def _errors_cell(errors, threshold):
315
+ """An error count cell. Unlike latency thresholds, 0 allows no errors."""
316
+ if threshold is None:
317
+ return str(errors)
318
+ return _with_limit(str(errors), errors <= threshold, f"\u2264{threshold}")
259
319
 
260
- percentiles_headers = [
261
- f"{int(percentile[0])} %tile" for percentile in perctile_thresh_results_list
262
- ]
263
- standard_headers = ["", "Avg", "Min", "Max", "Std Dev", "+/- Std Dev"]
264
320
 
265
- latency_table = PrettyTable()
266
- latency_table.field_names = standard_headers + percentiles_headers
267
-
268
- latency_table.add_row(
269
- [
270
- "Latency",
271
- time_unit_format(http_stats_output.mean_resp_time),
272
- time_unit_format(http_stats_output._resp_time_min),
273
- time_unit_format(http_stats_output._resp_time_max),
274
- time_unit_format(http_stats_output.resp_time_standard_deviation),
275
- f"{http_stats_output.resp_time_within_standard_deviation:.2f}%",
276
- *[
277
- colorise_result(result, threshold)
278
- for _, threshold, result in perctile_thresh_results_list
279
- ],
321
+ LEGEND = (
322
+ "\u2713 pass \u2717 fail "
323
+ "Limits: <ms for percentiles, \u2264count for errors (\u22640 = no errors allowed)"
324
+ )
325
+ STAT_HEADERS = ["Avg", "Min", "Max", "Std Dev", "+/- Std Dev"]
326
+
327
+
328
+ def _or_na(formatter, value):
329
+ return "N/A" if value is None else formatter(value)
330
+
331
+
332
+ def _number_format(number):
333
+ return f"{number / 1000:.2f}K" if number >= 1000 else f"{number:.2f}"
334
+
335
+
336
+ def _percent_format(number):
337
+ return f"{number:.2f}%"
338
+
339
+
340
+ def _latency_row(label, bucket, results, percentiles, error_threshold):
341
+ """A latency row with a cell for each of `percentiles`; "-" where the
342
+ row doesn't report that percentile."""
343
+ by_pct = {p: (t, r) for p, t, r in results}
344
+ return [
345
+ label,
346
+ _or_na(time_unit_format, bucket.resp_time_mean),
347
+ _or_na(time_unit_format, bucket.resp_time_min),
348
+ _or_na(time_unit_format, bucket.resp_time_max),
349
+ _or_na(time_unit_format, bucket.resp_time_stdev),
350
+ _or_na(_percent_format, bucket.resp_time_within_stdev),
351
+ *[
352
+ colorise_result(by_pct[p][1], by_pct[p][0]) if p in by_pct else "-"
353
+ for p in percentiles
280
354
  ],
281
- divider=True,
355
+ _errors_cell(bucket.error_total, error_threshold),
356
+ ]
357
+
358
+
359
+ def _req_sec_row(label, bucket):
360
+ return [
361
+ label,
362
+ _or_na(_number_format, bucket.req_sec_mean),
363
+ _or_na(_number_format, bucket.req_sec_min),
364
+ _or_na(_number_format, bucket.req_sec_max),
365
+ _or_na(_number_format, bucket.req_sec_stdev),
366
+ _or_na(_percent_format, bucket.req_sec_within_stdev),
367
+ bucket.req_total,
368
+ bucket.error_total,
369
+ ]
370
+
371
+
372
+ def _report_rows(http_stats_output, percentile_results):
373
+ """(label, bucket, percentile results, error threshold) for the run as a
374
+ whole, labelled "*", followed by each configured transaction."""
375
+ global_results, transaction_results = percentile_results
376
+ error_thresholds = http_stats_output.transaction_max_errors_thresholds
377
+ yield (
378
+ ALL_TRANSACTIONS_KEY,
379
+ http_stats_output._global,
380
+ global_results,
381
+ http_stats_output.max_errors_threshold,
282
382
  )
383
+ for transaction, bucket in sorted(http_stats_output.transaction_stats.items()):
384
+ yield (
385
+ transaction,
386
+ bucket,
387
+ transaction_results[transaction],
388
+ error_thresholds.get(transaction),
389
+ )
390
+
283
391
 
284
- if any(threshold[1] != 0 for threshold in perctile_thresh_results_list):
392
+ def _report_tables(http_stats_output, percentile_results):
393
+ rows = list(_report_rows(http_stats_output, percentile_results))
394
+ # Rows can have different percentile specs, so use the union of them
395
+ percentiles = sorted({p for _, _, results, _ in rows for p, _, _ in results})
396
+
397
+ latency_table = PrettyTable()
398
+ latency_table.field_names = [
399
+ "Transaction",
400
+ *STAT_HEADERS,
401
+ *[f"{p} %tile" for p in percentiles],
402
+ "Errors",
403
+ ]
404
+ requests_table = PrettyTable()
405
+ requests_table.field_names = ["Transaction", *STAT_HEADERS, "#Reqs", "#Errs"]
406
+ for table in (latency_table, requests_table):
407
+ table.align["Transaction"] = "l"
408
+
409
+ for label, bucket, results, error_threshold in rows:
285
410
  latency_table.add_row(
286
- [
287
- "Test Thresholds",
288
- *["-" for _ in range(len(standard_headers) - 1)],
289
- *[
290
- f"{threshold[1]}ms" if threshold[1] != 0 else "-"
291
- for threshold in perctile_thresh_results_list
292
- ],
293
- ],
411
+ _latency_row(label, bucket, results, percentiles, error_threshold),
412
+ divider=True,
294
413
  )
414
+ requests_table.add_row(_req_sec_row(label, bucket))
415
+ return latency_table, requests_table
295
416
 
296
- requests_table = PrettyTable()
297
- requests_table.field_names = standard_headers
298
- number_format = (
299
- lambda number: f"{number / 1000:.2f}K" if number >= 1000 else f"{number:.2f}"
300
- )
301
- requests_table.add_row(
302
- [
303
- "Req/Sec",
304
- number_format(http_stats_output.req_sec_mean),
305
- number_format(http_stats_output._req_sec_min),
306
- number_format(http_stats_output._req_sec_max),
307
- number_format(http_stats_output.req_sec_standard_deviation),
308
- f"{http_stats_output.req_sec_within_standard_deviation:.2f}%",
309
- ]
310
- )
311
417
 
418
+ def benchmark_report(http_stats_output, percentile_results):
419
+ latency_table, requests_table = _report_tables(http_stats_output, percentile_results)
312
420
  data_transfer, data_unit = human_readable_bytes(http_stats_output._data_transferred)
313
421
  print("\n" + "=" * 20 + " MITE Benchmark Report " + "=" * 20, end="\n\n")
314
- print(latency_table, end="\n\n")
422
+ print("Latency")
423
+ print(latency_table)
424
+ print(LEGEND, end="\n\n")
425
+ print("Req/Sec")
315
426
  print(requests_table, end="\n\n")
316
427
  print("=" * 27 + " Summary " + "=" * 27)
317
428
  print(