]> git.proxmox.com Git - mirror_zfs.git/blob - tests/test-runner/bin/zts-report.py.in
Speed up WB_SYNC_NONE when a WB_SYNC_ALL occurs simultaneously
[mirror_zfs.git] / tests / test-runner / bin / zts-report.py.in
1 #!/usr/bin/env @PYTHON_SHEBANG@
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 #
18 # This script must remain compatible with Python 3.6+.
19 #
20
21 import os
22 import re
23 import sys
24 import argparse
25
26 #
27 # This script parses the stdout of zfstest, which has this format:
28 #
29 # Test: /path/to/testa (run as root) [00:00] [PASS]
30 # Test: /path/to/testb (run as jkennedy) [00:00] [PASS]
31 # Test: /path/to/testc (run as root) [00:00] [FAIL]
32 # [...many more results...]
33 #
34 # Results Summary
35 # FAIL 22
36 # SKIP 32
37 # PASS 1156
38 #
39 # Running Time: 02:50:31
40 # Percent passed: 95.5%
41 # Log directory: /var/tmp/test_results/20180615T205926
42 #
43
44 #
45 # Common generic reasons for a test or test group to be skipped.
46 #
47 # Some test cases are known to fail in ways which are not harmful or dangerous.
48 # In these cases simply mark the test as a known failure until it can be
49 # updated and the issue resolved. Note that it's preferable to open a unique
50 # issue on the GitHub issue tracker for each test case failure.
51 #
52 known_reason = 'Known issue'
53
54 #
55 # Some tests require that a test user be able to execute the zfs utilities.
56 # This may not be possible when testing in-tree due to the default permissions
57 # on the user's home directory. When testing this can be resolved by granting
58 # group read access.
59 #
60 # chmod 0750 $HOME
61 #
62 exec_reason = 'Test user execute permissions required for utilities'
63
64 #
65 # Some tests require a minimum python version of 3.6 and will be skipped when
66 # the default system version is too old. There may also be tests which require
67 # additional python modules be installed, for example python3-cffi is required
68 # by the pyzfs tests.
69 #
70 python_deps_reason = 'Python modules missing: python3-cffi'
71
72 #
73 # Some tests require the O_TMPFILE flag which was first introduced in the
74 # 3.11 kernel.
75 #
76 tmpfile_reason = 'Kernel O_TMPFILE support required'
77
78 #
79 # Some tests require the statx(2) system call on Linux which was first
80 # introduced in the 4.11 kernel.
81 #
82 statx_reason = 'Kernel statx(2) system call required on Linux'
83
84 #
85 # Some tests require that the lsattr utility support the project id feature.
86 #
87 project_id_reason = 'lsattr with set/show project ID required'
88
89 #
90 # Some tests require that the kernel support user namespaces.
91 #
92 user_ns_reason = 'Kernel user namespace support required'
93
94 #
95 # Some rewind tests can fail since nothing guarantees that old MOS blocks
96 # are not overwritten. Snapshots protect datasets and data files but not
97 # the MOS. Reasonable efforts are made in the test case to increase the
98 # odds that some txgs will have their MOS data left untouched, but it is
99 # never a sure thing.
100 #
101 rewind_reason = 'Arbitrary pool rewind is not guaranteed'
102
103 #
104 # Some tests require a minimum version of the fio benchmark utility.
105 # Older distributions such as CentOS 6.x only provide fio-2.0.13.
106 #
107 fio_reason = 'Fio v2.3 or newer required'
108
109 #
110 # Some tests require that the DISKS provided support the discard operation.
111 # Normally this is not an issue because loop back devices are used for DISKS
112 # and they support discard (TRIM/UNMAP).
113 #
114 trim_reason = 'DISKS must support discard (TRIM/UNMAP)'
115
116 #
117 # Some tests on FreeBSD require the fspacectl(2) system call and the
118 # truncate(1) utility supporting the -d option. The system call was first
119 # introduced in FreeBSD version 1400032.
120 #
121 fspacectl_reason = 'fspacectl(2) and truncate -d support required'
122
123 #
124 # Some tests are not applicable to a platform or need to be updated to operate
125 # in the manor required by the platform. Any tests which are skipped for this
126 # reason will be suppressed in the final analysis output.
127 #
128 na_reason = "Not applicable"
129
130 #
131 # Some test cases doesn't have all requirements to run on Github actions CI.
132 #
133 ci_reason = 'CI runner doesn\'t have all requirements'
134
135
136 #
137 # These tests are known to fail, thus we use this list to prevent these
138 # failures from failing the job as a whole; only unexpected failures
139 # bubble up to cause this script to exit with a non-zero exit status.
140 #
141 # Format: { 'test-name': ['expected result', 'issue-number | reason'] }
142 #
143 # For each known failure it is recommended to link to a GitHub issue by
144 # setting the reason to the issue number. Alternately, one of the generic
145 # reasons listed above can be used.
146 #
147 known = {
148 'casenorm/mixed_none_lookup_ci': ['FAIL', 7633],
149 'casenorm/mixed_formd_lookup_ci': ['FAIL', 7633],
150 'cli_root/zpool_import/import_rewind_device_replaced':
151 ['FAIL', rewind_reason],
152 'cli_user/misc/zfs_share_001_neg': ['SKIP', na_reason],
153 'cli_user/misc/zfs_unshare_001_neg': ['SKIP', na_reason],
154 'privilege/setup': ['SKIP', na_reason],
155 'refreserv/refreserv_004_pos': ['FAIL', known_reason],
156 'rootpool/setup': ['SKIP', na_reason],
157 'rsend/rsend_008_pos': ['SKIP', 6066],
158 'vdev_zaps/vdev_zaps_007_pos': ['FAIL', known_reason],
159 }
160
161 if sys.platform.startswith('freebsd'):
162 known.update({
163 'cli_root/zfs_receive/receive-o-x_props_override':
164 ['FAIL', known_reason],
165 'cli_root/zpool_wait/zpool_wait_trim_basic': ['SKIP', trim_reason],
166 'cli_root/zpool_wait/zpool_wait_trim_cancel': ['SKIP', trim_reason],
167 'cli_root/zpool_wait/zpool_wait_trim_flag': ['SKIP', trim_reason],
168 'link_count/link_count_001': ['SKIP', na_reason],
169 'casenorm/mixed_create_failure': ['FAIL', 13215],
170 'mmap/mmap_sync_001_pos': ['SKIP', na_reason],
171 })
172 elif sys.platform.startswith('linux'):
173 known.update({
174 'casenorm/mixed_formd_lookup': ['FAIL', 7633],
175 'casenorm/mixed_formd_delete': ['FAIL', 7633],
176 'casenorm/sensitive_formd_lookup': ['FAIL', 7633],
177 'casenorm/sensitive_formd_delete': ['FAIL', 7633],
178 'removal/removal_with_zdb': ['SKIP', known_reason],
179 'cli_root/zfs_unshare/zfs_unshare_002_pos': ['SKIP', na_reason],
180 })
181
182
183 #
184 # These tests may occasionally fail or be skipped. We want there failures
185 # to be reported but only unexpected failures should bubble up to cause
186 # this script to exit with a non-zero exit status.
187 #
188 # Format: { 'test-name': ['expected result', 'issue-number | reason'] }
189 #
190 # For each known failure it is recommended to link to a GitHub issue by
191 # setting the reason to the issue number. Alternately, one of the generic
192 # reasons listed above can be used.
193 #
194 maybe = {
195 'chattr/setup': ['SKIP', exec_reason],
196 'crtime/crtime_001_pos': ['SKIP', statx_reason],
197 'cli_root/zdb/zdb_006_pos': ['FAIL', known_reason],
198 'cli_root/zfs_destroy/zfs_destroy_dev_removal_condense':
199 ['FAIL', known_reason],
200 'cli_root/zfs_get/zfs_get_004_pos': ['FAIL', known_reason],
201 'cli_root/zfs_get/zfs_get_009_pos': ['SKIP', 5479],
202 'cli_root/zfs_rollback/zfs_rollback_001_pos': ['FAIL', known_reason],
203 'cli_root/zfs_rollback/zfs_rollback_002_pos': ['FAIL', known_reason],
204 'cli_root/zfs_snapshot/zfs_snapshot_002_neg': ['FAIL', known_reason],
205 'cli_root/zfs_unshare/zfs_unshare_006_pos': ['SKIP', na_reason],
206 'cli_root/zpool_add/zpool_add_004_pos': ['FAIL', known_reason],
207 'cli_root/zpool_destroy/zpool_destroy_001_pos': ['SKIP', 6145],
208 'cli_root/zpool_import/zpool_import_missing_003_pos': ['SKIP', 6839],
209 'cli_root/zpool_initialize/zpool_initialize_import_export':
210 ['FAIL', 11948],
211 'cli_root/zpool_labelclear/zpool_labelclear_removed':
212 ['FAIL', known_reason],
213 'cli_root/zpool_trim/setup': ['SKIP', trim_reason],
214 'cli_root/zpool_upgrade/zpool_upgrade_004_pos': ['FAIL', 6141],
215 'delegate/setup': ['SKIP', exec_reason],
216 'fallocate/fallocate_punch-hole': ['SKIP', fspacectl_reason],
217 'history/history_004_pos': ['FAIL', 7026],
218 'history/history_005_neg': ['FAIL', 6680],
219 'history/history_006_neg': ['FAIL', 5657],
220 'history/history_008_pos': ['FAIL', known_reason],
221 'history/history_010_pos': ['SKIP', exec_reason],
222 'io/mmap': ['SKIP', fio_reason],
223 'largest_pool/largest_pool_001_pos': ['FAIL', known_reason],
224 'mmp/mmp_on_uberblocks': ['FAIL', known_reason],
225 'pyzfs/pyzfs_unittest': ['SKIP', python_deps_reason],
226 'pool_checkpoint/checkpoint_discard_busy': ['FAIL', 11946],
227 'projectquota/setup': ['SKIP', exec_reason],
228 'redundancy/redundancy_004_neg': ['FAIL', 7290],
229 'redundancy/redundancy_draid_spare1': ['FAIL', known_reason],
230 'redundancy/redundancy_draid_spare3': ['FAIL', known_reason],
231 'removal/removal_condense_export': ['FAIL', known_reason],
232 'reservation/reservation_008_pos': ['FAIL', 7741],
233 'reservation/reservation_018_pos': ['FAIL', 5642],
234 'snapshot/clone_001_pos': ['FAIL', known_reason],
235 'snapshot/snapshot_009_pos': ['FAIL', 7961],
236 'snapshot/snapshot_010_pos': ['FAIL', 7961],
237 'snapused/snapused_004_pos': ['FAIL', 5513],
238 'tmpfile/setup': ['SKIP', tmpfile_reason],
239 'threadsappend/threadsappend_001_pos': ['FAIL', 6136],
240 'trim/setup': ['SKIP', trim_reason],
241 'upgrade/upgrade_projectquota_001_pos': ['SKIP', project_id_reason],
242 'user_namespace/setup': ['SKIP', user_ns_reason],
243 'userquota/setup': ['SKIP', exec_reason],
244 'zvol/zvol_ENOSPC/zvol_ENOSPC_001_pos': ['FAIL', 5848],
245 'pam/setup': ['SKIP', "pamtester might be not available"],
246 }
247
248 if sys.platform.startswith('freebsd'):
249 maybe.update({
250 'cli_root/zfs_copies/zfs_copies_002_pos': ['FAIL', known_reason],
251 'cli_root/zfs_inherit/zfs_inherit_001_neg': ['FAIL', known_reason],
252 'cli_root/zfs_share/zfs_share_concurrent_shares':
253 ['FAIL', known_reason],
254 'cli_root/zpool_import/zpool_import_012_pos': ['FAIL', known_reason],
255 'delegate/zfs_allow_003_pos': ['FAIL', known_reason],
256 'inheritance/inherit_001_pos': ['FAIL', 11829],
257 'resilver/resilver_restart_001': ['FAIL', known_reason],
258 'pool_checkpoint/checkpoint_big_rewind': ['FAIL', 12622],
259 'pool_checkpoint/checkpoint_indirect': ['FAIL', 12623],
260 })
261 elif sys.platform.startswith('linux'):
262 maybe.update({
263 'cli_root/zfs_rename/zfs_rename_002_pos': ['FAIL', known_reason],
264 'cli_root/zpool_reopen/zpool_reopen_003_pos': ['FAIL', known_reason],
265 'fault/auto_spare_shared': ['FAIL', 11889],
266 'fault/auto_spare_multiple': ['FAIL', 11889],
267 'io/io_uring': ['SKIP', 'io_uring support required'],
268 'limits/filesystem_limit': ['SKIP', known_reason],
269 'limits/snapshot_limit': ['SKIP', known_reason],
270 'mmp/mmp_active_import': ['FAIL', known_reason],
271 'mmp/mmp_exported_import': ['FAIL', known_reason],
272 'mmp/mmp_inactive_import': ['FAIL', known_reason],
273 'zvol/zvol_misc/zvol_misc_snapdev': ['FAIL', 12621],
274 'zvol/zvol_misc/zvol_misc_volmode': ['FAIL', known_reason],
275 })
276
277
278 # Not all Github actions runners have scsi_debug module, so we may skip
279 # some tests which use it.
280 if os.environ.get('CI') == 'true':
281 known.update({
282 'cli_root/zpool_expand/zpool_expand_001_pos': ['SKIP', ci_reason],
283 'cli_root/zpool_expand/zpool_expand_003_neg': ['SKIP', ci_reason],
284 'cli_root/zpool_expand/zpool_expand_005_pos': ['SKIP', ci_reason],
285 'cli_root/zpool_reopen/setup': ['SKIP', ci_reason],
286 'cli_root/zpool_reopen/zpool_reopen_001_pos': ['SKIP', ci_reason],
287 'cli_root/zpool_reopen/zpool_reopen_002_pos': ['SKIP', ci_reason],
288 'cli_root/zpool_reopen/zpool_reopen_003_pos': ['SKIP', ci_reason],
289 'cli_root/zpool_reopen/zpool_reopen_004_pos': ['SKIP', ci_reason],
290 'cli_root/zpool_reopen/zpool_reopen_005_pos': ['SKIP', ci_reason],
291 'cli_root/zpool_reopen/zpool_reopen_006_neg': ['SKIP', ci_reason],
292 'cli_root/zpool_reopen/zpool_reopen_007_pos': ['SKIP', ci_reason],
293 'cli_root/zpool_split/zpool_split_wholedisk': ['SKIP', ci_reason],
294 'fault/auto_offline_001_pos': ['SKIP', ci_reason],
295 'fault/auto_online_001_pos': ['SKIP', ci_reason],
296 'fault/auto_online_002_pos': ['SKIP', ci_reason],
297 'fault/auto_replace_001_pos': ['SKIP', ci_reason],
298 'fault/auto_spare_ashift': ['SKIP', ci_reason],
299 'fault/auto_spare_shared': ['SKIP', ci_reason],
300 'procfs/pool_state': ['SKIP', ci_reason],
301 })
302
303 maybe.update({
304 'events/events_002_pos': ['FAIL', 11546],
305 })
306
307
308 def process_results(pathname):
309 try:
310 f = open(pathname)
311 except IOError as e:
312 print('Error opening file:', e)
313 sys.exit(1)
314
315 prefix = '/zfs-tests/tests/functional/'
316 pattern = \
317 r'^Test(?:\s+\(\S+\))?:' + \
318 rf'\s*\S*{prefix}(\S+)' + \
319 r'\s*\(run as (\S+)\)\s*\[(\S+)\]\s*\[(\S+)\]'
320 pattern_log = r'^\s*Log directory:\s*(\S*)'
321
322 d = {}
323 logdir = 'Could not determine log directory.'
324 for line in f.readlines():
325 m = re.match(pattern, line)
326 if m and len(m.groups()) == 4:
327 d[m.group(1)] = m.group(4)
328 continue
329
330 m = re.match(pattern_log, line)
331 if m:
332 logdir = m.group(1)
333
334 return d, logdir
335
336
337 class ListMaybesAction(argparse.Action):
338 def __init__(self,
339 option_strings,
340 dest="SUPPRESS",
341 default="SUPPRESS",
342 help="list flaky tests and exit"):
343 super(ListMaybesAction, self).__init__(
344 option_strings=option_strings,
345 dest=dest,
346 default=default,
347 nargs=0,
348 help=help)
349
350 def __call__(self, parser, namespace, values, option_string=None):
351 for test in maybe:
352 print(test)
353 sys.exit(0)
354
355
356 if __name__ == "__main__":
357 parser = argparse.ArgumentParser(description='Analyze ZTS logs')
358 parser.add_argument('logfile')
359 parser.add_argument('--list-maybes', action=ListMaybesAction)
360 parser.add_argument('--no-maybes', action='store_false', dest='maybes')
361 args = parser.parse_args()
362
363 results, logdir = process_results(args.logfile)
364
365 if not results:
366 print("\n\nNo test results were found.")
367 print("Log directory:", logdir)
368 sys.exit(0)
369
370 expected = []
371 unexpected = []
372 all_maybes = True
373
374 for test in list(results.keys()):
375 if results[test] == "PASS":
376 continue
377
378 setup = test.replace(os.path.basename(test), "setup")
379 if results[test] == "SKIP" and test != setup:
380 if setup in known and known[setup][0] == "SKIP":
381 continue
382 if setup in maybe and maybe[setup][0] == "SKIP":
383 continue
384
385 if (test in known and results[test] in known[test][0]):
386 expected.append(test)
387 elif test in maybe and results[test] in maybe[test][0]:
388 if results[test] == 'SKIP' or args.maybes:
389 expected.append(test)
390 elif not args.maybes:
391 unexpected.append(test)
392 else:
393 unexpected.append(test)
394 all_maybes = False
395
396 print("\nTests with results other than PASS that are expected:")
397 for test in sorted(expected):
398 issue_url = 'https://github.com/openzfs/zfs/issues/'
399
400 # Include the reason why the result is expected, given the following:
401 # 1. Suppress test results which set the "Not applicable" reason.
402 # 2. Numerical reasons are assumed to be GitHub issue numbers.
403 # 3. When an entire test group is skipped only report the setup reason.
404 if test in known:
405 if known[test][1] == na_reason:
406 continue
407 elif isinstance(known[test][1], int):
408 expect = f"{issue_url}{known[test][1]}"
409 else:
410 expect = known[test][1]
411 elif test in maybe:
412 if isinstance(maybe[test][1], int):
413 expect = f"{issue_url}{maybe[test][1]}"
414 else:
415 expect = maybe[test][1]
416 elif setup in known and known[setup][0] == "SKIP" and setup != test:
417 continue
418 elif setup in maybe and maybe[setup][0] == "SKIP" and setup != test:
419 continue
420 else:
421 expect = "UNKNOWN REASON"
422 print(f" {results[test]} {test} ({expect})")
423
424 print("\nTests with result of PASS that are unexpected:")
425 for test in sorted(known.keys()):
426 # We probably should not be silently ignoring the case
427 # where "test" is not in "results".
428 if test not in results or results[test] != "PASS":
429 continue
430 print(f" {results[test]} {test} (expected {known[test][0]})")
431
432 print("\nTests with results other than PASS that are unexpected:")
433 for test in sorted(unexpected):
434 expect = "PASS" if test not in known else known[test][0]
435 print(f" {results[test]} {test} (expected {expect})")
436
437 if len(unexpected) == 0:
438 sys.exit(0)
439 elif not args.maybes and all_maybes:
440 sys.exit(2)
441 else:
442 sys.exit(1)