]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: add bgp rpki topo1 rpkiValidationState 17728/head
authorDmytro Shytyi <dmytro.shytyi@6wind.com>
Thu, 26 Dec 2024 13:22:41 +0000 (14:22 +0100)
committerDmytro Shytyi <dmytro.shytyi@6wind.com>
Mon, 30 Dec 2024 08:45:26 +0000 (09:45 +0100)
Topotest to verify the next key-value "rpkiValidationState": "valid"

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
tests/topotests/bgp_rpki_topo1/r2/bgp_rpki_valid.json [new file with mode: 0644]
tests/topotests/bgp_rpki_topo1/test_bgp_rpki_topo1.py

diff --git a/tests/topotests/bgp_rpki_topo1/r2/bgp_rpki_valid.json b/tests/topotests/bgp_rpki_topo1/r2/bgp_rpki_valid.json
new file mode 100644 (file)
index 0000000..016c019
--- /dev/null
@@ -0,0 +1,70 @@
+{
+    "vrfId": 0,
+    "vrfName": "default",
+    "tableVersion": 3,
+    "routerId": "192.0.2.2",
+    "defaultLocPrf": 100,
+    "localAS": 65002,
+    "routes": {
+        "198.51.100.0/24": [
+            {
+                "origin": "IGP",
+                "metric": 0,
+                "valid": true,
+                "version": 2,
+                "rpkiValidationState": "valid",
+                "bestpath": {
+                    "overall": true,
+                    "selectionReason": "First path received"
+                },
+                "nexthops": [
+                    {
+                        "ip": "192.0.2.1",
+                        "hostname": "r1",
+                        "afi": "ipv4",
+                        "metric": 0,
+                        "accessible": true,
+                        "used": true
+                    }
+                ],
+                "peer": {
+                    "peerId": "192.0.2.1",
+                    "routerId": "192.0.2.1",
+                    "hostname": "r1",
+                    "type": "external"
+                }
+            }
+        ],
+        "203.0.113.0/24": [
+            {
+                "origin": "IGP",
+                "metric": 0,
+                "valid": true,
+                "version": 3,
+                "rpkiValidationState": "valid",
+                "bestpath": {
+                    "overall": true,
+                    "selectionReason": "First path received"
+                },
+                "nexthops": [
+                    {
+                        "ip": "192.0.2.1",
+                        "hostname": "r1",
+                        "afi": "ipv4",
+                        "metric": 0,
+                        "accessible": true,
+                        "used": true
+                    }
+                ],
+                "peer": {
+                    "peerId": "192.0.2.1",
+                    "routerId": "192.0.2.1",
+                    "hostname": "r1",
+                    "type": "external"
+                }
+            }
+        ]
+    },
+    "totalRoutes": 3,
+    "totalPaths": 3
+}
\ No newline at end of file
index 7b40bbdae82d62883f707a96aad56924a28bf926..5b775aa6cbf05322dfa68f279028740070467632 100644 (file)
@@ -101,6 +101,16 @@ def show_rpki_prefixes(rname, expected, vrf=None):
     return topotest.json_cmp(output, expected)
 
 
+def show_rpki_valid(rname, expected, vrf=None):
+    tgen = get_topogen()
+
+    cmd = "show bgp ipv4 detail json"
+
+    output = json.loads(tgen.gears[rname].vtysh_cmd(cmd))
+
+    return topotest.json_cmp(output, expected)
+
+
 def show_bgp_ipv4_table_rpki(rname, rpki_state, expected, vrf=None):
     tgen = get_topogen()
 
@@ -123,6 +133,25 @@ def show_bgp_ipv4_table_rpki(rname, rpki_state, expected, vrf=None):
     return topotest.json_cmp(output, expected)
 
 
+def test_show_bgp_rpki_prefixes_valid():
+    tgen = get_topogen()
+
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    for rname in ["r1", "r3"]:
+        logger.info("{}: checking if rtrd is running".format(rname))
+        if rtrd_process[rname].poll() is not None:
+            pytest.skip(tgen.errors)
+
+    rname = "r2"
+    expected = open(os.path.join(CWD, "{}/bgp_rpki_valid.json".format(rname))).read()
+    expected_json = json.loads(expected)
+    test_func = functools.partial(show_rpki_valid, rname, expected_json)
+    _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+    assert result is None, "Failed to see RPKI on {}".format(rname)
+
+
 def test_show_bgp_rpki_prefixes():
     tgen = get_topogen()