test,k8s: Ignore calico interfaces
The integration tests should ignore interfaces related to the CNI used by the k8s cluster calico. This change introduces an env var to pass inteface substring to ignore. Signed-off-by: Quique Llorente <ellorent@redhat.com>
This commit is contained in:
parent
8ed5100be5
commit
44b17591e1
@ -486,7 +486,7 @@ if [ -n "${RUN_BAREMETAL}" ];then
|
||||
run_customize_command
|
||||
start_machine_services
|
||||
elif [ -n "${RUN_K8S}" ]; then
|
||||
#start_machine_services
|
||||
CONTAINER_CMD=docker
|
||||
k8s::start_cluster
|
||||
k8s::pre_test_setup
|
||||
run_customize_command
|
||||
|
@ -71,6 +71,8 @@ spec:
|
||||
value: "${SHIPPABLE}"
|
||||
- name: RUN_K8S
|
||||
value: "true"
|
||||
- name: NMSTATE_TEST_IGNORE_IFACE
|
||||
value: "cali"
|
||||
volumeMounts:
|
||||
- name: dbus-socket
|
||||
mountPath: /run/dbus/system_bus_socket
|
||||
|
@ -18,6 +18,7 @@
|
||||
#
|
||||
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import warnings
|
||||
|
||||
@ -73,6 +74,7 @@ def _mark_tier2_tests(items):
|
||||
def test_env_setup():
|
||||
_logging_setup()
|
||||
old_state = libnmstate.show()
|
||||
old_state = _remove_interfaces_from_env(old_state)
|
||||
_remove_dns_route_route_rule()
|
||||
_ethx_init()
|
||||
yield
|
||||
@ -107,6 +109,26 @@ def _ethx_init():
|
||||
ifacelib.ifaces_init("eth1", "eth2")
|
||||
|
||||
|
||||
def _remove_interfaces_from_env(state):
|
||||
"""
|
||||
Remove references from interfaces passed to environment variable
|
||||
NMSTATE_TEST_IGNORE_IFACE.
|
||||
"""
|
||||
ignore_iface = os.getenv("NMSTATE_TEST_IGNORE_IFACE")
|
||||
if ignore_iface is None:
|
||||
return state
|
||||
|
||||
state["interfaces"] = [
|
||||
i for i in state["interfaces"] if ignore_iface not in i["name"]
|
||||
]
|
||||
state["routes"]["config"] = [
|
||||
r
|
||||
for r in state["routes"]["config"]
|
||||
if ignore_iface not in r["next-hop-interface"]
|
||||
]
|
||||
return state
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def eth1_up():
|
||||
with ifacelib.iface_up("eth1") as ifstate:
|
||||
@ -125,6 +147,7 @@ port1_up = eth2_up
|
||||
|
||||
def _diff_initial_state(old_state):
|
||||
new_state = libnmstate.show()
|
||||
new_state = _remove_interfaces_from_env(new_state)
|
||||
|
||||
if old_state != new_state:
|
||||
warnings.warn(
|
||||
|
Loading…
x
Reference in New Issue
Block a user