]> git.puffer.fish Git - matthieu/frr.git/commitdiff
topotest: add tests for BFD profiles
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Fri, 29 May 2020 20:44:02 +0000 (17:44 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Fri, 12 Jun 2020 17:25:53 +0000 (14:25 -0300)
Import a topology with some protocols that integrate with BFD. As other
daemons get the new BFD profile support we can update the test to cover
them.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
31 files changed:
tests/topotests/bfd-profiles-topo1/__init__.py [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r1/bfd-peers-initial.json [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r1/bfdd.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r1/ospfd.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r1/zebra.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r2/bfd-peers-initial.json [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r2/bfdd.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r2/bgpd.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r2/zebra.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r3/bfd-peers-initial.json [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r3/bfdd.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r3/bgpd.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r3/isisd.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r3/zebra.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r4/bfd-peers-initial.json [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r4/bfdd.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r4/bgpd.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r4/isisd.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r4/ospf6d.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r4/zebra.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r5/bfd-peers-initial.json [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r5/bfdd.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r5/ospf6d.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r5/zebra.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r6/bfd-peers-initial.json [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r6/bfdd.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r6/ospfd.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/r6/zebra.conf [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/test_bfd_profiles_topo1.dot [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/test_bfd_profiles_topo1.png [new file with mode: 0644]
tests/topotests/bfd-profiles-topo1/test_bfd_profiles_topo1.py [new file with mode: 0644]

diff --git a/tests/topotests/bfd-profiles-topo1/__init__.py b/tests/topotests/bfd-profiles-topo1/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/topotests/bfd-profiles-topo1/r1/bfd-peers-initial.json b/tests/topotests/bfd-profiles-topo1/r1/bfd-peers-initial.json
new file mode 100644 (file)
index 0000000..bab24c4
--- /dev/null
@@ -0,0 +1,38 @@
+[
+    {
+        "detect-multiplier": 3,
+        "diagnostic": "ok",
+        "id": "*",
+        "interface": "r1-eth1",
+        "multihop": false,
+        "peer": "172.16.100.2",
+        "receive-interval": 300,
+        "remote-detect-multiplier": 3,
+        "remote-diagnostic": "ok",
+        "remote-id": "*",
+        "remote-receive-interval": 300,
+        "remote-transmit-interval": 300,
+        "status": "up",
+        "transmit-interval": 300,
+        "uptime": "*",
+        "vrf": "default"
+    },
+    {
+        "detect-multiplier": 3,
+        "diagnostic": "ok",
+        "id": "*",
+        "interface": "r1-eth0",
+        "multihop": false,
+        "peer": "172.16.0.1",
+        "receive-interval": 800,
+        "remote-detect-multiplier": 3,
+        "remote-diagnostic": "ok",
+        "remote-id": "*",
+        "remote-receive-interval": 800,
+        "remote-transmit-interval": 800,
+        "status": "up",
+        "transmit-interval": 800,
+        "uptime": "*",
+        "vrf": "default"
+    }
+]
diff --git a/tests/topotests/bfd-profiles-topo1/r1/bfdd.conf b/tests/topotests/bfd-profiles-topo1/r1/bfdd.conf
new file mode 100644 (file)
index 0000000..4d636ab
--- /dev/null
@@ -0,0 +1,14 @@
+debug bfd peer
+debug bfd network
+debug bfd zebra
+!
+bfd
+ profile slowtx
+  receive-interval 800
+  transmit-interval 800
+ !
+ peer 172.16.0.1 interface r1-eth0
+  profile slowtx
+  no shutdown
+ !
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r1/ospfd.conf b/tests/topotests/bfd-profiles-topo1/r1/ospfd.conf
new file mode 100644 (file)
index 0000000..c089635
--- /dev/null
@@ -0,0 +1,8 @@
+interface r1-eth1
+ ip ospf area 0
+ ip ospf bfd
+!
+router ospf
+ ospf router-id 10.254.254.1
+ redistribute connected
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r1/zebra.conf b/tests/topotests/bfd-profiles-topo1/r1/zebra.conf
new file mode 100644 (file)
index 0000000..4b7982b
--- /dev/null
@@ -0,0 +1,9 @@
+interface lo
+ ip address 10.254.254.1/32
+!
+interface r1-eth0
+ ip address 172.16.0.2/24
+!
+interface r1-eth1
+ ip address 172.16.100.1/24
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r2/bfd-peers-initial.json b/tests/topotests/bfd-profiles-topo1/r2/bfd-peers-initial.json
new file mode 100644 (file)
index 0000000..3df9ec9
--- /dev/null
@@ -0,0 +1,39 @@
+[
+    {
+        "detect-multiplier": 3,
+        "diagnostic": "ok",
+        "id": "*",
+        "interface": "r2-eth0",
+        "multihop": false,
+        "peer": "172.16.0.2",
+        "receive-interval": 800,
+        "remote-detect-multiplier": 3,
+        "remote-diagnostic": "ok",
+        "remote-id": "*",
+        "remote-receive-interval": 800,
+        "remote-transmit-interval": 800,
+        "status": "up",
+        "transmit-interval": 800,
+        "uptime": "*",
+        "vrf": "default"
+    },
+    {
+        "detect-multiplier": 3,
+        "diagnostic": "ok",
+        "id": "*",
+        "interface": "r2-eth1",
+        "multihop": false,
+        "peer": "172.16.1.1",
+        "receive-interval": 250,
+        "remote-detect-multiplier": 3,
+        "remote-diagnostic": "ok",
+        "remote-echo-interval": 50,
+        "remote-id": "*",
+        "remote-receive-interval": 300,
+        "remote-transmit-interval": 300,
+        "status": "up",
+        "transmit-interval": 250,
+        "uptime": "*",
+        "vrf": "default"
+    }
+]
diff --git a/tests/topotests/bfd-profiles-topo1/r2/bfdd.conf b/tests/topotests/bfd-profiles-topo1/r2/bfdd.conf
new file mode 100644 (file)
index 0000000..23a39a6
--- /dev/null
@@ -0,0 +1,18 @@
+debug bfd peer
+debug bfd network
+debug bfd zebra
+!
+bfd
+ profile slowtx
+  receive-interval 800
+  transmit-interval 800
+ !
+ profile fasttx
+  receive-interval 250
+  transmit-interval 250
+ !
+ peer 172.16.0.2 interface r2-eth0
+  profile slowtx
+  no shutdown
+ !
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r2/bgpd.conf b/tests/topotests/bfd-profiles-topo1/r2/bgpd.conf
new file mode 100644 (file)
index 0000000..824d019
--- /dev/null
@@ -0,0 +1,19 @@
+debug bgp neighbor-events
+!
+router bgp 100
+ bgp router-id 10.254.254.2
+ no bgp ebgp-requires-policy
+ neighbor 172.16.1.1 remote-as 100
+ neighbor 172.16.1.1 bfd profile fasttx
+ neighbor 2001:db8:2::2 remote-as 200
+ neighbor 2001:db8:2::2 ebgp-multihop 2
+ neighbor 2001:db8:2::2 bfd profile slowtx
+ address-family ipv4 unicast
+  redistribute connected
+ exit-address-family
+ address-family ipv6 unicast
+  redistribute connected
+  neighbor 172.16.1.1 activate
+  neighbor 2001:db8:2::2 activate
+ exit-address-family
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r2/zebra.conf b/tests/topotests/bfd-profiles-topo1/r2/zebra.conf
new file mode 100644 (file)
index 0000000..6acef13
--- /dev/null
@@ -0,0 +1,10 @@
+interface lo
+ ip address 10.254.254.2/32
+!
+interface r2-eth0
+ ip address 172.16.0.1/24
+!
+interface r2-eth1
+ ip address 172.16.1.2/24
+ ipv6 address 2001:db8:1::2/64
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r3/bfd-peers-initial.json b/tests/topotests/bfd-profiles-topo1/r3/bfd-peers-initial.json
new file mode 100644 (file)
index 0000000..abca1ed
--- /dev/null
@@ -0,0 +1,39 @@
+[
+    {
+        "detect-multiplier": 3,
+        "diagnostic": "ok",
+        "id": "*",
+        "interface": "r3-eth0",
+        "multihop": false,
+        "peer": "172.16.1.2",
+        "receive-interval": 300,
+        "remote-detect-multiplier": 3,
+        "remote-diagnostic": "ok",
+        "remote-id": "*",
+        "remote-receive-interval": 250,
+        "remote-transmit-interval": 250,
+        "status": "up",
+        "transmit-interval": 300,
+        "uptime": "*",
+        "vrf": "default"
+    },
+    {
+        "detect-multiplier": 3,
+        "diagnostic": "ok",
+        "id": "*",
+        "interface": "r3-eth1",
+        "local": "*",
+        "multihop": false,
+        "peer": "*",
+        "receive-interval": 300,
+        "remote-detect-multiplier": 3,
+        "remote-diagnostic": "ok",
+        "remote-id": "*",
+        "remote-receive-interval": 300,
+        "remote-transmit-interval": 300,
+        "status": "up",
+        "transmit-interval": 300,
+        "uptime": "*",
+        "vrf": "default"
+    }
+]
diff --git a/tests/topotests/bfd-profiles-topo1/r3/bfdd.conf b/tests/topotests/bfd-profiles-topo1/r3/bfdd.conf
new file mode 100644 (file)
index 0000000..74dae5a
--- /dev/null
@@ -0,0 +1,11 @@
+debug bfd peer
+debug bfd network
+debug bfd zebra
+!
+bfd
+ ! profile is commented out on purpose.
+ !profile fasttx
+ ! receive-interval 250
+ ! transmit-interval 250
+ !!
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r3/bgpd.conf b/tests/topotests/bfd-profiles-topo1/r3/bgpd.conf
new file mode 100644 (file)
index 0000000..9c56a34
--- /dev/null
@@ -0,0 +1,13 @@
+router bgp 100
+ bgp router-id 10.254.254.3
+ neighbor 172.16.1.2 remote-as 100
+ neighbor 172.16.1.2 bfd profile fasttx
+ address-family ipv4 unicast
+  redistribute connected
+ exit-address-family
+ address-family ipv6 unicast
+  redistribute connected
+  neighbor 172.16.1.2 activate
+ exit-address-family
+ !
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r3/isisd.conf b/tests/topotests/bfd-profiles-topo1/r3/isisd.conf
new file mode 100644 (file)
index 0000000..5d774a3
--- /dev/null
@@ -0,0 +1,15 @@
+hostname r3
+!
+debug isis adj-packets
+debug isis events
+debug isis update-packets
+!
+interface r3-eth1
+ ipv6 router isis lan
+ isis circuit-type level-1
+ isis bfd
+!
+router isis lan
+ net 10.0000.0000.0000.0000.0000.0000.0000.0000.0001.00
+ redistribute ipv6 connected level-1
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r3/zebra.conf b/tests/topotests/bfd-profiles-topo1/r3/zebra.conf
new file mode 100644 (file)
index 0000000..2297bfa
--- /dev/null
@@ -0,0 +1,12 @@
+ipv6 forwarding
+!
+interface lo
+ ip address 10.254.254.3/32
+!
+interface r3-eth0
+ ip address 172.16.1.1/24
+ ipv6 address 2001:db8:1::1/64
+!
+interface r3-eth1
+ ipv6 address 2001:db8:2::1/64
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r4/bfd-peers-initial.json b/tests/topotests/bfd-profiles-topo1/r4/bfd-peers-initial.json
new file mode 100644 (file)
index 0000000..c8bc4c2
--- /dev/null
@@ -0,0 +1,41 @@
+[
+    {
+        "detect-multiplier": 3,
+        "diagnostic": "ok",
+        "id": "*",
+        "interface": "r4-eth0",
+        "local": "*",
+        "multihop": false,
+        "peer": "*",
+        "receive-interval": 300,
+        "remote-detect-multiplier": 3,
+        "remote-diagnostic": "ok",
+        "remote-id": "*",
+        "remote-receive-interval": 300,
+        "remote-transmit-interval": 300,
+        "status": "up",
+        "transmit-interval": 300,
+        "uptime": "*",
+        "vrf": "default"
+    },
+    {
+        "detect-multiplier": 3,
+        "diagnostic": "ok",
+        "id": "*",
+        "interface": "r4-eth1",
+        "local": "*",
+        "multihop": false,
+        "peer": "*",
+        "receive-interval": 300,
+        "remote-detect-multiplier": 3,
+        "remote-diagnostic": "ok",
+        "remote-echo-interval": 50,
+        "remote-id": "*",
+        "remote-receive-interval": 300,
+        "remote-transmit-interval": 300,
+        "status": "up",
+        "transmit-interval": 300,
+        "uptime": "*",
+        "vrf": "default"
+    }
+]
diff --git a/tests/topotests/bfd-profiles-topo1/r4/bfdd.conf b/tests/topotests/bfd-profiles-topo1/r4/bfdd.conf
new file mode 100644 (file)
index 0000000..36ef4f0
--- /dev/null
@@ -0,0 +1,6 @@
+debug bfd peer
+debug bfd network
+debug bfd zebra
+!
+bfd
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r4/bgpd.conf b/tests/topotests/bfd-profiles-topo1/r4/bgpd.conf
new file mode 100644 (file)
index 0000000..7c4b39b
--- /dev/null
@@ -0,0 +1,17 @@
+debug bgp neighbor-events
+!
+router bgp 200
+ bgp router-id 10.254.254.4
+ no bgp ebgp-requires-policy
+ neighbor 2001:db8:1::2 remote-as 100
+ neighbor 2001:db8:1::2 ebgp-multihop 2
+ neighbor 2001:db8:1::2 bfd profile fasttx
+ address-family ipv4 unicast
+  redistribute connected
+ exit-address-family
+ address-family ipv6 unicast
+  redistribute connected
+  neighbor 2001:db8:1::2 activate
+ exit-address-family
+ !
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r4/isisd.conf b/tests/topotests/bfd-profiles-topo1/r4/isisd.conf
new file mode 100644 (file)
index 0000000..4777400
--- /dev/null
@@ -0,0 +1,15 @@
+hostname r4
+!
+debug isis adj-packets
+debug isis events
+debug isis update-packets
+!
+interface r4-eth0
+ ipv6 router isis lan
+ isis circuit-type level-1
+ isis bfd
+!
+router isis lan
+ net 10.0000.0000.0000.0000.0000.0000.0000.0000.0002.00
+ redistribute ipv6 connected level-1
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r4/ospf6d.conf b/tests/topotests/bfd-profiles-topo1/r4/ospf6d.conf
new file mode 100644 (file)
index 0000000..84157de
--- /dev/null
@@ -0,0 +1,8 @@
+interface r4-eth1
+ ipv6 ospf6 bfd
+!
+router ospf6
+ ospf6 router-id 10.254.254.4
+ redistribute connected
+ interface r4-eth1 area 0.0.0.0
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r4/zebra.conf b/tests/topotests/bfd-profiles-topo1/r4/zebra.conf
new file mode 100644 (file)
index 0000000..753041f
--- /dev/null
@@ -0,0 +1,12 @@
+ipv6 forwarding
+!
+interface lo
+ ip address 10.254.254.4/32
+!
+interface r4-eth0
+ ipv6 address 2001:db8:2::2/64
+!
+interface r4-eth1
+ ip address 172.16.3.1/24
+ ipv6 address 2001:db8:3::1/64
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r5/bfd-peers-initial.json b/tests/topotests/bfd-profiles-topo1/r5/bfd-peers-initial.json
new file mode 100644 (file)
index 0000000..fcb0909
--- /dev/null
@@ -0,0 +1,21 @@
+[
+    {
+        "detect-multiplier": 3,
+        "diagnostic": "ok",
+        "id": "*",
+        "interface": "r5-eth0",
+        "local": "*",
+        "multihop": false,
+        "peer": "*",
+        "receive-interval": 300,
+        "remote-detect-multiplier": 3,
+        "remote-diagnostic": "ok",
+        "remote-id": "*",
+        "remote-receive-interval": 300,
+        "remote-transmit-interval": 300,
+        "status": "up",
+        "transmit-interval": 300,
+        "uptime": "*",
+        "vrf": "default"
+    }
+]
diff --git a/tests/topotests/bfd-profiles-topo1/r5/bfdd.conf b/tests/topotests/bfd-profiles-topo1/r5/bfdd.conf
new file mode 100644 (file)
index 0000000..74dae5a
--- /dev/null
@@ -0,0 +1,11 @@
+debug bfd peer
+debug bfd network
+debug bfd zebra
+!
+bfd
+ ! profile is commented out on purpose.
+ !profile fasttx
+ ! receive-interval 250
+ ! transmit-interval 250
+ !!
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r5/ospf6d.conf b/tests/topotests/bfd-profiles-topo1/r5/ospf6d.conf
new file mode 100644 (file)
index 0000000..970c713
--- /dev/null
@@ -0,0 +1,8 @@
+interface r5-eth0
+ ipv6 ospf6 bfd
+!
+router ospf6
+ ospf6 router-id 10.254.254.5
+ redistribute connected
+ interface r5-eth0 area 0.0.0.0
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r5/zebra.conf b/tests/topotests/bfd-profiles-topo1/r5/zebra.conf
new file mode 100644 (file)
index 0000000..de8ae16
--- /dev/null
@@ -0,0 +1,6 @@
+interface lo
+ ip address 10.254.254.5/32
+!
+interface r5-eth0
+ ipv6 address 2001:db8:3::2/64
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r6/bfd-peers-initial.json b/tests/topotests/bfd-profiles-topo1/r6/bfd-peers-initial.json
new file mode 100644 (file)
index 0000000..4e6fa86
--- /dev/null
@@ -0,0 +1,20 @@
+[
+    {
+        "detect-multiplier": 3,
+        "diagnostic": "ok",
+        "id": "*",
+        "interface": "r6-eth0",
+        "multihop": false,
+        "peer": "172.16.100.1",
+        "receive-interval": 300,
+        "remote-detect-multiplier": 3,
+        "remote-diagnostic": "ok",
+        "remote-id": "*",
+        "remote-receive-interval": 300,
+        "remote-transmit-interval": 300,
+        "status": "up",
+        "transmit-interval": 300,
+        "uptime": "*",
+        "vrf": "default"
+    }
+]
diff --git a/tests/topotests/bfd-profiles-topo1/r6/bfdd.conf b/tests/topotests/bfd-profiles-topo1/r6/bfdd.conf
new file mode 100644 (file)
index 0000000..74dae5a
--- /dev/null
@@ -0,0 +1,11 @@
+debug bfd peer
+debug bfd network
+debug bfd zebra
+!
+bfd
+ ! profile is commented out on purpose.
+ !profile fasttx
+ ! receive-interval 250
+ ! transmit-interval 250
+ !!
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r6/ospfd.conf b/tests/topotests/bfd-profiles-topo1/r6/ospfd.conf
new file mode 100644 (file)
index 0000000..f168444
--- /dev/null
@@ -0,0 +1,8 @@
+interface r6-eth0
+ ip ospf area 0
+ ip ospf bfd
+!
+router ospf
+ ospf router-id 10.254.254.6
+ redistribute connected
+!
diff --git a/tests/topotests/bfd-profiles-topo1/r6/zebra.conf b/tests/topotests/bfd-profiles-topo1/r6/zebra.conf
new file mode 100644 (file)
index 0000000..c0804b9
--- /dev/null
@@ -0,0 +1,6 @@
+interface lo
+ ip address 10.254.254.6/32
+!
+interface r6-eth0
+ ip address 172.16.100.2/24
+!
diff --git a/tests/topotests/bfd-profiles-topo1/test_bfd_profiles_topo1.dot b/tests/topotests/bfd-profiles-topo1/test_bfd_profiles_topo1.dot
new file mode 100644 (file)
index 0000000..a393609
--- /dev/null
@@ -0,0 +1,97 @@
+## Color coding:
+#########################
+##  Main FRR: #f08080  red
+##  Switches: #d0e0d0  gray
+##  RIP:      #19e3d9  Cyan
+##  RIPng:    #fcb314  dark yellow
+##  OSPFv2:   #32b835  Green
+##  OSPFv3:   #19e3d9  Cyan
+##  ISIS IPv4 #fcb314  dark yellow
+##  ISIS IPv6 #9a81ec  purple
+##  BGP IPv4  #eee3d3  beige
+##  BGP IPv6  #fdff00  yellow
+##### Colors (see http://www.color-hex.com/)
+
+graph template {
+  label="bfd-profiles-topo1";
+
+  # Routers
+  r1 [
+    shape=doubleoctagon,
+    label="r1",
+    fillcolor="#f08080",
+    style=filled,
+  ];
+  r2 [
+    shape=doubleoctagon
+    label="r2",
+    fillcolor="#f08080",
+    style=filled,
+  ];
+  r3 [
+    shape=doubleoctagon
+    label="r3",
+    fillcolor="#f08080",
+    style=filled,
+  ];
+  r4 [
+    shape=doubleoctagon
+    label="r4",
+    fillcolor="#f08080",
+    style=filled,
+  ];
+  r5 [
+    shape=doubleoctagon
+    label="r5",
+    fillcolor="#f08080",
+    style=filled,
+  ];
+
+  # Switches
+  sw1 [
+    shape=oval,
+    label="sw1\n172.16.0.0/24",
+    fillcolor="#d0e0d0",
+    style=filled,
+  ];
+  sw2 [
+    shape=oval,
+    label="sw2\n172.16.1.0/24\n2001:db8:1::/64",
+    fillcolor="#d0e0d0",
+    style=filled,
+  ];
+  sw3 [
+    shape=oval,
+    label="sw3\n2001:db8:2::/64",
+    fillcolor="#d0e0d0",
+    style=filled,
+  ];
+  sw4 [
+    shape=oval,
+    label="sw4\n2001:db8:3::/64",
+    fillcolor="#d0e0d0",
+    style=filled,
+  ];
+  sw5 [
+    shape=oval,
+    label="sw5\n172.16.100.0/24",
+    fillcolor="#d0e0d0",
+    style=filled,
+  ];
+
+  # Connections
+  r1 -- sw1 [label="eth0"];
+  r2 -- sw1 [label="eth0"];
+
+  r2 -- sw2 [label="eth1"];
+  r3 -- sw2 [label="eth0"];
+
+  r3 -- sw3 [label="eth1"];
+  r4 -- sw3 [label="eth0"];
+
+  r4 -- sw4 [label="eth1"];
+  r5 -- sw4 [label="eth0"];
+
+  r1 -- sw5 [label="eth1"];
+  r6 -- sw5 [label="eth0"];
+}
diff --git a/tests/topotests/bfd-profiles-topo1/test_bfd_profiles_topo1.png b/tests/topotests/bfd-profiles-topo1/test_bfd_profiles_topo1.png
new file mode 100644 (file)
index 0000000..775fae1
Binary files /dev/null and b/tests/topotests/bfd-profiles-topo1/test_bfd_profiles_topo1.png differ
diff --git a/tests/topotests/bfd-profiles-topo1/test_bfd_profiles_topo1.py b/tests/topotests/bfd-profiles-topo1/test_bfd_profiles_topo1.py
new file mode 100644 (file)
index 0000000..02385b3
--- /dev/null
@@ -0,0 +1,198 @@
+#!/usr/bin/env python
+
+#
+# test_bfd_profiles_topo1.py
+# Part of NetDEF Topology Tests
+#
+# Copyright (c) 2020 by
+# Network Device Education Foundation, Inc. ("NetDEF")
+#
+# Permission to use, copy, modify, and/or distribute this software
+# for any purpose with or without fee is hereby granted, provided
+# that the above copyright notice and this permission notice appear
+# in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
+# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+#
+
+"""
+test_bfd_profiles_topo1.py: Test the FRR BFD profile protocol integration.
+"""
+
+import os
+import sys
+import json
+from functools import partial
+import pytest
+
+# Save the Current Working Directory to find configuration files.
+CWD = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(CWD, "../"))
+
+# pylint: disable=C0413
+# Import topogen and topotest helpers
+from lib import topotest
+from lib.topogen import Topogen, TopoRouter, get_topogen
+from lib.topolog import logger
+
+# Required to instantiate the topology builder class.
+from mininet.topo import Topo
+
+
+class BFDProfTopo(Topo):
+    "Test topology builder"
+
+    def build(self, *_args, **_opts):
+        "Build function"
+        tgen = get_topogen(self)
+
+        # Create 6 routers
+        for routern in range(1, 7):
+            tgen.add_router("r{}".format(routern))
+
+        switch = tgen.add_switch("s1")
+        switch.add_link(tgen.gears["r1"])
+        switch.add_link(tgen.gears["r2"])
+
+        switch = tgen.add_switch("s2")
+        switch.add_link(tgen.gears["r2"])
+        switch.add_link(tgen.gears["r3"])
+
+        switch = tgen.add_switch("s3")
+        switch.add_link(tgen.gears["r3"])
+        switch.add_link(tgen.gears["r4"])
+
+        switch = tgen.add_switch("s4")
+        switch.add_link(tgen.gears["r4"])
+        switch.add_link(tgen.gears["r5"])
+
+        switch = tgen.add_switch("s5")
+        switch.add_link(tgen.gears["r1"])
+        switch.add_link(tgen.gears["r6"])
+
+
+def setup_module(mod):
+    "Sets up the pytest environment"
+    tgen = Topogen(BFDProfTopo, mod.__name__)
+    tgen.start_topology()
+
+    router_list = tgen.routers()
+    for rname, router in router_list.iteritems():
+        daemon_file = "{}/{}/bfdd.conf".format(CWD, rname)
+        if os.path.isfile(daemon_file):
+            router.load_config(TopoRouter.RD_BFD, daemon_file)
+
+        daemon_file = "{}/{}/bgpd.conf".format(CWD, rname)
+        if os.path.isfile(daemon_file):
+            router.load_config(TopoRouter.RD_BGP, daemon_file)
+
+        daemon_file = "{}/{}/isisd.conf".format(CWD, rname)
+        if os.path.isfile(daemon_file):
+            router.load_config(TopoRouter.RD_ISIS, daemon_file)
+
+        daemon_file = "{}/{}/ospfd.conf".format(CWD, rname)
+        if os.path.isfile(daemon_file):
+            router.load_config(TopoRouter.RD_OSPF, daemon_file)
+
+        daemon_file = "{}/{}/ospf6d.conf".format(CWD, rname)
+        if os.path.isfile(daemon_file):
+            router.load_config(TopoRouter.RD_OSPF6, daemon_file)
+
+        daemon_file = "{}/{}/zebra.conf".format(CWD, rname)
+        if os.path.isfile(daemon_file):
+            router.load_config(TopoRouter.RD_ZEBRA, daemon_file)
+
+    # Initialize all routers.
+    tgen.start_router()
+
+
+def teardown_module(_mod):
+    "Teardown the pytest environment"
+    tgen = get_topogen()
+    tgen.stop_topology()
+
+def test_wait_protocols_convergence():
+    "Wait for all protocols to converge"
+    tgen = get_topogen()
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    logger.info("waiting for protocols to converge")
+
+    def expect_loopback_route(router, iptype, route, proto):
+        "Wait until route is present on RIB for protocol."
+        logger.info('waiting route {} in {}'.format(route, router))
+        test_func = partial(
+            topotest.router_json_cmp,
+            tgen.gears[router],
+            'show {} route json'.format(iptype),
+            { route: [{ 'protocol': proto }] }
+        )
+        _, result = topotest.run_and_expect(test_func, None, count=130, wait=1)
+        assertmsg = '"{}" OSPF convergence failure'.format(router)
+        assert result is None, assertmsg
+
+
+    # Wait for R1 <-> R6 convergence.
+    expect_loopback_route('r1', 'ip', '10.254.254.6/32', 'ospf')
+
+    # Wait for R6 <-> R1 convergence.
+    expect_loopback_route('r6', 'ip', '10.254.254.1/32', 'ospf')
+
+    # Wait for R2 <-> R3 convergence.
+    expect_loopback_route('r2', 'ip', '10.254.254.3/32', 'bgp')
+
+    # Wait for R3 <-> R2 convergence.
+    expect_loopback_route('r3', 'ip', '10.254.254.2/32', 'bgp')
+
+    # Wait for R3 <-> R4 convergence.
+    expect_loopback_route('r3', 'ipv6', '2001:db8:3::/64', 'isis')
+
+    # Wait for R4 <-> R3 convergence.
+    expect_loopback_route('r4', 'ipv6', '2001:db8:1::/64', 'isis')
+
+    # Wait for R4 <-> R5 convergence.
+    expect_loopback_route('r4', 'ipv6', '2001:db8:3::/64', 'ospf6')
+
+    # Wait for R5 <-> R4 convergence.
+    expect_loopback_route('r5', 'ipv6', '2001:db8:2::/64', 'ospf6')
+
+
+def test_bfd_profile_values():
+    "Assert that the BFD peers can find themselves."
+    tgen = get_topogen()
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    logger.info("waiting for bfd peers to go up and checking profile values")
+
+    for router in tgen.routers().values():
+        json_file = "{}/{}/bfd-peers-initial.json".format(CWD, router.name)
+        expected = json.loads(open(json_file).read())
+        test_func = partial(
+            topotest.router_json_cmp, router, "show bfd peers json", expected
+        )
+        _, result = topotest.run_and_expect(test_func, None, count=12, wait=0.5)
+        assertmsg = '"{}" JSON output mismatches'.format(router.name)
+        assert result is None, assertmsg
+
+
+def test_memory_leak():
+    "Run the memory leak test and report results."
+    tgen = get_topogen()
+    if not tgen.is_memleak_enabled():
+        pytest.skip("Memory leak test/report is disabled")
+
+    tgen.report_memory_leaks()
+
+
+if __name__ == "__main__":
+    args = ["-s"] + sys.argv[1:]
+    sys.exit(pytest.main(args))