Skip to content

Bug: conditional_mark plugin aborts test collection when DUT facts lack 'branch'/'build_version' (e.g. Nokia arm64 BMC) #28084

Description

@ediwibowo-msft

Is it platform specific

marvell

Importance or Severity

High

Description of the bug

The conditional_mark plugin (tests/common/plugins/conditional_mark/__init__.py) for test system_health/test_system_health.py aborts pytest collection on DUTs whose dut_basic_facts do not report branch / build_version (for example the Nokia arm64 BMC platform arm64-nokia_bmc_h6_128-r0).

Any mark rule in tests_mark_conditions.yaml referencing those variables raises NameError: name 'branch' is not defined, which fails the whole collection. Examples that trigger it:

  • syslog/test_syslog.py -> "branch in ['internal-202012']"
  • system_health/test_system_health.py::test_service_checker_with_process_exit -> "branch in ['internal-202012']" and "build_version.split('.')[1]..."

Two plugin issues combine to cause this:

  1. evaluate_condition only defaults asic_type, platform, hwsku, and asic_gen to None, so any other fact referenced in a condition (branch, build_version, release) is undefined during eval().
  2. evaluate_conditions applies AND/OR using non short-circuit list comprehensions (all([...]) / any([...])), so every condition is evaluated even after the result is already decided. A rule like branch in ['internal-202012'] followed by build_version.split('.')[1]... still evaluates the second condition and hits AttributeError on a None build_version.

Steps to Reproduce

  1. Run any pytest suite whose collected tests match a tests_mark_conditions.yaml rule that references branch or build_version (e.g. system_health/test_system_health.py).
  2. Target a DUT/image whose dut_basic_facts does not return branch/build_version, such as the Nokia arm64 BMC (arm64-nokia_bmc_h6_128-r0, topo_type "bmc").
  3. Collection aborts with NameError: name 'branch' is not defined (or AttributeError on None.split for the build_version condition).

Actual Behavior and Expected Behavior

Actual: A single obsolete or fact-dependent rule (e.g. the internal-202012 rules) raises during condition evaluation and aborts collection for the entire run on images that report a reduced set of basic facts.

Expected: Missing facts should not crash collection. A condition that references an unavailable fact should evaluate safely (the rule simply does not apply), and evaluation should short-circuit so later fact-dependent conditions are not evaluated once the outcome is already determined.

Relevant log output

system_health/test_system_health.py::test_service_checker_with_process_exit
NameError: name 'branch' is not defined
# and, after guarding branch, the follow-on condition:
AttributeError: 'NoneType' object has no attribute 'split'

Output of show version

platform: arm64-nokia_bmc_h6_128-r0 (Nokia-7220-Th6p-2 BMC)
# dut_basic_facts on this image does not return 'branch' / 'build_version'

Attach files (if any)

Fix in progress via PR #28083: default branch/build_version/release to None in evaluate_condition and switch AND/OR evaluation in evaluate_conditions to short-circuit generator expressions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions