--- /dev/null
+{
+ "loc-rib": {
+ "update": {
+ "172.31.0.77/32": {
+ "as_path": "",
+ "bgp_nexthop": "192.168.1.3",
+ "bmp_log_type": "update",
+ "ip_prefix": "172.31.0.77/32",
+ "is_filtered": false,
+ "origin": "IGP",
+ "peer_asn": 65501,
+ "peer_bgp_id": "192.168.0.1",
+ "peer_distinguisher": "666:22",
+ "peer_type": "loc-rib instance",
+ "policy": "loc-rib"
+ },
+ "2001::1125/128": {
+ "afi": 2,
+ "as_path": "",
+ "bmp_log_type": "update",
+ "ip_prefix": "2001::1125/128",
+ "is_filtered": false,
+ "nxhp_ip": "192:167::3",
+ "origin": "IGP",
+ "peer_asn": 65501,
+ "peer_bgp_id": "192.168.0.1",
+ "peer_distinguisher": "666:22",
+ "peer_type": "loc-rib instance",
+ "policy": "loc-rib",
+ "safi": 1
+ }
+ }
+ }
+}
--- /dev/null
+{
+ "post-policy": {
+ "update": {
+ "172.31.0.77/32": {
+ "as_path": "",
+ "bgp_nexthop": "192.168.1.3",
+ "bmp_log_type": "update",
+ "ip_prefix": "172.31.0.77/32",
+ "ipv6": false,
+ "origin": "IGP",
+ "peer_asn": 65501,
+ "peer_bgp_id": "192.168.1.3",
+ "peer_distinguisher": "666:22",
+ "peer_ip": "192.168.1.3",
+ "peer_type": "route distinguisher instance",
+ "policy": "post-policy"
+ },
+ "2001::1125/128": {
+ "afi": 2,
+ "as_path": "",
+ "bmp_log_type": "update",
+ "ip_prefix": "2001::1125/128",
+ "ipv6": true,
+ "nxhp_ip": "192:167::3",
+ "origin": "IGP",
+ "peer_asn": 65501,
+ "peer_bgp_id": "192.168.1.3",
+ "peer_distinguisher": "666:22",
+ "peer_ip": "192:167::3",
+ "peer_type": "route distinguisher instance",
+ "policy": "post-policy",
+ "safi": 1
+ }
+ }
+ }
+}
--- /dev/null
+{
+ "pre-policy": {
+ "update": {
+ "172.31.0.77/32": {
+ "as_path": "",
+ "bgp_nexthop": "192.168.1.3",
+ "bmp_log_type": "update",
+ "ip_prefix": "172.31.0.77/32",
+ "ipv6": false,
+ "origin": "IGP",
+ "peer_asn": 65501,
+ "peer_bgp_id": "192.168.1.3",
+ "peer_distinguisher": "666:22",
+ "peer_ip": "192.168.1.3",
+ "peer_type": "route distinguisher instance",
+ "policy": "pre-policy"
+ },
+ "2001::1125/128": {
+ "afi": 2,
+ "as_path": "",
+ "bmp_log_type": "update",
+ "ip_prefix": "2001::1125/128",
+ "ipv6": true,
+ "nxhp_ip": "192:167::3",
+ "origin": "IGP",
+ "peer_asn": 65501,
+ "peer_bgp_id": "192.168.1.3",
+ "peer_distinguisher": "666:22",
+ "peer_ip": "192:167::3",
+ "peer_type": "route distinguisher instance",
+ "policy": "pre-policy",
+ "safi": 1
+ }
+ }
+ }
+}
+++ /dev/null
-{
- "post-policy": {
- "withdraw": {
- "2001::1111/128": {
- "afi": 2,
- "bmp_log_type": "withdraw",
- "ip_prefix": "2001::1111/128",
- "ipv6": true,
- "label": 0,
- "peer_asn": 65502,
- "peer_bgp_id": "192.168.0.2",
- "peer_distinguisher": "0:0",
- "peer_ip": "192:168::2",
- "peer_type": "global instance",
- "policy": "post-policy",
- "rd": "555:2",
- "safi": 128
- },
- "172.31.0.15/32": {
- "afi": 1,
- "bmp_log_type": "withdraw",
- "ip_prefix": "172.31.0.15/32",
- "ipv6": false,
- "label": 0,
- "peer_asn": 65502,
- "peer_bgp_id": "192.168.0.2",
- "peer_distinguisher": "0:0",
- "peer_ip": "192.168.0.2",
- "peer_type": "global instance",
- "policy": "post-policy",
- "rd": "444:2",
- "safi": 128
- }
- }
- }
-}
assert result is True, "BGP is not converging"
+def _test_prefixes_syncro(policy, vrf=None, step=1):
+ """
+ Check that the given policy has syncronised the previously received BGP
+ updates.
+ """
+ tgen = get_topogen()
+
+ prefixes = ["172.31.0.77/32", "2001::1125/128"]
+ # check
+ test_func = partial(
+ bmp_check_for_prefixes,
+ prefixes,
+ "update",
+ policy,
+ step,
+ tgen.gears["bmp1import"],
+ os.path.join(tgen.logdir, "bmp1import"),
+ tgen.gears["r1import"],
+ f"{CWD}/bmp1import",
+ UPDATE_EXPECTED_JSON,
+ LOC_RIB,
+ )
+ success, res = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assert success, "Checking the updated prefixes has failed ! %s" % res
+
+
def _test_prefixes(policy, vrf=None, step=0):
"""
Setup the BMP monitor policy, Add and withdraw ipv4/v6 prefixes.
assert success, "Checking the updated prefixes has been failed !."
+def test_reconfigure_prefixes():
+ """
+ Reconfigured BGP networks from R3. Check for BGP VRF update messages
+ """
+
+ tgen = get_topogen()
+
+ prefixes = ["172.31.0.77/32", "2001::1125/128"]
+ bgp_configure_prefixes(
+ tgen.gears["r3"],
+ 65501,
+ "unicast",
+ prefixes,
+ vrf=None,
+ update=True,
+ )
+
+ for ipver in [4, 6]:
+ ref_file = "{}/r1import/show-bgp-{}-ipv{}-{}-step{}.json".format(
+ CWD, "vrf1", ipver, "update", 1
+ )
+ expected = json.loads(open(ref_file).read())
+
+ test_func = partial(
+ topotest.router_json_cmp,
+ tgen.gears["r1import"],
+ f"show bgp vrf vrf1 ipv{ipver} json",
+ expected,
+ )
+ _, res = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assertmsg = f"r1: BGP IPv{ipver} convergence failed"
+ assert res is None, assertmsg
+
+
+def test_monitor_syncro():
+ """
+ Checking for BMP peers down messages
+ """
+ tgen = get_topogen()
+
+ tgen.gears["r1import"].vtysh_cmd(
+ """
+ configure terminal
+ router bgp 65501
+ bmp targets bmp1
+ bmp import-vrf-view vrf1
+ """
+ )
+
+ logger.info("*** Unicast prefixes pre-policy logging ***")
+ _test_prefixes_syncro(PRE_POLICY, vrf="vrf1")
+ logger.info("*** Unicast prefixes post-policy logging ***")
+ _test_prefixes_syncro(POST_POLICY, vrf="vrf1")
+ logger.info("*** Unicast prefixes loc-rib logging ***")
+ _test_prefixes_syncro(LOC_RIB, vrf="vrf1")
+
+
def test_reconfigure_route_distinguisher_vrf1():
"""
Checking for BMP peers down messages
"""
)
logger.info(
- "checking for BMP peer down LOC-RIB message with route-distinguisher set to 444:1"
+ "Checking for BMP peer down LOC-RIB message with route-distinguisher set to 444:1"
)
test_func = partial(
bmp_check_for_peer_message,
), "Checking the BMP peer down LOC-RIB message with route-distinguisher set to 444:1 failed !."
logger.info(
- "checking for BMP peer up LOC-RIB messages with route-distinguisher set to 666:22"
+ "Checking for BMP peer up LOC-RIB messages with route-distinguisher set to 666:22"
)
test_func = partial(
bmp_check_for_peer_message,
), "Checking the BMP peer up LOC-RIB message with route-distinguisher set to 666:22 failed !."
logger.info(
- "checking for BMP peer up messages with route-distinguisher set to 666:22"
+ "Checking for BMP peer up messages with route-distinguisher set to 666:22"
)
peers = ["192.168.1.3", "192:167::3"]
test_func = partial(
success
), "Checking the BMP peer up messages with route-distinguisher set to 666:22 failed !."
+ logger.info("*** Unicast prefixes pre-policy logging ***")
+ _test_prefixes_syncro(PRE_POLICY, vrf="vrf1", step=2)
+ logger.info("*** Unicast prefixes post-policy logging ***")
+ _test_prefixes_syncro(POST_POLICY, vrf="vrf1", step=2)
+ logger.info("*** Unicast prefixes loc-rib logging ***")
+ _test_prefixes_syncro(LOC_RIB, vrf="vrf1", step=2)
+
def test_bgp_routerid_changed():
"""