Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/skills/test-authoring/suite-map/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Set `chunked_enabled: true` once `ghcr.io/projectbluefin/bluefin:latest` ships z
| `@nvidia_only` | NVIDIA variant only |
| `@flatcar_suite` | Flatcar OS only |
| `@hardware_emulation` | Requires full-hw VM spec (TPM, audio, watchdog) |
| `@vm_only` | Scenario drives the device under test over SSH (or asserts VM-only boot state); the smoke `environment.py` skips it in container lanes, detected via `/run/.containerenv` (`tests/shared/runtime_env.py`) |
| `@pending` | Placeholder coverage gap; intentionally skipped until a valid harness exists |
| `@future` | Not yet implemented or blocked on infra |
| `@homed_migration` | systemd-homed migration scenarios; dakota lifecycle; SSH-mode; skip-safe when homed absent |
Expand Down
25 changes: 25 additions & 0 deletions tests/shared/runtime_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Runtime environment detection shared across suites.

Container lanes (Argo ``run-container-tests``) execute behave *inside* the
nested target container itself, so there is no separate device under test and
no sshd to reach. VM lanes (KubeVirt) run behave on a runner that talks to the
device under test over SSH.

Scenarios that can only be meaningful against a real VM — anything driving the
device over SSH, or asserting on boot-time/kernel state a container never has —
must be tagged ``@vm_only`` and are skipped by the suite hooks in a container
lane.
"""

import os

# Podman writes /run/.containerenv into every container it starts, including
# the nested systemd target used by container lanes. A KubeVirt VM never has
# it. This is a stronger signal than probing for /usr/bin/bootc, which is
# present in the container lane too because the target *is* a bootc image.
CONTAINER_MARKER = "/run/.containerenv"


def in_container_lane() -> bool:
"""Return True when behave is running inside a container-lane target."""
return os.path.exists(CONTAINER_MARKER)
13 changes: 13 additions & 0 deletions tests/smoke/features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
_QECORE_AVAILABLE = False

from steps.app_support import launch_target_available
from tests.shared.runtime_env import in_container_lane

# ── qecore keyboard key mapping patch ────────────────────────────────────────
# qecore 4.16 keyboard_key_combo_input builds uinput key names as
Expand Down Expand Up @@ -334,6 +335,18 @@ def before_scenario(context, scenario) -> None:

scenario_tags = set(getattr(scenario, "effective_tags", scenario.tags))

# Skip @vm_only scenarios in container lanes. Those scenarios drive the
# device under test over SSH, but a container lane runs behave inside the
# target itself and has no sshd — the resulting connection failure is a
# runner limitation, not an image regression.
if "vm_only" in scenario_tags and in_container_lane():
try:
scenario.skip("Skipping @vm_only scenario in a container lane (no SSH target)")
except TypeError:
scenario.skip()
print(f"Skipping {scenario.name}: @vm_only scenario in a container lane", flush=True)
return

# Skip @bluefin scenarios on non-Bluefin images (e.g. dakota).
if not getattr(context, "is_bluefin_image", True):
if "bluefin" in scenario_tags:
Expand Down
7 changes: 6 additions & 1 deletion tests/smoke/features/offline_boot.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@smoke @offline
@smoke @offline @vm_only
Feature: Offline and degraded-network boot
Validates that the image can reach graphical.target and remain operational
when outbound network connectivity is absent or degraded. Images must boot
Expand All @@ -12,6 +12,11 @@ Feature: Offline and degraded-network boot

Runner: plain SSH behave (no qecore — no GUI interaction needed).

Tagged @vm_only: every scenario drives the device under test over SSH, and a
container lane runs behave inside the target itself with no sshd to reach.
The suite hook skips these scenarios there rather than reporting a runner
limitation as an image regression.

Background:
* Bluefin VM is booted and reachable over SSH

Expand Down
18 changes: 18 additions & 0 deletions tests/unit/test_runtime_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Unit tests for tests/shared/runtime_env.py container-lane detection."""

from unittest.mock import patch

from tests.shared import runtime_env


class TestInContainerLane:
def test_true_when_containerenv_present(self):
with patch("os.path.exists", side_effect=lambda p: p == runtime_env.CONTAINER_MARKER):
assert runtime_env.in_container_lane() is True

def test_false_when_containerenv_absent(self):
with patch("os.path.exists", return_value=False):
assert runtime_env.in_container_lane() is False

def test_checks_the_podman_marker_path(self):
assert runtime_env.CONTAINER_MARKER == "/run/.containerenv"
Loading