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