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