Skip to content

Commit

Permalink
Enhanced bgp_fact to validate NEIGH_STATE_TABLE element 'peerType' (#…
Browse files Browse the repository at this point in the history
…8462) (#8572)

Added validation for this change : sonic-net/sonic-buildimage#15265

Cherry-pick of PR: #8462 to 202205 branch.

Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
  • Loading branch information
abdosi authored Jun 14, 2023
1 parent dba1e51 commit 35d409e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/bgp/test_bgp_fact.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def test_bgp_facts(duthosts, enum_frontend_dut_hostname, enum_asic_index):
bgp_facts = duthost.bgp_facts(instance_id=enum_asic_index)['ansible_facts']
namespace = duthost.get_namespace_from_asic_id(enum_asic_index)
config_facts = duthost.config_facts(host=duthost.hostname, source="running",namespace=namespace)['ansible_facts']

sonic_db_cmd = "sonic-db-cli {}".format("-n " + namespace if namespace else "")
for k, v in bgp_facts['bgp_neighbors'].items():
# Verify bgp sessions are established
Expand All @@ -23,7 +22,11 @@ def test_bgp_facts(duthosts, enum_frontend_dut_hostname, enum_asic_index):
assert v['local AS'] == int(config_facts['DEVICE_METADATA']['localhost']['bgp_asn'].encode().decode("utf-8"))
# Check bgpmon functionality by validate STATE DB contains this neighbor as well
state_fact = duthost.shell('{} STATE_DB HGET "NEIGH_STATE_TABLE|{}" "state"'.format(sonic_db_cmd, k), module_ignore_errors=False)['stdout_lines']
peer_type = duthost.shell('{} STATE_DB HGET "NEIGH_STATE_TABLE|{}" "peerType"'
.format(sonic_db_cmd, k),
module_ignore_errors=False)['stdout_lines']
assert state_fact[0] == "Established"
assert peer_type[0] == "i-BGP" if v['remote AS'] == v['local AS'] else "e-BGP"

# In multi-asic, would have 'BGP_INTERNAL_NEIGHBORS' and possibly no 'BGP_NEIGHBOR' (ebgp) neighbors.
nbrs_in_cfg_facts = {}
Expand Down

0 comments on commit 35d409e

Please sign in to comment.