diff options
author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2019-03-20 18:03:57 +0100 |
---|---|---|
committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2019-03-20 18:03:57 +0100 |
commit | 79d70a4c1b2c3901fa409979674cb0fcf704c8fa (patch) | |
tree | 66294c2a92efd93d410992c05e910dc7e8a601f6 /tests/topotests | |
parent | Add code to test some very basic pim functionality (diff) | |
download | frr-79d70a4c1b2c3901fa409979674cb0fcf704c8fa.tar.xz frr-79d70a4c1b2c3901fa409979674cb0fcf704c8fa.zip |
topotests: pim-basic: fix some rough edges
Move daemon configuration to appropriated files and use `json_cmp` to
assert the values we expect.
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'tests/topotests')
-rw-r--r-- | tests/topotests/pim-basic/r1/frr.conf | 19 | ||||
-rw-r--r-- | tests/topotests/pim-basic/r1/pimd.conf | 9 | ||||
-rw-r--r-- | tests/topotests/pim-basic/r1/zebra.conf | 7 | ||||
-rw-r--r-- | tests/topotests/pim-basic/r2/frr.conf | 14 | ||||
-rw-r--r-- | tests/topotests/pim-basic/r2/zebra.conf | 7 | ||||
-rw-r--r-- | tests/topotests/pim-basic/test_pim.py | 48 |
6 files changed, 51 insertions, 53 deletions
diff --git a/tests/topotests/pim-basic/r1/frr.conf b/tests/topotests/pim-basic/r1/frr.conf deleted file mode 100644 index 36433f73f..000000000 --- a/tests/topotests/pim-basic/r1/frr.conf +++ /dev/null @@ -1,19 +0,0 @@ -hostname r1 -interface r1-eth0 - ip address 10.0.20.1/24 -! -interface lo - ip address 10.254.0.1/32 -! -hostname r1 -! -! -interface r1-eth0 - ip igmp - ip pim sm -! -interface lo - ip pim sm -! -ip pim rp 10.254.0.1 - diff --git a/tests/topotests/pim-basic/r1/pimd.conf b/tests/topotests/pim-basic/r1/pimd.conf index faf7543ba..5740c66e2 100644 --- a/tests/topotests/pim-basic/r1/pimd.conf +++ b/tests/topotests/pim-basic/r1/pimd.conf @@ -1 +1,10 @@ hostname r1 +! +interface r1-eth0 + ip igmp + ip pim sm +! +interface lo + ip pim sm +! +ip pim rp 10.254.0.1 diff --git a/tests/topotests/pim-basic/r1/zebra.conf b/tests/topotests/pim-basic/r1/zebra.conf index faf7543ba..2bf71294d 100644 --- a/tests/topotests/pim-basic/r1/zebra.conf +++ b/tests/topotests/pim-basic/r1/zebra.conf @@ -1 +1,8 @@ hostname r1 +! +interface r1-eth0 + ip address 10.0.20.1/24 +! +interface lo + ip address 10.254.0.1/32 +! diff --git a/tests/topotests/pim-basic/r2/frr.conf b/tests/topotests/pim-basic/r2/frr.conf deleted file mode 100644 index 6473a466b..000000000 --- a/tests/topotests/pim-basic/r2/frr.conf +++ /dev/null @@ -1,14 +0,0 @@ -hostname r2 -interface r2-eth0 - ip address 10.0.20.2/24 -! -interface lo - ip address 10.254.0.2/32 -! -hostname r2 -interface r2-eth0 - ip address 10.0.21.2/24 -! -interface lo - ip address 10.254.0.2/32 -! diff --git a/tests/topotests/pim-basic/r2/zebra.conf b/tests/topotests/pim-basic/r2/zebra.conf index 932cff6f3..cb30858f5 100644 --- a/tests/topotests/pim-basic/r2/zebra.conf +++ b/tests/topotests/pim-basic/r2/zebra.conf @@ -1 +1,8 @@ hostname r2 +! +interface r2-eth0 + ip address 10.0.20.2/24 +! +interface lo + ip address 10.254.0.2/32 +! diff --git a/tests/topotests/pim-basic/test_pim.py b/tests/topotests/pim-basic/test_pim.py index 5d4f4b858..6d54b8f2f 100644 --- a/tests/topotests/pim-basic/test_pim.py +++ b/tests/topotests/pim-basic/test_pim.py @@ -71,10 +71,7 @@ def setup_module(mod): # After loading the configurations, this function loads configured daemons. tgen.start_router() - for rname, router in tgen.routers().iteritems(): - router.run("vtysh -f {}".format(os.path.join(CWD, '{}/frr.conf'.format(rname)))) - #tgen.mininet_cli() def teardown_module(mod): "Teardown the pytest environment" @@ -98,17 +95,22 @@ def test_pim_send_mcast_stream(): # Let's establish a S,G stream from r2 -> r1 CWD = os.path.dirname(os.path.realpath(__file__)) - out2 = r2.run("{}/mcast-tx.py --ttl 5 --count 5 --interval 10 229.1.1.1 r2-eth0 > /tmp/bar".format(CWD)) + r2.run("{}/mcast-tx.py --ttl 5 --count 5 --interval 10 229.1.1.1 r2-eth0 > /tmp/bar".format(CWD)) # Let's see that it shows up and we have established some basic state - out1 = r1.vtysh_cmd("show ip pim upstream json", isjson=True) + out = r1.vtysh_cmd("show ip pim upstream json", isjson=True) + expected = { + '229.1.1.1': { + '10.0.20.2': { + 'firstHopRouter': 1, + 'joinState': 'NotJoined', + 'regState': 'RegPrune', + 'inboundInterface': 'r1-eth0', + } + } + } - sg = out1['229.1.1.1']['10.0.20.2'] - assert sg['firstHopRouter'] == 1 - assert sg['joinState'] == "NotJoined" - assert sg['regState'] == "RegPrune" - assert sg['inboundInterface'] == "r1-eth0" - #tgen.mininet_cli() + assert topotest.json_cmp(out, expected) is None, 'failed to converge pim' def test_pim_igmp_report(): @@ -125,15 +127,21 @@ def test_pim_igmp_report(): # Let's send a igmp report from r2->r1 CWD = os.path.dirname(os.path.realpath(__file__)) - out2 = r2.run("{}/mcast-rx.py 229.1.1.2 r2-eth0 &".format(CWD)) - - out1 = r1.vtysh_cmd("show ip pim upstream json", isjson=True) - starg = out1['229.1.1.2']['*'] - assert starg['sourceIgmp'] == 1 - assert starg['joinState'] == "Joined" - assert starg['regState'] == "RegNoInfo" - assert starg['sptBit'] == 0 - #tgen.mininet_cli() + r2.run("{}/mcast-rx.py 229.1.1.2 r2-eth0 &".format(CWD)) + + out = r1.vtysh_cmd("show ip pim upstream json", isjson=True) + expected = { + '229.1.1.2': { + '*': { + 'sourceIgmp': 1, + 'joinState': 'Joined', + 'regState': 'RegNoInfo', + 'sptBit': 0, + } + } + } + + assert topotest.json_cmp(out, expected) is None, 'failed to converge pim' def test_memory_leak(): |