-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_pim_bfd.py
136 lines (118 loc) Β· 3.9 KB
/
test_pim_bfd.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
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2018-2022 David Lamparter for NetDEF, Inc.
"""
IPv4 PIM + BFD test.
TBD: incomplete, mostly used to test topotato ModifyLinkStatus.
"""
from topotato.v1 import *
@topology_fixture()
def topology(topo):
"""
[ r1 ]
|
[ r2 ]--[ r3 ]
|
[ r4 ]
"""
class Configs(FRRConfigs):
zebra = """
#% extends "boilerplate.conf"
"""
bfdd = """
#% extends "boilerplate.conf"
#% block main
bfd
#% if router.name == 'r1'
profile fast-tx
receive-interval 250
transmit-interval 250
!
#% endif
!
#% endblock
"""
pimd = """
#% extends "boilerplate.conf"
#% block main
#% for iface in router.ifaces
!
interface {{ iface.ifname }}
ip pim
ip pim hello 1 3
#% if router.name == 'r1'
ip pim bfd profile fast-tx
#% else
ip pim bfd
#% endif
#% endfor
#% endblock
"""
class PIMBFDTest(TestBase, AutoFixture, topo=topology, configs=Configs):
@topotatofunc
def test(self, topo, r1, r2, r3, r4):
def expect_neighbor(rtr, ifname, peer, deadline):
js = {
ifname: {
str(peer.ip4[0].ip): JSONCompareIgnoreContent(),
},
}
yield from AssertVtysh.make(
rtr, "pimd", "show ip pim neighbor json", js, maxwait=deadline
)
def expect_neighbor_down(rtr, ifname, peer, deadline):
js = {
ifname: {
str(peer.ip4[0].ip): None,
},
}
yield from AssertVtysh.make(
rtr, "pimd", "show ip pim neighbor json", js, maxwait=deadline
)
def expect_bfd_peer(rtr, peer, deadline):
js = [
{
"peer": str(peer.ip4[0].ip),
"status": "up",
}
]
yield from AssertVtysh.make(
rtr, "bfdd", "enable\nshow bfd peers json", js, maxwait=deadline
)
# PIM neighbors
yield from expect_neighbor(r2, "r2-r1", r1.iface_to("r2"), 5.0)
yield from expect_neighbor(r1, "r1-r2", r2.iface_to("r1"), 5.0)
yield from expect_neighbor(r2, "r2-r3", r3.iface_to("r2"), 5.0)
yield from expect_neighbor(r3, "r3-r2", r2.iface_to("r3"), 5.0)
yield from expect_neighbor(r2, "r2-r4", r4.iface_to("r2"), 5.0)
yield from expect_neighbor(r4, "r4-r2", r2.iface_to("r4"), 5.0)
# BFD sessions
yield from expect_bfd_peer(r2, r1.iface_to("r2"), 6.0)
yield from expect_bfd_peer(r1, r2.iface_to("r1"), 6.0)
yield from expect_bfd_peer(r2, r3.iface_to("r2"), 6.0)
yield from expect_bfd_peer(r3, r2.iface_to("r3"), 6.0)
yield from expect_bfd_peer(r2, r4.iface_to("r2"), 6.0)
yield from expect_bfd_peer(r4, r2.iface_to("r4"), 6.0)
# flip r4 off
yield from ModifyLinkStatus.make(r4, r4.iface_to("r2"), False)
yield from expect_neighbor_down(r2, "r2-r4", r4.iface_to("r2"), 9.0)
# and back on
yield from ModifyLinkStatus.make(r4, r4.iface_to("r2"), True)
yield from expect_neighbor(r2, "r2-r4", r4.iface_to("r2"), 12.0)
yield from expect_neighbor(r4, "r4-r2", r2.iface_to("r4"), 12.0)
js = [
{
"peer": str(r2.iface_to("r1").ip4[0].ip),
"receive-interval": 250,
"transmit-interval": 250,
}
]
yield from AssertVtysh.make(r1, "bfdd", "enable\nshow bfd peers json", js)
js = [
{
"peer": str(r1.iface_to("r2").ip4[0].ip),
"remote-receive-interval": 250,
"remote-transmit-interval": 250,
}
]
yield from AssertVtysh.make(r2, "bfdd", "enable\nshow bfd peers json", js)