]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bfd-topo1: add fast reconvergence test
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Wed, 6 Jun 2018 21:02:34 +0000 (18:02 -0300)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 28 Nov 2018 01:22:14 +0000 (20:22 -0500)
Test that after a link goes down BGPd will be notified and recovered
quickly. Also test that BFD show command tells us that the peer went
down.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
tests/topotests/bfd-topo1/r1/bgp_prefixes.json [new file with mode: 0644]
tests/topotests/bfd-topo1/r1/bgpd.conf
tests/topotests/bfd-topo1/r2/bgp_prefixes.json [new file with mode: 0644]
tests/topotests/bfd-topo1/r2/bgpd.conf
tests/topotests/bfd-topo1/r3/bgp_prefixes.json [new file with mode: 0644]
tests/topotests/bfd-topo1/r3/bgpd.conf
tests/topotests/bfd-topo1/r4/bgp_prefixes.json [new file with mode: 0644]
tests/topotests/bfd-topo1/r4/bgpd.conf
tests/topotests/bfd-topo1/test_bfd_topo1.py

diff --git a/tests/topotests/bfd-topo1/r1/bgp_prefixes.json b/tests/topotests/bfd-topo1/r1/bgp_prefixes.json
new file mode 100644 (file)
index 0000000..4b2cc1a
--- /dev/null
@@ -0,0 +1,52 @@
+{
+  "routes": {
+    "10.254.254.2/32": [
+      {
+        "aspath": "102",
+        "prefix": "10.254.254.2",
+        "valid": true,
+        "peerId": "192.168.0.2",
+        "prefixLen": 32,
+        "nexthops": [
+          {
+            "ip": "192.168.0.2",
+            "used": true,
+            "afi": "ipv4"
+          }
+        ]
+      }
+    ],
+    "10.254.254.3/32": [
+      {
+        "aspath": "102 103",
+        "prefix": "10.254.254.3",
+        "valid": true,
+        "peerId": "192.168.0.2",
+        "prefixLen": 32,
+        "nexthops": [
+          {
+            "ip": "192.168.0.2",
+            "used": true,
+            "afi": "ipv4"
+          }
+        ]
+      }
+    ],
+    "10.254.254.4/32": [
+      {
+        "aspath": "102 104",
+        "prefix": "10.254.254.4",
+        "valid": true,
+        "peerId": "192.168.0.2",
+        "prefixLen": 32,
+        "nexthops": [
+          {
+            "ip": "192.168.0.2",
+            "used": true,
+            "afi": "ipv4"
+          }
+        ]
+      }
+    ]
+  }
+}
index 9a0166a8762635a3893f7c18079db7807d10b0dc..78a5611844bef154e58abefd4fb0924e92e1722a 100644 (file)
@@ -1,4 +1,7 @@
 router bgp 101
  neighbor 192.168.0.2 remote-as 102
  neighbor 192.168.0.2 bfd
+ address-family ipv4 unicast
+  network 10.254.254.1/32
+ exit-address-family
 !
diff --git a/tests/topotests/bfd-topo1/r2/bgp_prefixes.json b/tests/topotests/bfd-topo1/r2/bgp_prefixes.json
new file mode 100644 (file)
index 0000000..39f3c0a
--- /dev/null
@@ -0,0 +1,52 @@
+{
+  "routes": {
+    "10.254.254.1/32": [
+      {
+        "aspath": "101",
+        "prefix": "10.254.254.1",
+        "valid": true,
+        "peerId": "192.168.0.1",
+        "prefixLen": 32,
+        "nexthops": [
+          {
+            "ip": "192.168.0.1",
+            "used": true,
+            "afi": "ipv4"
+          }
+        ]
+      }
+    ],
+    "10.254.254.3/32": [
+      {
+        "aspath": "103",
+        "prefix": "10.254.254.3",
+        "valid": true,
+        "peerId": "192.168.1.1",
+        "prefixLen": 32,
+        "nexthops": [
+          {
+            "ip": "192.168.1.1",
+            "used": true,
+            "afi": "ipv4"
+          }
+        ]
+      }
+    ],
+    "10.254.254.4/32": [
+      {
+        "aspath": "104",
+        "prefix": "10.254.254.4",
+        "valid": true,
+        "peerId": "192.168.2.1",
+        "prefixLen": 32,
+        "nexthops": [
+          {
+            "ip": "192.168.2.1",
+            "used": true,
+            "afi": "ipv4"
+          }
+        ]
+      }
+    ]
+  }
+}
index 0ad222689136b260b62c5f031a144aa0e556f4e4..af10cfaf401846303e2a588319a7503f0f60520a 100644 (file)
@@ -5,4 +5,7 @@ router bgp 102
  neighbor 192.168.1.1 bfd
  neighbor 192.168.2.1 remote-as 104
  neighbor 192.168.2.1 bfd
