Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/common/fixtures/advanced_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,24 @@ def __buildTestbedData(self, tbinfo):
self.rebootData['lo_v6_prefix'] = str(ipaddress.ip_interface(intf['addr'] + '/64').network)
break

def __checkBgpRouterId(self, error_list):
"""
Check bgp router ID is same as Loopback0
"""
check_bgp_router_id_cmd = r'vtysh -c "show ip bgp summary json"'
bgp_summary = self.duthost.shell(check_bgp_router_id_cmd, module_ignore_errors=True)
bgp_summary_json = json.loads(bgp_summary['stdout'])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible exception here if stdout is not in json format for some reason.

router_id = str(bgp_summary_json['ipv4Unicast']['routerId'])
loopback0 = str(self.mgFacts['minigraph_lo_interfaces'][0]['addr'])
if router_id == loopback0:
logger.info("BGP router identifier: %s == Loopback0 address %s" % (router_id, loopback0))
return True
else:
logger.info("BGP router identifier %s != Loopback0 address %s" % (router_id, loopback0))
error_list.append("Failed to verify BGP router identifier is Loopback0 address on %s" %
self.duthost.hostname)
return False

def __updateNextHopIps(self):
"""
Update next hop IPs
Expand Down Expand Up @@ -553,6 +571,7 @@ def runRebootTest(self):
try:
if self.preboot_setup:
self.preboot_setup()
self.__checkBgpRouterId(test_results[test_case_name])
if self.advanceboot_loganalyzer:
pre_reboot_analysis, post_reboot_analysis = self.advanceboot_loganalyzer
marker = pre_reboot_analysis()
Expand Down
21 changes: 20 additions & 1 deletion tests/common/plugins/sanity_check/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def _check_interfaces_on_dut(*args, **kwargs):


@pytest.fixture(scope="module")
def check_bgp(duthosts):
def check_bgp(duthosts, tbinfo):
init_result = {"failed": False, "check_item": "bgp"}

def _check(*args, **kwargs):
Expand Down Expand Up @@ -206,6 +206,21 @@ def _check_bgp_status_helper():
check_result['failed'] = False
return not check_result['failed']

def _check_bgp_router_id(tbinfo):
duthost = kwargs['node']
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there is duplication of whole logic here. So can we put this into commons and import at both the places?

mgFacts = duthost.get_extended_minigraph_facts(tbinfo)
check_bgp_router_id_cmd = r'vtysh -c "show ip bgp summary json"'
bgp_summary = duthost.shell(check_bgp_router_id_cmd, module_ignore_errors=True)
bgp_summary_json = json.loads(bgp_summary['stdout'])
router_id = str(bgp_summary_json['ipv4Unicast']['routerId'])
loopback0 = str(mgFacts['minigraph_lo_interfaces'][0]['addr'])
if router_id == loopback0:
logger.info("BGP router identifier: %s == Loopback0 address %s" % (router_id, loopback0))
return True
else:
logger.info("BGP router identifier %s != Loopback0 address %s" % (router_id, loopback0))
return False

logger.info("Checking bgp status on host %s ..." % dut.hostname)
check_result = {"failed": False, "check_item": "bgp", "host": dut.hostname}

Expand All @@ -230,6 +245,10 @@ def _check_bgp_status_helper():
else:
logger.info('No BGP neighbors are down on %s' % dut.hostname)

if not wait_until(timeout, interval, 0, _check_bgp_router_id, tbinfo):
check_result['failed'] = True
logger.info("Failed to verify BGP router identifier is Loopback0 address on %s" % dut.hostname)

logger.info("Done checking bgp status on %s" % dut.hostname)
results[dut.hostname] = check_result

Expand Down