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