]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: Check if pfxSnt is adjusted when default-originate is used for BGP
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Wed, 14 Jul 2021 21:10:38 +0000 (00:10 +0300)
committermergify-bot <noreply@mergify.io>
Fri, 23 Jul 2021 09:18:45 +0000 (09:18 +0000)
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
(cherry picked from commit 5fa869fcc7263cedb353341b83e00dd0e4221f46)

tests/topotests/bgp_default_route/r2/bgpd.conf
tests/topotests/bgp_default_route/test_bgp_default-originate.py

index 00c96cc58b2c16d80859d8ca60a715da5e7ca8fb..6d1080c11933d09829858274c955cf41e954032c 100644 (file)
@@ -2,7 +2,4 @@ router bgp 65001
   no bgp ebgp-requires-policy
   neighbor 192.168.255.1 remote-as 65000
   neighbor 192.168.255.1 timers 3 10
-  address-family ipv4 unicast
-    redistribute connected
-  exit-address-family
 !
index d8de0f0ac64e74fdc0810eac4883d625bad9e0b1..19632162b4922d0df9e167351bbc6efe87edd374 100644 (file)
@@ -79,10 +79,10 @@ def test_bgp_default_originate_route_map():
     if tgen.routers_have_failure():
         pytest.skip(tgen.errors)
 
-    router = tgen.gears["r2"]
-
-    def _bgp_converge(router):
-        output = json.loads(router.vtysh_cmd("show ip bgp neighbor 192.168.255.1 json"))
+    def _bgp_check_if_received():
+        output = json.loads(
+            tgen.gears["r2"].vtysh_cmd("show ip bgp neighbor 192.168.255.1 json")
+        )
         expected = {
             "192.168.255.1": {
                 "bgpState": "Established",
@@ -91,22 +91,27 @@ def test_bgp_default_originate_route_map():
         }
         return topotest.json_cmp(output, expected)
 
+    def _bgp_check_if_originated():
+        output = json.loads(tgen.gears["r1"].vtysh_cmd("show ip bgp summary json"))
+        expected = {"ipv4Unicast": {"peers": {"192.168.255.2": {"pfxSnt": 1}}}}
+        return topotest.json_cmp(output, expected)
+
     def _bgp_default_route_is_valid(router):
         output = json.loads(router.vtysh_cmd("show ip bgp 0.0.0.0/0 json"))
         expected = {"paths": [{"valid": True}]}
         return topotest.json_cmp(output, expected)
 
-    test_func = functools.partial(_bgp_converge, router)
+    test_func = functools.partial(_bgp_check_if_received)
     success, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+    assert result is None, "No 0.0.0.0/0 at r2 from r1"
 
-    assert result is None, 'Failed to see bgp convergence in "{}"'.format(router)
-
-    test_func = functools.partial(_bgp_default_route_is_valid, router)
+    test_func = functools.partial(_bgp_check_if_originated)
     success, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+    assert result is None, "No 0.0.0.0/0 from r1 to r2"
 
-    assert (
-        result is None
-    ), 'Failed to see applied metric for default route in "{}"'.format(router)
+    test_func = functools.partial(_bgp_default_route_is_valid, tgen.gears["r2"])
+    success, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+    assert result is None, "Failed to see 0.0.0.0/0 in r2"
 
 
 if __name__ == "__main__":