mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-01 21:41:13 +00:00
Merge pull request #8253 from opensourcerouting/topotest-python3-backports
tests: iproute2 VRF capability check for topotests
This commit is contained in:
commit
638fa8dd4e
@ -115,7 +115,7 @@ sys.path.append(os.path.join(CWD, "../lib/"))
|
|||||||
# Import topogen and topotest helpers
|
# Import topogen and topotest helpers
|
||||||
from lib.topogen import Topogen, get_topogen
|
from lib.topogen import Topogen, get_topogen
|
||||||
from mininet.topo import Topo
|
from mininet.topo import Topo
|
||||||
|
from lib.topotest import iproute2_is_vrf_capable
|
||||||
from lib.common_config import (
|
from lib.common_config import (
|
||||||
step,
|
step,
|
||||||
verify_rib,
|
verify_rib,
|
||||||
@ -215,6 +215,10 @@ def setup_module(mod):
|
|||||||
if result is not True:
|
if result is not True:
|
||||||
pytest.skip("Kernel requirements are not met")
|
pytest.skip("Kernel requirements are not met")
|
||||||
|
|
||||||
|
# iproute2 needs to support VRFs for this suite to run.
|
||||||
|
if not iproute2_is_vrf_capable():
|
||||||
|
pytest.skip("Installed iproute2 version does not support VRFs")
|
||||||
|
|
||||||
testsuite_run_time = time.asctime(time.localtime(time.time()))
|
testsuite_run_time = time.asctime(time.localtime(time.time()))
|
||||||
logger.info("Testsuite start time: {}".format(testsuite_run_time))
|
logger.info("Testsuite start time: {}".format(testsuite_run_time))
|
||||||
logger.info("=" * 40)
|
logger.info("=" * 40)
|
||||||
|
@ -71,7 +71,7 @@ sys.path.append(os.path.join(CWD, "../lib/"))
|
|||||||
# Import topogen and topotest helpers
|
# Import topogen and topotest helpers
|
||||||
from lib.topogen import Topogen, get_topogen
|
from lib.topogen import Topogen, get_topogen
|
||||||
from mininet.topo import Topo
|
from mininet.topo import Topo
|
||||||
|
from lib.topotest import iproute2_is_vrf_capable
|
||||||
from lib.common_config import (
|
from lib.common_config import (
|
||||||
step,
|
step,
|
||||||
verify_rib,
|
verify_rib,
|
||||||
@ -164,6 +164,10 @@ def setup_module(mod):
|
|||||||
if result is not True:
|
if result is not True:
|
||||||
pytest.skip("Kernel requirements are not met")
|
pytest.skip("Kernel requirements are not met")
|
||||||
|
|
||||||
|
# iproute2 needs to support VRFs for this suite to run.
|
||||||
|
if not iproute2_is_vrf_capable():
|
||||||
|
pytest.skip("Installed iproute2 version does not support VRFs")
|
||||||
|
|
||||||
testsuite_run_time = time.asctime(time.localtime(time.time()))
|
testsuite_run_time = time.asctime(time.localtime(time.time()))
|
||||||
logger.info("Testsuite start time: {}".format(testsuite_run_time))
|
logger.info("Testsuite start time: {}".format(testsuite_run_time))
|
||||||
logger.info("=" * 40)
|
logger.info("=" * 40)
|
||||||
|
@ -40,6 +40,8 @@ sys.path.append(os.path.join(CWD, "../"))
|
|||||||
from lib import topotest
|
from lib import topotest
|
||||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||||
from lib.topolog import logger
|
from lib.topolog import logger
|
||||||
|
from lib.topotest import iproute2_is_vrf_capable
|
||||||
|
from lib.common_config import required_linux_kernel_version
|
||||||
|
|
||||||
from mininet.topo import Topo
|
from mininet.topo import Topo
|
||||||
|
|
||||||
@ -193,18 +195,21 @@ def test_isis_route_installation():
|
|||||||
|
|
||||||
|
|
||||||
def test_isis_linux_route_installation():
|
def test_isis_linux_route_installation():
|
||||||
|
|
||||||
dist = platform.dist()
|
|
||||||
|
|
||||||
if dist[1] == "16.04":
|
|
||||||
pytest.skip("Kernel not supported for vrf")
|
|
||||||
|
|
||||||
"Check whether all expected routes are present and installed in the OS"
|
"Check whether all expected routes are present and installed in the OS"
|
||||||
tgen = get_topogen()
|
tgen = get_topogen()
|
||||||
# Don't run this test if we have any failure.
|
# Don't run this test if we have any failure.
|
||||||
if tgen.routers_have_failure():
|
if tgen.routers_have_failure():
|
||||||
pytest.skip(tgen.errors)
|
pytest.skip(tgen.errors)
|
||||||
|
|
||||||
|
# Required linux kernel version for this suite to run.
|
||||||
|
result = required_linux_kernel_version("4.15")
|
||||||
|
if result is not True:
|
||||||
|
pytest.skip("Kernel requirements are not met")
|
||||||
|
|
||||||
|
# iproute2 needs to support VRFs for this suite to run.
|
||||||
|
if not iproute2_is_vrf_capable():
|
||||||
|
pytest.skip("Installed iproute2 version does not support VRFs")
|
||||||
|
|
||||||
logger.info("Checking routers for installed ISIS vrf routes in OS")
|
logger.info("Checking routers for installed ISIS vrf routes in OS")
|
||||||
# Check for routes in `ip route show vrf {}-cust1`
|
# Check for routes in `ip route show vrf {}-cust1`
|
||||||
for rname, router in tgen.routers().items():
|
for rname, router in tgen.routers().items():
|
||||||
@ -236,18 +241,21 @@ def test_isis_route6_installation():
|
|||||||
|
|
||||||
|
|
||||||
def test_isis_linux_route6_installation():
|
def test_isis_linux_route6_installation():
|
||||||
|
|
||||||
dist = platform.dist()
|
|
||||||
|
|
||||||
if dist[1] == "16.04":
|
|
||||||
pytest.skip("Kernel not supported for vrf")
|
|
||||||
|
|
||||||
"Check whether all expected routes are present and installed in the OS"
|
"Check whether all expected routes are present and installed in the OS"
|
||||||
tgen = get_topogen()
|
tgen = get_topogen()
|
||||||
# Don't run this test if we have any failure.
|
# Don't run this test if we have any failure.
|
||||||
if tgen.routers_have_failure():
|
if tgen.routers_have_failure():
|
||||||
pytest.skip(tgen.errors)
|
pytest.skip(tgen.errors)
|
||||||
|
|
||||||
|
# Required linux kernel version for this suite to run.
|
||||||
|
result = required_linux_kernel_version("4.15")
|
||||||
|
if result is not True:
|
||||||
|
pytest.skip("Kernel requirements are not met")
|
||||||
|
|
||||||
|
# iproute2 needs to support VRFs for this suite to run.
|
||||||
|
if not iproute2_is_vrf_capable():
|
||||||
|
pytest.skip("Installed iproute2 version does not support VRFs")
|
||||||
|
|
||||||
logger.info("Checking routers for installed ISIS vrf IPv6 routes in OS")
|
logger.info("Checking routers for installed ISIS vrf IPv6 routes in OS")
|
||||||
# Check for routes in `ip -6 route show vrf {}-cust1`
|
# Check for routes in `ip -6 route show vrf {}-cust1`
|
||||||
for rname, router in tgen.routers().items():
|
for rname, router in tgen.routers().items():
|
||||||
|
@ -516,6 +516,44 @@ def normalize_text(text):
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
def is_linux():
|
||||||
|
"""
|
||||||
|
Parses unix name output to check if running on GNU/Linux.
|
||||||
|
|
||||||
|
Returns True if running on Linux, returns False otherwise.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if os.uname()[0] == "Linux":
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def iproute2_is_vrf_capable():
|
||||||
|
"""
|
||||||
|
Checks if the iproute2 version installed on the system is capable of
|
||||||
|
handling VRFs by interpreting the output of the 'ip' utility found in PATH.
|
||||||
|
|
||||||
|
Returns True if capability can be detected, returns False otherwise.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if is_linux():
|
||||||
|
try:
|
||||||
|
subp = subprocess.Popen(
|
||||||
|
["ip", "route", "show", "vrf"],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
stdin=subprocess.PIPE,
|
||||||
|
encoding="utf-8"
|
||||||
|
)
|
||||||
|
iproute2_err = subp.communicate()[1].splitlines()[0].split()[0]
|
||||||
|
|
||||||
|
if iproute2_err != "Error:":
|
||||||
|
return True
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def module_present_linux(module, load):
|
def module_present_linux(module, load):
|
||||||
"""
|
"""
|
||||||
Returns whether `module` is present.
|
Returns whether `module` is present.
|
||||||
|
Loading…
Reference in New Issue
Block a user