Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
03e9b95
move nmstate checks to netwrok sanity
rnetser Aug 28, 2025
bb90322
nodes_active_nics will return node_physical_nics if running on cloud …
rnetser Aug 28, 2025
65e3f5d
update log content in nodes_active_nics
rnetser Aug 28, 2025
2180fbd
Merge branch 'main' of https://github.com/RedHatQE/openshift-virtuali…
rnetser Sep 1, 2025
35fe2de
rename conformance_tests to is_baremetal_or_psi_cluster
rnetser Sep 1, 2025
fc55066
set nodes_active_nics for non-bm from node_physical_nics
rnetser Sep 1, 2025
7d57af7
do not collect MS is not running on bm or psi
rnetser Sep 1, 2025
87eef2c
rename param to not_running_pods for clarity
rnetser Sep 1, 2025
78ad105
use copy to not mutate a global
rnetser Sep 1, 2025
72c6612
improve MS knmstate collection based on is_baremetal_or_psi_cluster f…
rnetser Sep 1, 2025
0b7928c
improve MS knmstate collection based on is_baremetal_or_psi_cluster f…
rnetser Sep 1, 2025
8ecc6bd
Use consistent test path check
rnetser Sep 2, 2025
3d6ed95
Merge branch 'main' of https://github.com/RedHatQE/openshift-virtuali…
rnetser Sep 2, 2025
c3d2529
resolve merge conflicts
rnetser Sep 2, 2025
f11a7e5
Merge branch 'main' of https://github.com/RedHatQE/openshift-virtuali…
rnetser Sep 3, 2025
012cf62
fix wait_for_pods_running docstring
rnetser Sep 3, 2025
d164c37
resolve conflicts with main
rnetser Sep 21, 2025
3b8c4d0
move function above calls and update arg name
rnetser Sep 21, 2025
9ca0d80
Merge branch 'main' of https://github.com/RedHatQE/openshift-virtuali…
rnetser Sep 28, 2025
2061a95
Merge branch 'main' of https://github.com/RedHatQE/openshift-virtuali…
rnetser Sep 28, 2025
add9715
remove duplicate call to _verify_multi_nic
rnetser Sep 28, 2025
8d39da4
Merge branch 'main' of https://github.com/RedHatQE/openshift-virtuali…
rnetser Oct 1, 2025
2d84777
Merge branch 'main' of https://github.com/RedHatQE/openshift-virtuali…
rnetser Oct 5, 2025
1aa60ad
wait_for_pods_running-format error message
rnetser Oct 5, 2025
d21e911
Merge branch 'main' of https://github.com/RedHatQE/openshift-virtuali…
rnetser Oct 5, 2025
e58d852
Merge branch 'main' of https://github.com/RedHatQE/openshift-virtuali…
rnetser Oct 5, 2025
e03611d
Merge branch 'main' of https://github.com/RedHatQE/openshift-virtuali…
rnetser Oct 5, 2025
eb53a1e
resolve merge conflicts
rnetser Oct 22, 2025
393c4e0
Merge branch 'main' of https://github.com/RedHatQE/openshift-virtuali…
rnetser Oct 23, 2025
ba2ffe6
Merge branch 'main' of https://github.com/RedHatQE/openshift-virtuali…
rnetser Oct 26, 2025
95d3f28
do not check bm_psi hw
rnetser Oct 27, 2025
68b5045
Merge branch 'main' of https://github.com/RedHatQE/openshift-virtuali…
rnetser Oct 27, 2025
e6fd846
linting
rnetser Oct 27, 2025
c1ee12c
remove get_fixture_return_values
rnetser Oct 27, 2025
fe8c0fe
save nmstate ns as const
rnetser Oct 27, 2025
f5d63e8
rebase on main
rnetser Oct 27, 2025
2baf15f
wait_for_pods_running - remove bool and add try in network sanity
rnetser Oct 27, 2025
1c0e886
Merge branch 'main' of https://github.com/RedHatQE/openshift-virtuali…
rnetser Oct 27, 2025
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
7 changes: 3 additions & 4 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
}
NAMESPACE_COLLECTION = {
"storage": [NamespacesNames.OPENSHIFT_STORAGE],
"network": ["openshift-nmstate"],
"network": [NamespacesNames.OPENSHIFT_NMSTATE],
"virt": [],
}
MUST_GATHER_IGNORE_EXCEPTION_LIST = [
Expand Down Expand Up @@ -839,7 +839,7 @@ def get_inspect_command_namespace_string(node: Node, test_name: str) -> str:
LOGGER.warning(f"{test_name} does not require special data collection on failure")
else:
component = components[0]
namespaces_to_collect: list[str] = NAMESPACE_COLLECTION[component]
namespaces_to_collect: list[str] = NAMESPACE_COLLECTION[component].copy()
if component == "virt":
all_markers = get_all_node_markers(node=node)
if "gpu" in all_markers:
Expand All @@ -863,7 +863,6 @@ def pytest_exception_interact(node: Item | Collector, call: CallInfo[Any], repor
if node.config.getoption("--data-collector") and not is_skip_must_gather(node=node):
test_name = f"{node.fspath}::{node.name}"
LOGGER.info(f"Must-gather collection is enabled for {test_name}.")
inspect_str = get_inspect_command_namespace_string(test_name=test_name, node=node)
if call.excinfo and any([
isinstance(call.excinfo.value, exception_type) for exception_type in MUST_GATHER_IGNORE_EXCEPTION_LIST
]):
Expand All @@ -882,7 +881,7 @@ def pytest_exception_interact(node: Item | Collector, call: CallInfo[Any], repor
since_time=calculate_must_gather_timer(test_start_time=test_start_time),
target_dir=collection_dir,
)
if inspect_str:
if inspect_str := get_inspect_command_namespace_string(test_name=test_name, node=node):
target_dir = os.path.join(collection_dir, "inspect_collection")
inspect_command = (
f"{INSPECT_BASE_COMMAND} {inspect_str} "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ def test_node_sanity(admin_client, nodes):


@pytest.mark.cluster_health_check
def test_pod_sanity(admin_client, hco_namespace, nmstate_namespace):
for namespace_obj in [hco_namespace, nmstate_namespace]:
wait_for_pods_running(
admin_client=admin_client,
namespace=namespace_obj,
)
def test_pod_sanity(admin_client, hco_namespace):
wait_for_pods_running(
admin_client=admin_client,
namespace=hco_namespace,
)


@pytest.mark.cluster_health_check
Expand Down
16 changes: 7 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ def nodes_active_nics(
workers_utility_pods,
node_physical_nics,
):
# TODO: Add support for environments that do not have KNMstate installed. e.g: clouds
# TODO: Reduce cognitive complexity
def _bridge_ports(node_interface):
ports = set()
Expand Down Expand Up @@ -2860,11 +2861,13 @@ def machine_config_pools():


@pytest.fixture(scope="session")
def nmstate_namespace(admin_client, nmstate_required):
if nmstate_required:
return Namespace(client=admin_client, name="openshift-nmstate", ensure_exists=True)
def nmstate_namespace(admin_client):
try:
return Namespace(client=admin_client, name=NamespacesNames.OPENSHIFT_NMSTATE, ensure_exists=True)

return None
except ResourceNotFoundError:
LOGGER.info(f"Namespace '{NamespacesNames.OPENSHIFT_NMSTATE}' not found.")
return None


@pytest.fixture()
Expand All @@ -2890,11 +2893,6 @@ def smbios_from_kubevirt_config(kubevirt_config_scope_module):
return kubevirt_config_scope_module["smbios"]


@pytest.fixture(scope="session")
def nmstate_required(admin_client):
return get_cluster_platform(admin_client=admin_client) in ("BareMetal", "OpenStack")


# TODO: Replace this fixture with py_config.get("conformance_tests")
@pytest.fixture(scope="session")
def conformance_tests(request):
Expand Down
28 changes: 25 additions & 3 deletions tests/network/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from ocp_resources.performance_profile import PerformanceProfile
from ocp_resources.pod import Pod
from pytest_testconfig import config as py_config
from timeout_sampler import TimeoutExpiredError

from tests.network.constants import BRCNV
from tests.network.utils import get_vlan_index_number, vm_for_brcnv_tests
Expand All @@ -25,12 +26,14 @@
ISTIO_SYSTEM_DEFAULT_NS,
OVS_BRIDGE,
VIRT_HANDLER,
NamespacesNames,
)
from utilities.infra import (
ExecCommandOnPod,
exit_pytest_execution,
get_deployment_by_name,
get_node_selector_dict,
wait_for_pods_running,
)
from utilities.network import (
get_cluster_cni_type,
Expand Down Expand Up @@ -216,6 +219,7 @@ def network_operator():

@pytest.fixture(scope="session", autouse=True)
def network_sanity(
admin_client,
hosts_common_available_ports,
junitxml_plugin,
request,
Expand All @@ -226,6 +230,7 @@ def network_sanity(
ipv4_supported_cluster,
ipv6_supported_cluster,
conformance_tests,
nmstate_namespace,
):
"""
Ensures the test cluster meets network requirements before executing tests.
Expand All @@ -235,8 +240,9 @@ def network_sanity(
failure_msgs = []
collected_tests = request.session.items

def _verify_multi_nic(request=request):
marker_args = request.config.getoption("-m")
def _verify_multi_nic(_request):
marker_args = _request.config.getoption("-m")
# TODO: add multi_nic marker to tests that require multiple NICs
if marker_args and "single_nic" in marker_args and "not single_nic" not in marker_args:
LOGGER.info("Running only single-NIC network cases, no need to verify multi NIC support")
return
Expand Down Expand Up @@ -339,14 +345,30 @@ def _verify_bgp_env_vars():
failure_msgs.append(f"BGP tests require the following environment variables: {missing_env_vars}")
return

_verify_multi_nic(request=request)
def _verify_nmstate_running_pods(_admin_client, namespace):
# TODO: Only test if nmstate is required by the test(s)
if not namespace:
failure_msgs.append(f"Knmstate namespace '{NamespacesNames.OPENSHIFT_NMSTATE}' does not exist.")
return

LOGGER.info("Verifying all pods in nmstate namespace are running")
try:
wait_for_pods_running(
admin_client=_admin_client,
namespace=namespace,
)
except TimeoutExpiredError:
failure_msgs.append(f"Some pods are not running in nmstate namespace '{namespace.name}'")

_verify_multi_nic(_request=request)
_verify_dpdk()
_verify_service_mesh()
_verify_jumbo_frame()
_verify_sriov()
_verify_ip_family(family="ipv4", is_supported_in_cluster=ipv4_supported_cluster)
_verify_ip_family(family="ipv6", is_supported_in_cluster=ipv6_supported_cluster)
_verify_bgp_env_vars()
_verify_nmstate_running_pods(_admin_client=admin_client, namespace=nmstate_namespace)

if failure_msgs:
err_msg = "\n".join(failure_msgs)
Expand Down
1 change: 1 addition & 0 deletions utilities/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ class NamespacesNames:
OPENSHIFT_VIRTUALIZATION_OS_IMAGES = "openshift-virtualization-os-images"
WASP = "wasp"
OPENSHIFT_KUBE_DESCHEDULER_OPERATOR = "openshift-kube-descheduler-operator"
OPENSHIFT_NMSTATE = "openshift-nmstate"


# CNV supplemental-templates
Expand Down
Loading