+ address-family ipv4 unicast
+  network 10.254.254.2/32
+ exit-address-family
 !
diff --git a/tests/topotests/bfd-topo1/r3/bgp_prefixes.json b/tests/topotests/bfd-topo1/r3/bgp_prefixes.json
new file mode 100644 (file)
index 0000000..c92d4e0
--- /dev/null
@@ -0,0 +1,52 @@
+{
+  "routes": {
+    "10.254.254.1/32": [
+      {
+        "aspath": "102 101",
+        "prefix": "10.254.254.1",
+        "valid": true,
+        "peerId": "192.168.1.2",
+        "prefixLen": 32,
+        "nexthops": [
+          {
+            "ip": "192.168.1.2",
+            "used": true,
+            "afi": "ipv4"
+          }
+        ]
+      }
+    ],
+    "10.254.254.2/32": [
+      {
+        "aspath": "102",
+        "prefix": "10.254.254.2",
+        "valid": true,
+        "peerId": "192.168.1.2",
+        "prefixLen": 32,
+        "nexthops": [
+          {
+            "ip": "192.168.1.2",
+            "used": true,
+            "afi": "ipv4"
+          }
+        ]
+      }
+    ],
+    "10.254.254.4/32": [
+      {
+        "aspath": "102 104",
+        "prefix": "10.254.254.4",
+        "valid": true,
+        "peerId": "192.168.1.2",
+        "prefixLen": 32,
+        "nexthops": [
+          {
+            "ip": "192.168.1.2",
+            "used": true,
+            "afi": "ipv4"
+          }
+        ]
+      }
+    ]
+  }
+}
index e36a2f9930246293b171061b09b613a13fbb39c4..041fd7a75969cd57a73411dcf2c713200b13f085 100644 (file)
@@ -1,4 +1,7 @@
 router bgp 103
  neighbor 192.168.1.2 remote-as 102
  neighbor 192.168.1.2 bfd
+ address-family ipv4 unicast
+  network 10.254.254.3/32
+ exit-address-family
 !
diff --git a/tests/topotests/bfd-topo1/r4/bgp_prefixes.json b/tests/topotests/bfd-topo1/r4/bgp_prefixes.json
new file mode 100644 (file)
index 0000000..cc8510d
--- /dev/null
@@ -0,0 +1,52 @@
+{
+  "routes": {
+    "10.254.254.1/32": [
+      {
+        "aspath": "102 101",
+        "prefix": "10.254.254.1",
+        "valid": true,
+        "peerId": "192.168.2.2",
+        "prefixLen": 32,
+        "nexthops": [
+          {
+            "ip": "192.168.2.2",
+            "used": true,
+            "afi": "ipv4"
+          }
+        ]
+      }
+    ],
+    "10.254.254.2/32": [
+      {
+        "aspath": "102",
+        "prefix": "10.254.254.2",
+        "valid": true,
+        "peerId": "192.168.2.2",
+        "prefixLen": 32,
+        "nexthops": [
+          {
+            "ip": "192.168.2.2",
+            "used": true,
+            "afi": "ipv4"
+          }
+        ]
+      }
+    ],
+    "10.254.254.3/32": [
+      {
+        "aspath": "102 103",
+        "prefix": "10.254.254.3",
+        "valid": true,
+        "peerId": "192.168.2.2",
+        "prefixLen": 32,
+        "nexthops": [
+          {
+            "ip": "192.168.2.2",
+            "used": true,
+            "afi": "ipv4"
+          }
+        ]
+      }
+    ]
+  }
+}
index 5f04fbdd7fbbef1812bc694a4ed0f3e2cca75cb4..9c504699ba7aa4855c4b40a85eaa61fcc88245fc 100644 (file)
@@ -1,4 +1,7 @@
 router bgp 104
  neighbor 192.168.2.2 remote-as 102
  neighbor 192.168.2.2 bfd
