summaryrefslogtreecommitdiffstats
path: root/tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py')
-rw-r--r--tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py34
1 files changed, 18 insertions, 16 deletions
diff --git a/tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py b/tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py
index bfc083b..1e6e731 100644
--- a/tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py
+++ b/tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py
@@ -120,13 +120,9 @@ def exabgp_get_update_prefix(filename, afi, nexthop, prefix):
ret = ret.get(afi)
if ret is None:
continue
- ret = ret.get(nexthop)
- if ret is None:
- continue
- ret = ret.get(prefix)
- if ret is None:
- continue
- return output
+ for nh in ret.get(nexthop, []):
+ if nh.get("nlri") == prefix:
+ return output
return "Not found"
@@ -135,33 +131,39 @@ def test_peer2_receive_prefix_sid_type1():
peer2 = tgen.gears["peer2"]
logfile = "{}/{}-received.log".format(peer2.gearlogdir, peer2.name)
- def _check_type1_peer2(prefix, labelindex):
+ def _check_type1_peer2(prefix, label):
output = exabgp_get_update_prefix(
logfile, "ipv4 nlri-mpls", "10.0.0.101", prefix
)
expected = {
"type": "update",
"neighbor": {
- "ip": "10.0.0.1",
+ "address": {
+ "peer": "10.0.0.1",
+ },
"message": {
"update": {
- "attribute": {
- "attribute-0x28-0xE0": "0x010007000000{:08x}".format(
- labelindex
- )
+ "announce": {
+ "ipv4 nlri-mpls": {
+ "10.0.0.101": [
+ {
+ "nlri": prefix,
+ "label": [[label]],
+ }
+ ]
+ }
},
- "announce": {"ipv4 nlri-mpls": {"10.0.0.101": {}}},
}
},
},
}
return topotest.json_cmp(output, expected)
- test_func = functools.partial(_check_type1_peer2, "3.0.0.1/32", labelindex=1)
+ test_func = functools.partial(_check_type1_peer2, "3.0.0.1/32", label=8001)
success, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
assert result is None, 'Failed _check_type1_peer2 in "{}"'.format("peer2")
- test_func = functools.partial(_check_type1_peer2, "3.0.0.2/32", labelindex=2)
+ test_func = functools.partial(_check_type1_peer2, "3.0.0.2/32", label=8002)
success, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
assert result is None, 'Failed _check_type1_peer2 in "{}"'.format("peer2")