]> git.proxmox.com Git - mirror_zfs.git/blame - tests/test-runner/bin/zts-report.py
flake8 pass
[mirror_zfs.git] / tests / test-runner / bin / zts-report.py
CommitLineData
6e72a5b9 1#!/usr/bin/python3
e4a3297a
BB
2
3#
4# This file and its contents are supplied under the terms of the
5# Common Development and Distribution License ("CDDL"), version 1.0.
6# You may only use this file in accordance with the terms of version
7# 1.0 of the CDDL.
8#
9# A full copy of the text of the CDDL should have accompanied this
10# source. A copy of the CDDL is also available via the Internet at
11# http://www.illumos.org/license/CDDL.
12#
13
14#
15# Copyright (c) 2017 by Delphix. All rights reserved.
16# Copyright (c) 2018 by Lawrence Livermore National Security, LLC.
17#
6e72a5b9
BB
18# This script must remain compatible with Python 2.6+ and Python 3.4+.
19#
e4a3297a
BB
20
21import os
22import re
23import sys
24
25#
26# This script parses the stdout of zfstest, which has this format:
27#
28# Test: /path/to/testa (run as root) [00:00] [PASS]
29# Test: /path/to/testb (run as jkennedy) [00:00] [PASS]
30# Test: /path/to/testc (run as root) [00:00] [FAIL]
31# [...many more results...]
32#
33# Results Summary
34# FAIL 22
35# SKIP 32
36# PASS 1156
37#
38# Running Time: 02:50:31
39# Percent passed: 95.5%
40# Log directory: /var/tmp/test_results/20180615T205926
41#
42
43#
44# Common generic reasons for a test or test group to be skipped.
45#
46# Some test cases are known to fail in ways which are not harmful or dangerous.
47# In these cases simply mark the test as a known failure until it can be
48# updated and the issue resolved. Note that it's preferable to open a unique
49# issue on the GitHub issue tracker for each test case failure.
50#
51known_reason = 'Known issue'
52
53#
54# Some tests require that a test user be able to execute the zfs utilities.
55# This may not be possible when testing in-tree due to the default permissions
56# on the user's home directory. When testing this can be resolved by granting
57# group read access.
58#
59# chmod 0750 $HOME
60#
61exec_reason = 'Test user execute permissions required for utilities'
62
63#
64# Some tests require that the DISKS provided can be partitioned. This is
65# normally not an issue because loop back devices are used for DISKS and they
66# can be partition. There is one notable exception, the CentOS 6.x kernel is
67# old enough that it does not support partitioning loop back devices.
68#
69disk_reason = 'Partitionable DISKS required'
70
71#
72# Some tests require a minimum python version of 3.5 and will be skipped when
73# the default system version is too old. There may also be tests which require
74# additional python modules be installed, for example python-cffi is required
75# by the pyzfs tests.
76#
77python_reason = 'Python v3.5 or newer required'
78python_deps_reason = 'Python modules missing: python-cffi'
79
80#
81# Some tests require the O_TMPFILE flag which was first introduced in the
82# 3.11 kernel.
83#
84tmpfile_reason = 'Kernel O_TMPFILE support required'
85
d441e85d
BB
86#
87# Some tests may depend on udev change events being generated when block
88# devices change capacity. This functionality wasn't available until the
89# 2.6.38 kernel.
90#
91udev_reason = 'Kernel block device udev change events required'
92
e4a3297a
BB
93#
94# Some tests require that the NFS client and server utilities be installed.
95#
96share_reason = 'NFS client and server utilities required'
97
98#
99# Some tests require that the lsattr utility support the project id feature.
100#
101project_id_reason = 'lsattr with set/show project ID required'
102
103#
104# Some tests require that the kernel support user namespaces.
105#
106user_ns_reason = 'Kernel user namespace support required'
107
108#
109# Some rewind tests can fail since nothing guarantees that old MOS blocks
110# are not overwritten. Snapshots protect datasets and data files but not
111# the MOS. Reasonable efforts are made in the test case to increase the
112# odds that some txgs will have their MOS data left untouched, but it is
113# never a sure thing.
114#
115rewind_reason = 'Arbitrary pool rewind is not guaranteed'
116
e03a41a6
BB
117#
118# Some tests may by structured in a way that relies on exact knowledge
119# of how much free space in available in a pool. These tests cannot be
120# made completely reliable because the internal details of how free space
121# is managed are not exposed to user space.
122#
123enospc_reason = 'Exact free space reporting is not guaranteed'
124
a584ef26
BB
125#
126# Some tests require a minimum version of the fio benchmark utility.
127# Older distributions such as CentOS 6.x only provide fio-2.0.13.
128#
129fio_reason = 'Fio v2.3 or newer required'
130
e4a3297a
BB
131#
132# Some tests are not applicable to Linux or need to be updated to operate
133# in the manor required by Linux. Any tests which are skipped for this
134# reason will be suppressed in the final analysis output.
135#
136na_reason = "N/A on Linux"
137
138summary = {
139 'total': float(0),
140 'passed': float(0),
141 'logfile': "Could not determine logfile location."
142}
143
144#
145# These tests are known to fail, thus we use this list to prevent these
146# failures from failing the job as a whole; only unexpected failures
147# bubble up to cause this script to exit with a non-zero exit status.
148#
149# Format: { 'test-name': ['expected result', 'issue-number | reason'] }
150#
151# For each known failure it is recommended to link to a GitHub issue by
152# setting the reason to the issue number. Alternately, one of the generic
153# reasons listed above can be used.
154#
155known = {
e4a3297a
BB
156 'casenorm/sensitive_none_lookup': ['FAIL', '7633'],
157 'casenorm/sensitive_none_delete': ['FAIL', '7633'],
158 'casenorm/sensitive_formd_lookup': ['FAIL', '7633'],
159 'casenorm/sensitive_formd_delete': ['FAIL', '7633'],
160 'casenorm/insensitive_none_lookup': ['FAIL', '7633'],
161 'casenorm/insensitive_none_delete': ['FAIL', '7633'],
162 'casenorm/insensitive_formd_lookup': ['FAIL', '7633'],
163 'casenorm/insensitive_formd_delete': ['FAIL', '7633'],
164 'casenorm/mixed_none_lookup': ['FAIL', '7633'],
165 'casenorm/mixed_none_lookup_ci': ['FAIL', '7633'],
166 'casenorm/mixed_none_delete': ['FAIL', '7633'],
167 'casenorm/mixed_formd_lookup': ['FAIL', '7633'],
168 'casenorm/mixed_formd_lookup_ci': ['FAIL', '7633'],
169 'casenorm/mixed_formd_delete': ['FAIL', '7633'],
e4a3297a
BB
170 'cli_root/zfs_receive/zfs_receive_004_neg': ['FAIL', known_reason],
171 'cli_root/zfs_unshare/zfs_unshare_002_pos': ['SKIP', na_reason],
172 'cli_root/zfs_unshare/zfs_unshare_006_pos': ['SKIP', na_reason],
173 'cli_root/zpool_create/zpool_create_016_pos': ['SKIP', na_reason],
e4a3297a
BB
174 'cli_user/misc/zfs_share_001_neg': ['SKIP', na_reason],
175 'cli_user/misc/zfs_unshare_001_neg': ['SKIP', na_reason],
176 'inuse/inuse_001_pos': ['SKIP', na_reason],
177 'inuse/inuse_003_pos': ['SKIP', na_reason],
178 'inuse/inuse_006_pos': ['SKIP', na_reason],
179 'inuse/inuse_007_pos': ['SKIP', na_reason],
180 'privilege/setup': ['SKIP', na_reason],
181 'refreserv/refreserv_004_pos': ['FAIL', known_reason],
182 'removal/removal_condense_export': ['SKIP', known_reason],
183 'removal/removal_with_zdb': ['SKIP', known_reason],
184 'rootpool/setup': ['SKIP', na_reason],
185 'rsend/rsend_008_pos': ['SKIP', '6066'],
1bf490ba 186 'snapshot/rollback_003_pos': ['SKIP', '6143'],
e4a3297a
BB
187 'vdev_zaps/vdev_zaps_007_pos': ['FAIL', known_reason],
188 'xattr/xattr_008_pos': ['SKIP', na_reason],
189 'xattr/xattr_009_neg': ['SKIP', na_reason],
190 'xattr/xattr_010_neg': ['SKIP', na_reason],
191 'zvol/zvol_misc/zvol_misc_001_neg': ['SKIP', na_reason],
192 'zvol/zvol_misc/zvol_misc_003_neg': ['SKIP', na_reason],
193 'zvol/zvol_misc/zvol_misc_004_pos': ['SKIP', na_reason],
194 'zvol/zvol_misc/zvol_misc_005_neg': ['SKIP', na_reason],
195 'zvol/zvol_misc/zvol_misc_006_pos': ['SKIP', na_reason],
196 'zvol/zvol_swap/zvol_swap_003_pos': ['SKIP', na_reason],
197 'zvol/zvol_swap/zvol_swap_005_pos': ['SKIP', na_reason],
198 'zvol/zvol_swap/zvol_swap_006_pos': ['SKIP', na_reason],
199}
200
201#
202# These tests may occasionally fail or be skipped. We want there failures
203# to be reported but only unexpected failures should bubble up to cause
204# this script to exit with a non-zero exit status.
205#
206# Format: { 'test-name': ['expected result', 'issue-number | reason'] }
207#
208# For each known failure it is recommended to link to a GitHub issue by
209# setting the reason to the issue number. Alternately, one of the generic
210# reasons listed above can be used.
211#
212maybe = {
213 'cache/setup': ['SKIP', disk_reason],
214 'cache/cache_010_neg': ['FAIL', known_reason],
215 'chattr/setup': ['SKIP', exec_reason],
e4a3297a
BB
216 'cli_root/zdb/zdb_006_pos': ['FAIL', known_reason],
217 'cli_root/zfs_get/zfs_get_004_pos': ['FAIL', known_reason],
218 'cli_root/zfs_get/zfs_get_009_pos': ['SKIP', '5479'],
e4a3297a
BB
219 'cli_root/zfs_rollback/zfs_rollback_001_pos': ['FAIL', '6415'],
220 'cli_root/zfs_rollback/zfs_rollback_002_pos': ['FAIL', '6416'],
221 'cli_root/zfs_share/setup': ['SKIP', share_reason],
222 'cli_root/zfs_snapshot/zfs_snapshot_002_neg': ['FAIL', known_reason],
223 'cli_root/zfs_unshare/setup': ['SKIP', share_reason],
224 'cli_root/zpool_add/setup': ['SKIP', disk_reason],
225 'cli_root/zpool_add/zpool_add_004_pos': ['FAIL', known_reason],
226 'cli_root/zpool_create/setup': ['SKIP', disk_reason],
227 'cli_root/zpool_create/zpool_create_008_pos': ['FAIL', known_reason],
228 'cli_root/zpool_destroy/zpool_destroy_001_pos': ['SKIP', '6145'],
d441e85d 229 'cli_root/zpool_expand/setup': ['SKIP', udev_reason],
e4a3297a
BB
230 'cli_root/zpool_export/setup': ['SKIP', disk_reason],
231 'cli_root/zpool_import/setup': ['SKIP', disk_reason],
232 'cli_root/zpool_import/import_rewind_device_replaced':
233 ['FAIL', rewind_reason],
234 'cli_root/zpool_import/import_rewind_config_changed':
235 ['FAIL', rewind_reason],
236 'cli_root/zpool_import/zpool_import_missing_003_pos': ['SKIP', '6839'],
237 'cli_root/zpool_remove/setup': ['SKIP', disk_reason],
238 'cli_root/zpool_upgrade/zpool_upgrade_004_pos': ['FAIL', '6141'],
239 'cli_user/misc/arc_summary3_001_pos': ['SKIP', python_reason],
240 'delegate/setup': ['SKIP', exec_reason],
241 'fault/auto_online_001_pos': ['SKIP', disk_reason],
242 'fault/auto_replace_001_pos': ['SKIP', disk_reason],
243 'history/history_004_pos': ['FAIL', '7026'],
244 'history/history_005_neg': ['FAIL', '6680'],
245 'history/history_006_neg': ['FAIL', '5657'],
246 'history/history_008_pos': ['FAIL', known_reason],
247 'history/history_010_pos': ['SKIP', exec_reason],
248 'inuse/inuse_005_pos': ['SKIP', disk_reason],
249 'inuse/inuse_008_pos': ['SKIP', disk_reason],
250 'inuse/inuse_009_pos': ['SKIP', disk_reason],
a584ef26 251 'io/mmap': ['SKIP', fio_reason],
e4a3297a
BB
252 'largest_pool/largest_pool_001_pos': ['FAIL', known_reason],
253 'pyzfs/pyzfs_unittest': ['SKIP', python_deps_reason],
e03a41a6 254 'no_space/enospc_002_pos': ['FAIL', enospc_reason],
e4a3297a 255 'projectquota/setup': ['SKIP', exec_reason],
94b197a0 256 'redundancy/redundancy_004_neg': ['FAIL', '7290'],
e106a7ba 257 'reservation/reservation_008_pos': ['FAIL', '7741'],
e4a3297a
BB
258 'reservation/reservation_018_pos': ['FAIL', '5642'],
259 'rsend/rsend_019_pos': ['FAIL', '6086'],
260 'rsend/rsend_020_pos': ['FAIL', '6446'],
261 'rsend/rsend_021_pos': ['FAIL', '6446'],
262 'rsend/rsend_024_pos': ['FAIL', '5665'],
263 'rsend/send-c_volume': ['FAIL', '6087'],
e4a3297a 264 'snapshot/clone_001_pos': ['FAIL', known_reason],
838bd5ff
BB
265 'snapshot/snapshot_009_pos': ['FAIL', '7961'],
266 'snapshot/snapshot_010_pos': ['FAIL', '7961'],
e4a3297a
BB
267 'snapused/snapused_004_pos': ['FAIL', '5513'],
268 'tmpfile/setup': ['SKIP', tmpfile_reason],
269 'threadsappend/threadsappend_001_pos': ['FAIL', '6136'],
270 'upgrade/upgrade_projectquota_001_pos': ['SKIP', project_id_reason],
271 'user_namespace/setup': ['SKIP', user_ns_reason],
272 'userquota/setup': ['SKIP', exec_reason],
273 'vdev_zaps/vdev_zaps_004_pos': ['FAIL', '6935'],
274 'write_dirs/setup': ['SKIP', disk_reason],
275 'zvol/zvol_ENOSPC/zvol_ENOSPC_001_pos': ['FAIL', '5848'],
276}
277
278
279def usage(s):
3ed2fbcc 280 print(s)
e4a3297a
BB
281 sys.exit(1)
282
283
284def process_results(pathname):
285 try:
286 f = open(pathname)
3ed2fbcc
GK
287 except IOError as e:
288 print('Error opening file: %s' % e)
e4a3297a
BB
289 sys.exit(1)
290
291 prefix = '/zfs-tests/tests/functional/'
b74f48fe
BB
292 pattern = \
293 r'^Test:\s*\S*%s(\S+)\s*\(run as (\S+)\)\s*\[(\S+)\]\s*\[(\S+)\]' \
e4a3297a 294 % prefix
b74f48fe 295 pattern_log = r'^\s*Log directory:\s*(\S*)'
e4a3297a
BB
296
297 d = {}
298 for l in f.readlines():
299 m = re.match(pattern, l)
300 if m and len(m.groups()) == 4:
301 summary['total'] += 1
302 if m.group(4) == "PASS":
303 summary['passed'] += 1
304 d[m.group(1)] = m.group(4)
305 continue
306
307 m = re.match(pattern_log, l)
308 if m:
309 summary['logfile'] = m.group(1)
310
311 return d
312
313
314if __name__ == "__main__":
cca14128 315 if len(sys.argv) != 2:
e4a3297a
BB
316 usage('usage: %s <pathname>' % sys.argv[0])
317 results = process_results(sys.argv[1])
318
319 if summary['total'] == 0:
3ed2fbcc
GK
320 print("\n\nNo test results were found.")
321 print("Log directory: %s" % summary['logfile'])
e4a3297a
BB
322 sys.exit(0)
323
324 expected = []
325 unexpected = []
326
3ed2fbcc 327 for test in list(results.keys()):
e4a3297a
BB
328 if results[test] == "PASS":
329 continue
330
331 setup = test.replace(os.path.basename(test), "setup")
332 if results[test] == "SKIP" and test != setup:
333 if setup in known and known[setup][0] == "SKIP":
334 continue
335 if setup in maybe and maybe[setup][0] == "SKIP":
336 continue
337
338 if ((test not in known or results[test] not in known[test][0]) and
339 (test not in maybe or results[test] not in maybe[test][0])):
340 unexpected.append(test)
341 else:
342 expected.append(test)
343
3ed2fbcc 344 print("\nTests with results other than PASS that are expected:")
e4a3297a
BB
345 for test in sorted(expected):
346 issue_url = 'https://github.com/zfsonlinux/zfs/issues/'
347
348 # Include the reason why the result is expected, given the following:
349 # 1. Suppress test results which set the "N/A on Linux" reason.
350 # 2. Numerical reasons are assumed to be GitHub issue numbers.
351 # 3. When an entire test group is skipped only report the setup reason.
352 if test in known:
353 if known[test][1] == na_reason:
354 continue
355 elif known[test][1].isdigit():
356 expect = issue_url + known[test][1]
357 else:
358 expect = known[test][1]
359 elif test in maybe:
360 if maybe[test][1].isdigit():
361 expect = issue_url + maybe[test][1]
362 else:
363 expect = maybe[test][1]
364 elif setup in known and known[setup][0] == "SKIP" and setup != test:
365 continue
366 elif setup in maybe and maybe[setup][0] == "SKIP" and setup != test:
367 continue
368 else:
369 expect = "UNKNOWN REASON"
3ed2fbcc 370 print(" %s %s (%s)" % (results[test], test, expect))
e4a3297a 371
3ed2fbcc 372 print("\nTests with result of PASS that are unexpected:")
e4a3297a
BB
373 for test in sorted(known.keys()):
374 # We probably should not be silently ignoring the case
375 # where "test" is not in "results".
376 if test not in results or results[test] != "PASS":
377 continue
3ed2fbcc
GK
378 print(" %s %s (expected %s)" % (results[test], test,
379 known[test][0]))
e4a3297a 380
3ed2fbcc 381 print("\nTests with results other than PASS that are unexpected:")
e4a3297a
BB
382 for test in sorted(unexpected):
383 expect = "PASS" if test not in known else known[test][0]
3ed2fbcc 384 print(" %s %s (expected %s)" % (results[test], test, expect))
e4a3297a
BB
385
386 if len(unexpected) == 0:
387 sys.exit(0)
388 else:
389 sys.exit(1)