+ address-family ipv4 unicast
+  network 10.254.254.4/32
+ exit-address-family
 !
index 6030aff3e314c3edaccaf7b20aef1cd977969039..91904c6aae6e7f1fd65735b424061e51d990f392 100644 (file)
@@ -143,6 +143,96 @@ def test_bgp_convergence():
         assert res is None, assertmsg
 
 
+def test_bgp_fast_convergence():
+    "Assert that BGP is converging before setting a link down."
+    tgen = get_topogen()
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    logger.info('waiting for bgp peers converge')
+
+    for router in tgen.routers().values():
+        ref_file = '{}/{}/bgp_prefixes.json'.format(CWD, router.name)
+        expected = json.loads(open(ref_file).read())
+        test_func = partial(topotest.router_json_cmp,
+                            router, 'show ip bgp json', expected)
+        _, res = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
+        assertmsg = '{}: bgp did not converge'.format(router.name)
+        assert res is None, assertmsg
+
+
+def test_bfd_fast_convergence():
+    """
+    Assert that BFD notices the link down after simulating network
+    failure.
+    """
+    tgen = get_topogen()
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    # Disable r1-eth0 link.
+    tgen.gears['r1'].link_enable('r1-eth0', enabled=False)
+
+    # Wait the minimum time we can before checking that BGP/BFD
+    # converged.
+    logger.info('waiting for BFD converge')
+
+    # Check that BGP converged quickly.
+    for router in tgen.routers().values():
+        json_file = '{}/{}/peers.json'.format(CWD, router.name)
+        expected = json.loads(open(json_file).read())
+
+        # Load the same file as previous test, but expect R1 to be down.
+        if router.name == 'r1':
+            for peer in expected:
+                if peer['peer'] == '192.168.0.2':
+                    peer['status'] = 'down'
+        else:
+            for peer in expected:
+                if peer['peer'] == '192.168.0.1':
+                    peer['status'] = 'down'
+
+        test_func = partial(topotest.router_json_cmp,
+            router, 'show bfd peers json', expected)
+        _, res = topotest.run_and_expect(test_func, None, count=20, wait=0.5)
+        assertmsg = '"{}" JSON output mismatches'.format(router.name)
+        assert res is None, assertmsg
+
+
+def test_bgp_fast_reconvergence():
+    "Assert that BGP is converging after setting a link down."
+    tgen = get_topogen()
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    logger.info('waiting for BGP re convergence')
+
+    # Check that BGP converged quickly.
+    for router in tgen.routers().values():
+        ref_file = '{}/{}/bgp_prefixes.json'.format(CWD, router.name)
+        expected = json.loads(open(ref_file).read())
+
+        # Load the same file as previous test, but set networks to None
+        # to test absence.
+        if router.name == 'r1':
+            expected['routes']['10.254.254.2/32'] = None
+            expected['routes']['10.254.254.3/32'] = None
+            expected['routes']['10.254.254.4/32'] = None
+        else:
+            expected['routes']['10.254.254.1/32'] = None
+
+        test_func = partial(topotest.router_json_cmp,
+                            router, 'show ip bgp json', expected)
+        _, res = topotest.run_and_expect(
+            test_func,
+            None,
+            count=3,
+            wait=1
+        )
+        assertmsg = '{}: bgp did not converge'.format(router.name)
+        assert res is None, assertmsg
+
+
 def test_memory_leak():
     "Run the memory leak test and report results."
     tgen = get_topogen()