-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_rip.py
202 lines (184 loc) Β· 7.45 KB
/
test_rip.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2018-2022 David Lamparter for NetDEF, Inc.
"""
Basic IPv4 RIP test.
TBD: incomplete.
"""
import re
from topotato.v1 import *
@topology_fixture()
def topology(topo):
"""
[ ]--{ stub1 }
[ ]
[ r1 ]--{ stub2 }
[ ]
[ ]--{ stub3 }
|
{ lan1 }
|
[ r2 ]
|
{ lan2 }
|
[ r3 ]
|
{ lan3 }
|
[ rtsta ]--{ lansta }
"""
topo.lan("lan1").ip4.append("193.1.1.0/26")
topo.lan("lan2").ip4.append("193.1.2.0/26")
topo.noauto_v6 = True
topo.lo_v4 = False
class Configs(FRRConfigs):
zebra_routers = ["r1", "r2", "r3"]
zebra = """
#% extends "boilerplate.conf"
#% for iface in router.ifaces
interface {{ iface.ifname }}
no link-detect
#% endfor
"""
ripd_routers = ["r1", "r2", "r3"]
ripd = """
#% extends "boilerplate.conf"
#% block main
router rip
version 2
timers basic 5 180 5
##
#% if router.name == 'r1'
network 193.1.1.0/26
network r1-stub2
network r1-stub3
passive-interface r1-stub3
##
#% elif router.name == 'r2'
network 193.1.1.0/26
network 193.1.2.0/24
##
#% elif router.name == 'r3'
redistribute connected
redistribute static
network 193.1.2.0/24
#% endif
#% endblock
"""
staticd_routers = ["r3"]
staticd = """
#% extends "boilerplate.conf"
#% block main
ip route 10.104.0.0/16 10.103.0.4
#% endblock
"""
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):
compare = r"""
Routing Protocol is "rip"
Sending updates every 5 seconds with +/-50%, next due in $$\d+$$ seconds
Timeout after 180 seconds, garbage collect after 5 seconds
Outgoing update filter list for all interface is not set
Incoming update filter list for all interface is not set
Default redistribution metric is 1
Redistributing:
Default version control: send version 2, receive version 2
Interface Send Recv Key-chain
r1-lan1 2 2
r1-stub2 2 2
r1-stub3 2 2
Routing for Networks:
193.1.1.0/26
r1-stub2
r1-stub3
Passive Interface(s):
r1-stub3
Routing Information Sources:
Gateway BadPackets BadRoutes Distance Last Update
193.1.1.2 $$\s*$$ 0 0 120 $$\s*[0-9:]+$$
Distance: (default is 120)
"""
yield from AssertVtysh.make(
r1, "ripd", "show ip rip status", compare, maxwait=6.0
)
compare = r"""
Routing Protocol is "rip"
Sending updates every 5 seconds with +/-50%, next due in $$\d+$$ seconds
Timeout after 180 seconds, garbage collect after 5 seconds
Outgoing update filter list for all interface is not set
Incoming update filter list for all interface is not set
Default redistribution metric is 1
Redistributing:
Default version control: send version 2, receive version 2
Interface Send Recv Key-chain
r2-lan1 2 2
r2-lan2 2 2
Routing for Networks:
193.1.1.0/26
193.1.2.0/24
Routing Information Sources:
Gateway BadPackets BadRoutes Distance Last Update
193.1.1.1 $$\s*$$ 0 0 120 $$\s*[0-9:]+$$
193.1.2.3 $$\s*$$ 0 0 120 $$\s*[0-9:]+$$
Distance: (default is 120)
"""
yield from AssertVtysh.make(
r2, "ripd", "show ip rip status", compare, maxwait=6.0
)
compare = r"""
Routing Protocol is "rip"
Sending updates every 5 seconds with +/-50%, next due in $$\d+$$ seconds
Timeout after 180 seconds, garbage collect after 5 seconds
Outgoing update filter list for all interface is not set
Incoming update filter list for all interface is not set
Default redistribution metric is 1
Redistributing: connected static
Default version control: send version 2, receive version 2
Interface Send Recv Key-chain
r3-lan2 2 2
Routing for Networks:
193.1.2.0/24
Routing Information Sources:
Gateway BadPackets BadRoutes Distance Last Update
193.1.2.2 $$\s*$$ 0 0 120 $$\s*[0-9:]+$$
Distance: (default is 120)
"""
yield from AssertVtysh.make(
r3, "ripd", "show ip rip status", compare, maxwait=6.0
)
compare = r"""
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:]+$$
C(i) 10.106.0.0/16 0.0.0.0 1 self 0
C(i) 10.107.0.0/16 0.0.0.0 1 self 0
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, filters=[strip_header])
compare = r"""
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:]+$$
R(n) 10.106.0.0/16 193.1.1.1 2 193.1.1.1 0 $$[0-9:]+$$
R(n) 10.107.0.0/16 193.1.1.1 2 193.1.1.1 0 $$[0-9:]+$$
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, filters=[strip_header])
compare = r"""
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
R(n) 10.106.0.0/16 193.1.2.2 3 193.1.2.2 0 $$[0-9:]+$$
R(n) 10.107.0.0/16 193.1.2.2 3 193.1.2.2 0 $$[0-9:]+$$
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, filters=[strip_header])