summaryrefslogtreecommitdiffstats
path: root/tests/topotests
diff options
context:
space:
mode:
authorBarry A. Trent <barry.trent@atcorp.com>2024-09-27 21:59:12 +0200
committerBarry A. Trent <barry.trent@atcorp.com>2024-09-27 22:39:50 +0200
commit41fa1541632660e8eab92c3b3b786007c5cbe67b (patch)
tree0699f8000f4bed1b81d05ae175cea1358d3d0aa1 /tests/topotests
parentpimd: fix autorp CLI bugs (diff)
downloadfrr-41fa1541632660e8eab92c3b3b786007c5cbe67b.tar.xz
frr-41fa1541632660e8eab92c3b3b786007c5cbe67b.zip
tests: enhance autorp topotest
Signed-off-by: Barry A. Trent <barry.trent@atcorp.com>
Diffstat (limited to 'tests/topotests')
-rw-r--r--tests/topotests/pim_autorp/test_pim_autorp.py154
1 files changed, 144 insertions, 10 deletions
diff --git a/tests/topotests/pim_autorp/test_pim_autorp.py b/tests/topotests/pim_autorp/test_pim_autorp.py
index 5aecce942..ad618af29 100644
--- a/tests/topotests/pim_autorp/test_pim_autorp.py
+++ b/tests/topotests/pim_autorp/test_pim_autorp.py
@@ -11,12 +11,18 @@
import os
import sys
import pytest
+from functools import partial
# pylint: disable=C0413
# Import topogen and topotest helpers
+from lib import topotest
from lib.topogen import Topogen, get_topogen
from lib.topolog import logger
-from lib.pim import scapy_send_autorp_raw_packet, verify_pim_rp_info, verify_pim_rp_info_is_empty
+from lib.pim import (
+ scapy_send_autorp_raw_packet,
+ verify_pim_rp_info,
+ verify_pim_rp_info_is_empty,
+)
from lib.common_config import step, write_test_header
from time import sleep
@@ -55,6 +61,7 @@ def build_topo(tgen):
switch.add_link(tgen.gears["r1"])
switch.add_link(tgen.gears["r2"])
+
def setup_module(mod):
logger.info("PIM AutoRP basic functionality:\n {}".format(TOPOLOGY))
@@ -87,6 +94,7 @@ def teardown_module(mod):
tgen = get_topogen()
tgen.stop_topology()
+
def test_pim_autorp_discovery_single_rp(request):
"Test PIM AutoRP Discovery with single RP"
tgen = get_topogen()
@@ -106,13 +114,25 @@ def test_pim_autorp_discovery_single_rp(request):
scapy_send_autorp_raw_packet(tgen, "r1", "r1-eth0", data)
step("Verify rp-info from AutoRP packet")
- result = verify_pim_rp_info(tgen, None, "r2", "224.0.0.0/4", "r2-eth0", "10.10.76.1", "AutoRP", False, "ipv4", True)
+ result = verify_pim_rp_info(
+ tgen,
+ None,
+ "r2",
+ "224.0.0.0/4",
+ "r2-eth0",
+ "10.10.76.1",
+ "AutoRP",
+ False,
+ "ipv4",
+ True,
+ )
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
step("Verify AutoRP configuration times out")
result = verify_pim_rp_info_is_empty(tgen, "r2")
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
+
def test_pim_autorp_discovery_multiple_rp(request):
"Test PIM AutoRP Discovery with multiple RP's"
tgen = get_topogen()
@@ -132,9 +152,31 @@ def test_pim_autorp_discovery_multiple_rp(request):
scapy_send_autorp_raw_packet(tgen, "r1", "r1-eth0", data)
step("Verify rp-info from AutoRP packet")
- result = verify_pim_rp_info(tgen, None, "r2", "224.0.0.0/8", "r2-eth0", "10.10.76.1", "AutoRP", False, "ipv4", True)
+ result = verify_pim_rp_info(
+ tgen,
+ None,
+ "r2",
+ "224.0.0.0/8",
+ "r2-eth0",
+ "10.10.76.1",
+ "AutoRP",
+ False,
+ "ipv4",
+ True,
+ )
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
- result = verify_pim_rp_info(tgen, None, "r2", "225.0.0.0/8", "r2-eth0", "10.10.76.3", "AutoRP", False, "ipv4", True)
+ result = verify_pim_rp_info(
+ tgen,
+ None,
+ "r2",
+ "225.0.0.0/8",
+ "r2-eth0",
+ "10.10.76.3",
+ "AutoRP",
+ False,
+ "ipv4",
+ True,
+ )
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
@@ -156,7 +198,18 @@ def test_pim_autorp_discovery_static(request):
rnode.cmd("vtysh -c 'conf t' -c 'router pim' -c 'rp 10.10.76.3 224.0.0.0/4'")
step("Verify static rp-info from r2")
- result = verify_pim_rp_info(tgen, None, "r2", "224.0.0.0/4", "r2-eth0", "10.10.76.3", "Static", False, "ipv4", True)
+ result = verify_pim_rp_info(
+ tgen,
+ None,
+ "r2",
+ "224.0.0.0/4",
+ "r2-eth0",
+ "10.10.76.3",
+ "Static",
+ False,
+ "ipv4",
+ True,
+ )
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
step("Send AutoRP packet from r1 to r2")
@@ -165,10 +218,87 @@ def test_pim_autorp_discovery_static(request):
scapy_send_autorp_raw_packet(tgen, "r1", "r1-eth0", data)
step("Verify rp-info from AutoRP packet")
- result = verify_pim_rp_info(tgen, None, "r2", "224.0.0.0/4", "r2-eth0", "10.10.76.1", "AutoRP", False, "ipv4", True)
+ result = verify_pim_rp_info(
+ tgen,
+ None,
+ "r2",
+ "224.0.0.0/4",
+ "r2-eth0",
+ "10.10.76.1",
+ "AutoRP",
+ False,
+ "ipv4",
+ True,
+ )
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
+def test_pim_autorp_announce_cli(request):
+ "Test PIM AutoRP Announcement CLI commands"
+ tgen = get_topogen()
+ tc_name = request.node.name
+ write_test_header(tc_name)
+
+ if tgen.routers_have_failure():
+ pytest.skip("skipped because of router(s) failure")
+
+ step("Add AutoRP announcement configuration to r1")
+ r1 = tgen.routers()["r1"]
+ r1.vtysh_cmd(
+ """
+ conf
+ router pim
+ autorp announce holdtime 90
+ autorp announce interval 120
+ autorp announce scope 5
+ autorp announce 10.2.3.4 225.0.0.0/24
+"""
+ )
+
+ expected = {
+ "discoveryEnabled": True,
+ "announce": {
+ "scope": 5,
+ "interval": 120,
+ "holdtime": 90,
+ "rpList": [
+ {"rpAddress": "10.2.3.4", "group": "225.0.0.0/24", "prefixList": ""}
+ ],
+ },
+ }
+
+ test_func = partial(
+ topotest.router_json_cmp, r1, "show ip pim autorp json", expected
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assertmsg = '"{}" JSON output mismatches'.format(r1.name)
+ assert result is None, assertmsg
+
+ r1.vtysh_cmd(
+ """
+ conf
+ router pim
+ autorp announce 10.2.3.4 group-list ListA
+"""
+ )
+ expected = {
+ "discoveryEnabled": True,
+ "announce": {
+ "scope": 5,
+ "interval": 120,
+ "holdtime": 90,
+ "rpList": [{"rpAddress": "10.2.3.4", "group": "", "prefixList": "ListA"}],
+ },
+ }
+
+ test_func = partial(
+ topotest.router_json_cmp, r1, "show ip pim autorp json", expected
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assertmsg = '"{}" JSON output mismatches'.format(r1.name)
+ assert result is None, assertmsg
+
+
def test_pim_autorp_announce_group(request):
"Test PIM AutoRP Announcement with a single group"
tgen = get_topogen()
@@ -180,17 +310,21 @@ def test_pim_autorp_announce_group(request):
step("Add candidate RP configuration to r1")
rnode = tgen.routers()["r1"]
- rnode.cmd("vtysh -c 'conf t' -c 'router pim' -c 'send-rp-announce 10.10.76.1 224.0.0.0/4'")
+ rnode.cmd(
+ "vtysh -c 'conf t' -c 'router pim' -c 'send-rp-announce 10.10.76.1 224.0.0.0/4'"
+ )
step("Verify Announcement sent data")
# TODO: Verify AutoRP mapping agent receives candidate RP announcement
# Mapping agent is not yet implemented
- #sleep(10)
+ # sleep(10)
step("Change AutoRP Announcement packet parameters")
- rnode.cmd("vtysh -c 'conf t' -c 'router pim' -c 'send-rp-announce scope 8 interval 10 holdtime 60'")
+ rnode.cmd(
+ "vtysh -c 'conf t' -c 'router pim' -c 'send-rp-announce scope 8 interval 10 holdtime 60'"
+ )
step("Verify Announcement sent data")
# TODO: Verify AutoRP mapping agent receives updated candidate RP announcement
# Mapping agent is not yet implemented
- #sleep(10)
+ # sleep(10)
def test_memory_leak():