Skip to content

Commit

Permalink
topotato: strip header on RIP text compare
Browse files Browse the repository at this point in the history
This has changed between versions.  Should really be using a JSON
compare...

Signed-off-by: David Lamparter <[email protected]>
  • Loading branch information
eqvinox committed Sep 17, 2024
1 parent 1d73a71 commit b96cfe2
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions test_rip.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
TBD: incomplete.
"""

import re
from topotato.v1 import *


Expand Down Expand Up @@ -83,6 +84,12 @@ class Configs(FRRConfigs):
"""


def strip_header(text):
if m := re.match(r"""^Codes:.+?\n\n""", text, re.MULTILINE | re.DOTALL):
return text[m.end():]
return text


class RIPBasic(TestBase, AutoFixture, topo=topology, configs=Configs):
@topotatofunc
def test(self, topo, r1, r2, r3, rtsta):
Expand Down Expand Up @@ -162,11 +169,6 @@ def test(self, topo, r1, r2, r3, rtsta):
)

compare = r"""
Codes: R - RIP, C - connected, S - Static, O - OSPF, B - BGP
Sub-codes:
(n) - normal, (s) - static, (d) - default, (r) - redistribute,
(i) - interface
Network Next Hop Metric From Tag Time
R(n) 10.103.0.0/16 193.1.1.2 3 193.1.1.2 0 $$[0-9:]+$$
R(n) 10.104.0.0/16 193.1.1.2 3 193.1.1.2 0 $$[0-9:]+$$
Expand All @@ -175,14 +177,9 @@ def test(self, topo, r1, r2, r3, rtsta):
C(i) 193.1.1.0/26 0.0.0.0 1 self 0
R(n) 193.1.2.0/26 193.1.1.2 2 193.1.1.2 0 $$[0-9:]+$$
"""
yield from AssertVtysh.make(r1, "ripd", "show ip rip", compare, maxwait=10.0)
yield from AssertVtysh.make(r1, "ripd", "show ip rip", compare, maxwait=10.0, filters=[strip_header])

compare = r"""
Codes: R - RIP, C - connected, S - Static, O - OSPF, B - BGP
Sub-codes:
(n) - normal, (s) - static, (d) - default, (r) - redistribute,
(i) - interface
Network Next Hop Metric From Tag Time
R(n) 10.103.0.0/16 193.1.2.3 2 193.1.2.3 0 $$[0-9:]+$$
R(n) 10.104.0.0/16 193.1.2.3 2 193.1.2.3 0 $$[0-9:]+$$
Expand All @@ -191,14 +188,9 @@ def test(self, topo, r1, r2, r3, rtsta):
C(i) 193.1.1.0/26 0.0.0.0 1 self 0
C(i) 193.1.2.0/26 0.0.0.0 1 self 0
"""
yield from AssertVtysh.make(r2, "ripd", "show ip rip", compare, maxwait=10.0)
yield from AssertVtysh.make(r2, "ripd", "show ip rip", compare, maxwait=10.0, filters=[strip_header])

compare = r"""
Codes: R - RIP, C - connected, S - Static, O - OSPF, B - BGP
Sub-codes:
(n) - normal, (s) - static, (d) - default, (r) - redistribute,
(i) - interface
Network Next Hop Metric From Tag Time
C(r) 10.103.0.0/16 0.0.0.0 1 self 0
S(r) 10.104.0.0/16 10.103.0.4 1 self 0
Expand All @@ -207,4 +199,4 @@ def test(self, topo, r1, r2, r3, rtsta):
R(n) 193.1.1.0/26 193.1.2.2 2 193.1.2.2 0 $$[0-9:]+$$
C(i) 193.1.2.0/26 0.0.0.0 1 self 0
"""
yield from AssertVtysh.make(r3, "ripd", "show ip rip", compare, maxwait=10.0)
yield from AssertVtysh.make(r3, "ripd", "show ip rip", compare, maxwait=10.0, filters=[strip_header])

0 comments on commit b96cfe2

Please sign in to comment.