TempestParser 3.0.0__py3-none-any.whl

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.
@@ -0,0 +1,327 @@
1
+ import argparse
2
+ import logging
3
+ import os
4
+ import sys
5
+ from collections.abc import Iterable, Sequence
6
+ from datetime import UTC, datetime
7
+ from importlib import metadata
8
+ from typing import IO, Any, NoReturn, Protocol
9
+
10
+ from tempest_parser.const import InputFormat
11
+ from tempest_parser.manager.importers import (
12
+ XML_TIME_UNITS,
13
+ CSVImporter,
14
+ JSONImporter,
15
+ SubunitImporter,
16
+ XMLImporter,
17
+ )
18
+ from tempest_parser.manager.test_manager import TestsManager
19
+ from tempest_parser.parser.tempest_log_parser import TempestLogParser
20
+ from tempest_parser.reports import reporter
21
+ from tempest_parser.reports.csv_reporter import CSVReporter
22
+ from tempest_parser.reports.json_reporter import JSONReporter, failing_results
23
+ from tempest_parser.utils.config import ParserConfigFile
24
+
25
+ pkg_dir = os.path.normpath(os.path.dirname(__file__))
26
+
27
+ log = logging.getLogger("tempest_parser")
28
+
29
+ # exit code when --fail-on finds results with the given statuses
30
+ EXIT_FAILED_TESTS = 3
31
+
32
+
33
+ class CLIError(Exception):
34
+ """Stops the run with an error message and exit code 1."""
35
+
36
+
37
+ class Importer(Protocol):
38
+ """What every input format's importer provides."""
39
+
40
+ def parse(self) -> None: ...
41
+
42
+
43
+ # (source: a path or an open stream, its format if known, the --force-single run name)
44
+ Input = tuple[str | IO[Any], InputFormat | None, str | None]
45
+
46
+
47
+ class MyParser(argparse.ArgumentParser):
48
+ def error(self, message: str) -> NoReturn:
49
+ sys.stderr.write(f'Error: {message}\n\n')
50
+ self.print_help()
51
+ sys.exit(2)
52
+
53
+
54
+ class _Formatter(logging.Formatter):
55
+ """Plain messages; errors and warnings get a prefix."""
56
+
57
+ def format(self, record: logging.LogRecord) -> str:
58
+ message = super().format(record)
59
+ if record.levelno >= logging.ERROR:
60
+ return "Error: " + message
61
+ if record.levelno >= logging.WARNING:
62
+ return "Warning: " + message
63
+ return message
64
+
65
+
66
+ def setup_logging(quiet: bool = False) -> None:
67
+ # test names and messages can hold any character; a console that can't show one
68
+ # (Windows code pages, an ASCII locale) gets an escape instead of an error
69
+ if hasattr(sys.stdout, "reconfigure"):
70
+ sys.stdout.reconfigure(errors="backslashreplace")
71
+ handler = logging.StreamHandler(sys.stdout)
72
+ handler.setFormatter(_Formatter("%(message)s"))
73
+ log.handlers[:] = [handler]
74
+ log.setLevel(logging.ERROR if quiet else logging.INFO)
75
+ log.propagate = False
76
+
77
+
78
+ def detect_format_from_filename(filename: str) -> InputFormat | None:
79
+ """Input format for a file name, or None when the extension is not known."""
80
+ return InputFormat.from_filename(filename)
81
+
82
+
83
+ def parse_run_date(value: str) -> datetime:
84
+ """--run-date: an ISO 8601 date or date and time; without a time zone it is UTC."""
85
+ try:
86
+ date = datetime.fromisoformat(value)
87
+ except ValueError:
88
+ raise argparse.ArgumentTypeError(
89
+ f"not an ISO 8601 date: '{value}' (e.g. 2026-11-23 or 2026-11-23T14:30)") from None
90
+ if date.tzinfo is None:
91
+ return date.replace(tzinfo=UTC)
92
+ return date.astimezone(UTC)
93
+
94
+
95
+ def make_importer(fmt: InputFormat | None, tm: TestsManager, source: IO[Any],
96
+ force_single: str | None = None, filters: Iterable[str] | None = None,
97
+ run_name: str | None = None, run_date: datetime | None = None,
98
+ xml_time_unit: str | None = None) -> Importer:
99
+ kw: dict[str, Any] = {
100
+ "status_filters": filters or [], "run_name": run_name, "run_date": run_date}
101
+ if fmt == InputFormat.RALLY_JSON:
102
+ return JSONImporter(tm, source, **kw)
103
+ if fmt == InputFormat.CSV:
104
+ return CSVImporter(tm, source, **kw)
105
+ if fmt in (InputFormat.XML_TEMPEST, InputFormat.XML_RAW):
106
+ # raw XML keeps the test names as they are
107
+ return XMLImporter(tm, source,
108
+ use_raw_names=fmt == InputFormat.XML_RAW,
109
+ force_single_execution=force_single, time_unit=xml_time_unit,
110
+ **kw)
111
+ if fmt == InputFormat.LOG:
112
+ return TempestLogParser(tm, source, **kw)
113
+ if fmt == InputFormat.SUBUNIT:
114
+ return SubunitImporter(tm, source, **kw)
115
+ raise CLIError(f"Unknown input format: {fmt}")
116
+
117
+
118
+ def do_parse_file(source: str | IO[Any], tm: TestsManager, fmt: InputFormat | None = None,
119
+ force_single: str | None = None, filters: Iterable[str] | None = None,
120
+ run_name: str | None = None, run_date: datetime | None = None,
121
+ xml_time_unit: str | None = None) -> None:
122
+ """Import one file (a path) or stream (an open file, e.g. stdin)."""
123
+ if not isinstance(source, str):
124
+ if fmt != InputFormat.SUBUNIT and hasattr(source, "reconfigure"):
125
+ # text piped in is read as UTF-8 whatever the locale (subunit reads bytes)
126
+ source.reconfigure(encoding="utf-8")
127
+ make_importer(fmt, tm, source, force_single, filters, run_name, run_date,
128
+ xml_time_unit).parse()
129
+ log.info("Imported %s", getattr(source, "name", "unknown/stdin"))
130
+ return
131
+ if fmt is None:
132
+ fmt = detect_format_from_filename(source)
133
+ if fmt is None:
134
+ raise CLIError(
135
+ f"Input filename's extension is not supported: '{source}'")
136
+ # input files are UTF-8 (not the locale's code page, as on Windows before Python 3.15)
137
+ with open(source, encoding="utf-8") as stream:
138
+ make_importer(fmt, tm, stream, force_single, filters, run_name, run_date,
139
+ xml_time_unit).parse()
140
+ log.info("Imported %s", source)
141
+
142
+
143
+ def package_version() -> str:
144
+ """The installed package's version (from the git tag at build time)."""
145
+ try:
146
+ return metadata.version("TempestParser")
147
+ except metadata.PackageNotFoundError:
148
+ return "unknown (not installed)"
149
+
150
+
151
+ # --html-layout: the (trending, errors) report classes for each layout
152
+ HTML_LAYOUTS: dict[str, tuple[type[reporter.HTMLTrendingReport],
153
+ type[reporter.HTMLErrorsReport]]] = {
154
+ "table": (reporter.HTMLTrendingReport, reporter.HTMLErrorsReport),
155
+ "grid": (reporter.HTMLTrendingGridReport, reporter.HTMLErrorsGridReport),
156
+ }
157
+
158
+
159
+ def build_parser() -> MyParser:
160
+ parser = MyParser(prog="Tempest CLI Parser")
161
+ parser.add_argument(
162
+ "-V", "--version", action="version", version=f"tparser {package_version()}")
163
+ parser.add_argument(
164
+ "inputfile", nargs="?", default=sys.stdin,
165
+ help="File with test results or a folder of them; stdin when omitted")
166
+ parser.add_argument(
167
+ "-f", "--input-format", choices=sorted(InputFormat),
168
+ help="Input format. Detected from the file extension when not set; "
169
+ "stdin defaults to subunit")
170
+ parser.add_argument(
171
+ "--omit-status", action="append", default=[], metavar="STATUS",
172
+ help="Leave tests with this status (OK, FAIL, ERROR, SKIP, ...) out of "
173
+ "the reports. Can be used several times")
174
+ parser.add_argument(
175
+ "-d", "--detailed", action="store_true",
176
+ help="Include a messages column with tracebacks. Default comes from config")
177
+ parser.add_argument(
178
+ "-i", "--include-required", action="store_true",
179
+ help="Add the baseline test list from the config as the first column")
180
+ parser.add_argument("-c", "--csv-file", help="Write the CSV report")
181
+ parser.add_argument(
182
+ "-j", "--json-file", help="Write a JSON summary of the runs (counts, times, dates)")
183
+ parser.add_argument(
184
+ "--fail-on", action="append", default=[], metavar="STATUS", type=str.upper,
185
+ help=f"Exit with code {EXIT_FAILED_TESTS} when any run has a test with this status "
186
+ "(FAIL, ERROR, ...). Can be used several times")
187
+ parser.add_argument(
188
+ "--config-file",
189
+ help="Use this configuration file (absolute path) instead of the packaged one")
190
+ parser.add_argument(
191
+ "--force-single", action="store_true",
192
+ help="Treat all files in a folder as a single run (XML input)")
193
+ parser.add_argument(
194
+ "--run-name", metavar="NAME",
195
+ help="Name of the run in the reports instead of the file name (single input only)")
196
+ parser.add_argument(
197
+ "--run-date", metavar="DATE", type=parse_run_date,
198
+ help="Date of the run, ISO 8601 (2026-11-23 or 2026-11-23T14:30, UTC unless an "
199
+ "offset is given), instead of the file's modification time (single input only)")
200
+ parser.add_argument(
201
+ "--xml-time-unit", choices=sorted(XML_TIME_UNITS),
202
+ help="Unit of the XML time attributes: s or ms. Default: seconds when any time in the "
203
+ "file has a decimal point, else milliseconds")
204
+ parser.add_argument(
205
+ "-r", "--html-trending-filename", help="Write the HTML trending report")
206
+ parser.add_argument(
207
+ "--html-layout", choices=sorted(HTML_LAYOUTS), default="table",
208
+ help="Layout of the HTML reports: tables (default) or CSS grid (sticky headers, "
209
+ "light/dark switch, collapsible error groups)")
210
+ parser.add_argument(
211
+ "-e", "--html-errors-filename",
212
+ help="Write the HTML unique errors report (single file input only)")
213
+ parser.add_argument(
214
+ "-q", "--quiet", action="store_true", help="Print errors only")
215
+ return parser
216
+
217
+
218
+ def load_config(args: argparse.Namespace) -> ParserConfigFile:
219
+ path = args.config_file or os.path.join(pkg_dir, 'etc', 'tempest-parser.conf')
220
+ return ParserConfigFile(path)
221
+
222
+
223
+ def collect_inputs(args: argparse.Namespace, input_fmt: InputFormat | None) -> list[Input]:
224
+ """[(source, format, force_single)] to import, in order."""
225
+ source = args.inputfile
226
+ if hasattr(source, "name"):
227
+ if source.name != "<stdin>":
228
+ raise CLIError(f"Unknown PIPE: '{source.name}', '<stdin>' expected")
229
+ fmt = input_fmt if input_fmt is not None else InputFormat.SUBUNIT
230
+ if input_fmt is None:
231
+ log.info("No PIPE format set, defaulted to: '%s'", fmt.label)
232
+ log.info("Reading '%s' from '%s'", fmt.label, source.name)
233
+ return [(source, fmt, None)]
234
+
235
+ if not os.path.exists(source):
236
+ raise CLIError(f"Supplied path/file not exists, '{source}'")
237
+ if os.path.isfile(source):
238
+ return [(source, input_fmt, None)]
239
+ if args.html_errors_filename:
240
+ raise CLIError(
241
+ f"Errors report require single file, folder given: '{source}'")
242
+ if args.run_name or args.run_date:
243
+ raise CLIError(
244
+ f"--run-name and --run-date need a single file, folder given: '{source}'")
245
+
246
+ log.info("Importing tests from folder '%s'", source)
247
+ inputs = []
248
+ for name in sorted(os.listdir(source)):
249
+ if input_fmt is None:
250
+ if detect_format_from_filename(name) is None:
251
+ log.info("Skipped '%s', extension is not supported", name)
252
+ continue
253
+ elif not name.endswith(input_fmt.label):
254
+ log.info("Skipped '%s', extension not corresponds to given format (%s)",
255
+ name, input_fmt.label)
256
+ continue
257
+ inputs.append((os.path.join(source, name), input_fmt,
258
+ source if args.force_single else None))
259
+ return inputs
260
+
261
+
262
+ def write_reports(args: argparse.Namespace, tests_manager: TestsManager,
263
+ detailed: bool) -> None:
264
+ if args.html_trending_filename:
265
+ log.info("Generating HTML Trending report...")
266
+ trending = HTML_LAYOUTS[args.html_layout][0]()
267
+ reporter.ReportToFile(trending, args.html_trending_filename)(
268
+ tests_manager, detailed=detailed)
269
+ if args.html_errors_filename:
270
+ log.info("Generating HTML Errors report...")
271
+ errors = HTML_LAYOUTS[args.html_layout][1]()
272
+ reporter.ReportToFile(errors, args.html_errors_filename)(tests_manager)
273
+ if args.csv_file is not None:
274
+ log.info("Generating CSV report...")
275
+ CSVReporter(tests_manager).generate_to_file(args.csv_file, detailed=detailed)
276
+ if args.json_file is not None:
277
+ log.info("Generating JSON summary...")
278
+ JSONReporter(tests_manager).generate_to_file(args.json_file)
279
+
280
+
281
+ def check_fail_on(statuses: Iterable[str], tests_manager: TestsManager) -> int:
282
+ """Exit code for --fail-on: EXIT_FAILED_TESTS when a result has one of the statuses."""
283
+ found = failing_results(tests_manager, statuses)
284
+ if not found:
285
+ return 0
286
+ for run, class_name, test_name, status in found:
287
+ log.warning("%s: %s.%s %s", run, class_name, test_name, status)
288
+ log.error("%d test result(s) with status %s", len(found), ", ".join(sorted(set(statuses))))
289
+ return EXIT_FAILED_TESTS
290
+
291
+
292
+ def run(args: argparse.Namespace) -> int:
293
+ config = load_config(args)
294
+ detailed = args.detailed or config.get_detailed_column_default_value()
295
+ input_fmt = InputFormat(args.input_format) if args.input_format else None
296
+
297
+ inputs = collect_inputs(args, input_fmt)
298
+
299
+ tests_manager = TestsManager()
300
+ if args.include_required and args.html_errors_filename is None:
301
+ baseline = config.get_all_tests_list_filepath()
302
+ log.info("Preloading all tests from '%s'", baseline)
303
+ tests_manager.add_required(
304
+ baseline, use_raw_names=input_fmt == InputFormat.XML_RAW)
305
+
306
+ for source, fmt, force_single in inputs:
307
+ do_parse_file(source, tests_manager, fmt=fmt, force_single=force_single,
308
+ filters=args.omit_status, run_name=args.run_name,
309
+ run_date=args.run_date, xml_time_unit=args.xml_time_unit)
310
+
311
+ write_reports(args, tests_manager, detailed)
312
+ return check_fail_on(args.fail_on, tests_manager) if args.fail_on else 0
313
+
314
+
315
+ def tempest_cli_parser_main(argv: Sequence[str] | None = None) -> int:
316
+ """Console entry point; returns the exit code."""
317
+ args = build_parser().parse_args(argv)
318
+ setup_logging(args.quiet)
319
+ try:
320
+ return run(args)
321
+ except CLIError as e:
322
+ log.error("%s", e)
323
+ return 1
324
+
325
+
326
+ if __name__ == '__main__':
327
+ sys.exit(tempest_cli_parser_main())
File without changes
@@ -0,0 +1,35 @@
1
+ import configparser
2
+ import os
3
+
4
+ pkg_dir = os.path.dirname(__file__)
5
+ pkg_dir = os.path.join(pkg_dir, os.path.pardir)
6
+ pkg_dir = os.path.normpath(pkg_dir)
7
+
8
+
9
+ class ParserConfigFile:
10
+ _truth = ['true', '1', 't', 'y', 'yes', 'yeah', 'yup',
11
+ 'certainly', 'uh-huh']
12
+
13
+ def __init__(self, filepath: str) -> None:
14
+ self.config_file_path = filepath
15
+
16
+ self.section_name = 'ParserConfig'
17
+
18
+ self.config = configparser.ConfigParser()
19
+ self.config.read(self.config_file_path, encoding="utf-8")
20
+
21
+ def get_all_tests_list_filepath(self) -> str:
22
+ # get path
23
+ _path = self.config.get(self.section_name, 'default_test_list')
24
+
25
+ # make sure it is absolute
26
+ if not os.path.isabs(_path):
27
+ return os.path.join(pkg_dir, _path)
28
+ else:
29
+ return _path
30
+
31
+ def get_detailed_column_default_value(self) -> bool:
32
+ # value
33
+ _value = self.config.get(self.section_name, 'default_detailed')
34
+ # parse if
35
+ return _value.lower() in self._truth
@@ -0,0 +1,320 @@
1
+ Metadata-Version: 2.4
2
+ Name: TempestParser
3
+ Version: 3.0.0
4
+ Summary: Builds trending HTML and CSV reports from Tempest, pytest, Rally, k8s conformance and subunit test results.
5
+ Author-email: Alex Savatieiev <a.savex@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/savex/tempest-parser
8
+ Project-URL: Changelog, https://github.com/savex/tempest-parser/blob/master/changelog.md
9
+ Project-URL: Issues, https://github.com/savex/tempest-parser/issues
10
+ Keywords: QA,tempest,openstack,kubernetes,pytest,subunit,html,report
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3.15
21
+ Classifier: Topic :: Software Development :: Quality Assurance
22
+ Classifier: Topic :: Software Development :: Testing
23
+ Requires-Python: >=3.11
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: jinja2>=3.1
27
+ Requires-Dist: markupsafe>=2.1
28
+ Requires-Dist: python-subunit>=1.4
29
+ Requires-Dist: testtools>=2.5
30
+ Dynamic: license-file
31
+
32
+ # tempest-parser
33
+
34
+ [![Tests](https://github.com/savex/tempest-parser/actions/workflows/tests.yml/badge.svg)](https://github.com/savex/tempest-parser/actions/workflows/tests.yml)
35
+ [![Release](https://github.com/savex/tempest-parser/actions/workflows/release.yml/badge.svg)](https://github.com/savex/tempest-parser/actions/workflows/release.yml)
36
+ [![Version tracking](https://github.com/savex/tempest-parser/actions/workflows/version.yml/badge.svg)](https://github.com/savex/tempest-parser/actions/workflows/version.yml)
37
+ [![PyPI](https://img.shields.io/pypi/v/TempestParser.svg)](https://pypi.org/project/TempestParser/)
38
+ ![Python 3.11–3.15](https://img.shields.io/badge/python-3.11%E2%80%933.15-blue.svg)
39
+ ![Platforms](https://img.shields.io/badge/platforms-Linux%20%7C%20macOS%20%7C%20Windows-blue.svg)
40
+ [![License](https://img.shields.io/badge/license-Apache%202.0-green.svg)](https://github.com/savex/tempest-parser/blob/master/LICENSE)
41
+
42
+ Imports test results from many runs, matches the tests by class, name and options, and builds HTML and CSV
43
+ reports to track their statuses over time.
44
+
45
+ > **Status: maintained.** All six input formats and the three reports work and are covered by tests in CI.
46
+ > The latest release is [3.0.0](https://github.com/savex/tempest-parser/releases/tag/v3.0.0), on
47
+ > [PyPI](https://pypi.org/project/TempestParser/). See [Project status](#project-status).
48
+
49
+ ## Foreword
50
+
51
+ When you run tempest, you probably want to review the results in a human manner.
52
+
53
+ You run it once again... and again... and a couple more times the next day... and you end up with 20+ files
54
+ in the `.testrepository` folder. You start digging into how a specific tempest test ran yesterday and how its
55
+ result changed today. `grep`, `less`... Brain goes hot.
56
+
57
+ Honestly, Subunit's CLI output is good enough for reading the word PASSED at the end... and the summary.
58
+
59
+ So, there is a need to:
60
+ - import tempest test results
61
+ - match tests by class, test name and options
62
+ - produce a report to work with test statuses and track them over time
63
+ - have error messages added to the report
64
+
65
+ ## Example reports
66
+
67
+ Made by `tparser` from four made-up runs in
68
+ [tests/data/trending](https://github.com/savex/tempest-parser/tree/master/tests/data/trending); the commands are in
69
+ [examples/README.md](https://github.com/savex/tempest-parser/blob/master/examples/README.md). Open a report in the browser with **view**, or download it
70
+ with **source**.
71
+
72
+ | Report | Command | Files |
73
+ |---|---|---|
74
+ | Trending, table | `tparser -d -r trending.html runs/` | [view](https://htmlpreview.github.io/?https://github.com/savex/tempest-parser/blob/master/examples/trending_report.html) · [source](https://github.com/savex/tempest-parser/blob/master/examples/trending_report.html) |
75
+ | Trending, table, without messages | `tparser -r trending.html runs/` | [view](https://htmlpreview.github.io/?https://github.com/savex/tempest-parser/blob/master/examples/trending_report_brief.html) · [source](https://github.com/savex/tempest-parser/blob/master/examples/trending_report_brief.html) |
76
+ | Trending, grid | `tparser -d -r trending.html --html-layout grid runs/` | [view](https://htmlpreview.github.io/?https://github.com/savex/tempest-parser/blob/master/examples/trending_report_grid.html) · [source](https://github.com/savex/tempest-parser/blob/master/examples/trending_report_grid.html) |
77
+ | Unique errors, table | `tparser -e errors.html run_4.log` | [view](https://htmlpreview.github.io/?https://github.com/savex/tempest-parser/blob/master/examples/errors_report_run_4.html) · [source](https://github.com/savex/tempest-parser/blob/master/examples/errors_report_run_4.html) |
78
+ | Unique errors, grid | `tparser -e errors.html --html-layout grid run_4.log` | [view](https://htmlpreview.github.io/?https://github.com/savex/tempest-parser/blob/master/examples/errors_report_run_4_grid.html) · [source](https://github.com/savex/tempest-parser/blob/master/examples/errors_report_run_4_grid.html) |
79
+
80
+ **Trending report** (`-r`, table layout): one row per test, one column per run, with each run's totals,
81
+ times under the statuses (the slowest in bold) and a filter bar.
82
+
83
+ ![Trending report, table layout](https://raw.githubusercontent.com/savex/tempest-parser/master/examples/screenshots/trending_table.png)
84
+
85
+ **Trending report, grid layout** (`--html-layout grid`) in dark mode: the header and test names stay in
86
+ view while scrolling; the icons at the top right switch between system, light and dark colours.
87
+
88
+ ![Trending report, grid layout, dark](https://raw.githubusercontent.com/savex/tempest-parser/master/examples/screenshots/trending_grid_dark.png)
89
+
90
+ **Unique errors report, grid layout** (`-e --html-layout grid`): failures and skips grouped by message,
91
+ each group opening to its tests and times.
92
+
93
+ ![Unique errors report, grid layout](https://raw.githubusercontent.com/savex/tempest-parser/master/examples/screenshots/errors_grid.png)
94
+
95
+ ## Installing
96
+
97
+ The latest published version can be installed with pip:
98
+
99
+ ```bash
100
+ pip install tempestparser
101
+ ```
102
+
103
+ or from a cloned git repo:
104
+
105
+ ```bash
106
+ pip install .
107
+ ```
108
+
109
+ ## Usage
110
+
111
+ The tool was originally made for an "import, match, export" flow: produce a CSV with tests matched by class
112
+ and name against the list of tests that was originally executed.
113
+
114
+ ```bash
115
+ tparser -c matched.csv tempest.log
116
+ ```
117
+
118
+ A folder can be used too:
119
+
120
+ ```bash
121
+ tparser -c matched.csv folder1
122
+ ```
123
+
124
+ HTML trending report:
125
+
126
+ ```bash
127
+ tparser -f t_xml -r trending.html tempest.xml
128
+ ```
129
+
130
+ or
131
+
132
+ ```bash
133
+ tparser -f t_xml -r trending.html folder1
134
+ ```
135
+
136
+ The report has a filter bar: type words from a class or test name, or show only tests that failed in any
137
+ run, failed in the last run, or changed status. Each result shows the test's time (the slowest in bold),
138
+ and each class row the class's total time per run. Add messages and tracebacks to the report with `-d`
139
+ (tracebacks are folded; click **Trace** to open one):
140
+
141
+ ```bash
142
+ tparser -f t_xml -r trending.html -d folder1
143
+ ```
144
+
145
+ `--html-layout grid` lays the same report out with CSS grid instead of a table: the header and the test
146
+ names stay in view while scrolling, and it follows the system's dark mode or a light / dark switch
147
+ next to the title. It needs a browser from 2024 or later:
148
+
149
+ ```bash
150
+ tparser -r trending.html --html-layout grid folder1
151
+ ```
152
+
153
+ To avoid scrolling the report back and forth, you can produce a unique errors report (see below).
154
+ Note that it needs a single test run file:
155
+
156
+ ```bash
157
+ tparser -e errors.html single_run.json
158
+ ```
159
+
160
+ This report groups FAILs and SKIPs by their main message to produce lists of unique errors and skips.
161
+ With `--html-layout grid`, each message is a collapsible group with a filter, **Expand all** /
162
+ **Collapse all** buttons and the same light / dark switch as the grid trending report.
163
+ If there is no main message, it is taken from the trace: the line starting with `Details: ` becomes the main
164
+ message, and additional lines are those that:
165
+ - don't start with whitespace (regular expression `\s`)
166
+ - don't start with `Trace`
167
+
168
+ To parse k8s conformance reports, use the raw XML format:
169
+
170
+ ```bash
171
+ tparser -f r_xml -r conformance.html conformance.xml
172
+ ```
173
+
174
+ Conformance and other k8s tests are often spread across several files. They can be combined into a single
175
+ report:
176
+
177
+ ```bash
178
+ tparser -d -r tests.html -f r_xml --force-single conformance_folder
179
+ ```
180
+
181
+ You can also leave specific statuses out of the report, say 2k+ SKIPs. `--omit-status` can be used several
182
+ times:
183
+
184
+ ```bash
185
+ tparser -d -r tests.html -f r_xml --force-single --omit-status OK conformance_folder
186
+ ```
187
+
188
+ Results can be piped in as a subunit stream:
189
+
190
+ ```bash
191
+ stestr last --subunit | tparser -r trending.html
192
+ ```
193
+
194
+ In a CI pipeline, write a JSON summary of the runs and fail the step (exit code 3) when tests failed:
195
+
196
+ ```bash
197
+ stestr last --subunit | tparser -r trending.html -j summary.json --fail-on FAIL --fail-on ERROR
198
+ ```
199
+
200
+ ### Options
201
+
202
+ | Option | Meaning |
203
+ |---|---|
204
+ | `-f, --input-format` | `log`, `t_xml`, `r_xml`, `json`, `csv` or `subunit`. Detected from the extension when omitted; stdin defaults to `subunit`. |
205
+ | `-r, --html-trending-filename` | Write the HTML trending report. |
206
+ | `--xml-time-unit` | Unit of XML test times, `s` or `ms`. Without it, a file with whole numbers only is read as milliseconds. |
207
+ | `--html-layout` | HTML report layout (`-r` and `-e`): `table` (default) or `grid` (CSS grid, sticky headers, light / dark switch). |
208
+ | `-e, --html-errors-filename` | Write the HTML unique errors report (single file input only). |
209
+ | `-c, --csv-file` | Write the CSV report. |
210
+ | `-j, --json-file` | Write a JSON summary: per run its name, file, date, counts per status and total time. |
211
+ | `--fail-on` | Exit with code 3 when any run has a test with this status (`FAIL`, `ERROR`, ...). Repeatable. |
212
+ | `-d, --detailed` | Include messages and tracebacks. |
213
+ | `-i, --include-required` | Add the baseline test list from the config as the first column. |
214
+ | `--omit-status` | Leave tests with this status (`OK`, `FAIL`, `ERROR`, `SKIP`, ...) out. Repeatable. |
215
+ | `-q, --quiet` | Print errors only. |
216
+ | `-V, --version` | Print the version and exit. |
217
+ | `--force-single` | Treat all files in a folder as a single run. |
218
+ | `--run-name` | Name of the run in the reports instead of the file name (single file or stdin). |
219
+ | `--run-date` | Date of the run, ISO 8601 (`2026-11-23T14:30`, UTC unless an offset is given), instead of the file's modification time (single file or stdin). |
220
+ | `--config-file` | Use this config file (absolute path) instead of the packaged one. |
221
+
222
+ ## Imported formats
223
+
224
+ ### .log files
225
+ Tempest console output, captured with a redirect (`tempest run ... | tee tempest.log`), from a CI job
226
+ log, or from the numbered files in the `.testrepository` folder. Both the current stestr layout
227
+ (`{0} tempest.api....test_x [1.2s] ... ok`, with `Captured traceback:` sections, the `Totals` summary
228
+ and `stestr --slowest`) and the older testr layout (class lines with indented test lines) are read.
229
+ CI timestamp prefixes such as `2026-01-01 10:00:00.123456 | ` are removed. The log has no date: give one
230
+ with `--run-date`, or the file's modification time is used.
231
+
232
+ ### .xml files
233
+ jUnit XML files exported from subunit (`t_xml`, the default for `.xml`), or raw jUnit XML from k8s
234
+ conformance and pytest (`r_xml`, test names used as is).
235
+
236
+ ### .json files
237
+ [Rally](https://github.com/openstack/rally) tool export:
238
+
239
+ ```bash
240
+ rally verify results --json --output-file result1.json
241
+ ```
242
+
243
+ ### .csv files
244
+ CSV files exported by tparser itself (`-c`), or xunit CSV files. An export with several runs imports
245
+ back as the same runs, dated from its header and named after their files when it was written with `-d`;
246
+ a baseline column (`-i`) comes back as the `required` run. So a CSV can stand in for the original files:
247
+
248
+ ```bash
249
+ tparser -c all_runs.csv folder1
250
+ tparser -r trending.html all_runs.csv
251
+ ```
252
+
253
+ ### .subunit files
254
+ Subunit v2 streams saved to a file.
255
+
256
+ ## Project status
257
+
258
+ | Part | State |
259
+ |---|---|
260
+ | Input: Tempest log, subunit, jUnit XML (Tempest and raw / k8s), Rally JSON, CSV | Done |
261
+ | Reports: HTML trending, HTML unique errors, CSV | Done |
262
+ | Tests (smoke, functional, integration) and CI on Linux, macOS and Windows, Python 3.11–3.15 | Done |
263
+ | Tag-based versioning, Bump version and Release workflows | Done; 0.3.0 and 3.0.0 were released through them |
264
+ | Upload to PyPI from CI | Done (on from 3.0.0) |
265
+ | Project rules for contributors ([CLAUDE.md](https://github.com/savex/tempest-parser/blob/master/CLAUDE.md)) | Done |
266
+
267
+ The plan is in [documents/plan.md](https://github.com/savex/tempest-parser/blob/master/documents/plan.md), the specification in
268
+ [documents/specs.md](https://github.com/savex/tempest-parser/blob/master/documents/specs.md) and the changes in [changelog.md](https://github.com/savex/tempest-parser/blob/master/changelog.md).
269
+
270
+ ## Development
271
+
272
+ With [uv](https://docs.astral.sh/uv/), which creates `.venv` from `uv.lock`:
273
+
274
+ ```bash
275
+ uv sync
276
+ ```
277
+
278
+ ```bash
279
+ uv run pytest
280
+ ```
281
+
282
+ ```bash
283
+ uv run ruff check .
284
+ ```
285
+
286
+ ```bash
287
+ uv run mypy
288
+ ```
289
+
290
+ ```bash
291
+ uv run python scripts/check-test-tags.py
292
+ ```
293
+
294
+ Without uv (pip 25.1 or newer): `python3 -m venv .venv`, then
295
+ `.venv/bin/pip install -e . --group dev`.
296
+
297
+ Dependencies are declared in `pyproject.toml`; after changing them, run `uv lock` and commit `uv.lock`.
298
+ Dependabot proposes weekly updates for `uv.lock` and the GitHub Actions.
299
+
300
+ Tests live in `tests/smoke`, `tests/functional` and `tests/integration`; the folder is the test's tag
301
+ (`pytest -m smoke` runs one tag). Sample inputs are in `tests/data`.
302
+
303
+ Versions come from `v*` git tags: setuptools-scm reads the tag when the package is built, and commits
304
+ after a tag build as `X.Y.Z.devN`. `scripts/version.sh versions` shows the latest tag and the newest
305
+ `changelog.md` release, and whether they agree; see the script's header for the other commands.
306
+
307
+ CI (`.github/workflows`):
308
+ - **Tests** runs on pull requests and pushes to `master`: ruff, mypy, actionlint, package build and
309
+ `twine check`, version and test-tag checks, then the tests on ubuntu, macOS and Windows with Python
310
+ 3.11–3.15, with a minimum coverage (`fail_under` in `pyproject.toml`).
311
+ - **Version tracking** reports the version on every push to `master`.
312
+ - **Bump version** (manual) picks the next version, updates `changelog.md`, commits
313
+ `Release vX.Y.Z`, tags it and starts **Release**.
314
+ - **Release** builds the sdist and wheel, smoke-tests them and publishes a GitHub release with the
315
+ changelog section as notes. PyPI upload runs only when the repository variable `PYPI_PUBLISH` is
316
+ `true`.
317
+
318
+ ## Credits
319
+
320
+ Thanks to Dmitry Bogun, Alexey Diyan and Dmitriy Zapeka.