Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions tests/common/fixtures/advanced_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from tests.common.utilities import InterruptableThread
from tests.common.dualtor.data_plane_utils import get_peerhost
from tests.common.dualtor.dual_tor_utils import show_muxcable_status
from tests.common.fixtures.duthost_utils import check_bgp_router_id

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -524,6 +525,9 @@ def runRebootTest(self):
try:
if self.preboot_setup:
self.preboot_setup()
if self.duthost.num_asics() == 1 and not check_bgp_router_id(self.duthost, self.mgFacts):
test_results[test_case_name].append("Failed to verify BGP router identifier is Loopback0 on %s" %
self.duthost.hostname)
if self.advanceboot_loganalyzer:
pre_reboot_analysis, post_reboot_analysis = self.advanceboot_loganalyzer
marker = pre_reboot_analysis()
Expand Down
20 changes: 20 additions & 0 deletions tests/common/fixtures/duthost_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,3 +562,23 @@ def load_dscp_to_queue_map(duthost, port, dut_qos_maps_module):
except:
logger.error("Failed to retrieve dscp to queue map for port {} on {}".format(port, duthost.hostname))
return {}


def check_bgp_router_id(duthost, mgFacts):
"""
Check bgp router ID is same as Loopback0
"""
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)
try:
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
except Exception as e:
logger.error("Error loading BGP routerID - {}".format(e))
8 changes: 7 additions & 1 deletion tests/common/plugins/sanity_check/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from tests.common.plugins.sanity_check.constants import STAGE_PRE_TEST, STAGE_POST_TEST
from tests.common.helpers.parallel import parallel_run, reset_ansible_local_tmp
from tests.common.dualtor.mux_simulator_control import _probe_mux_ports
from tests.common.fixtures.duthost_utils import check_bgp_router_id

logger = logging.getLogger(__name__)
SYSTEM_STABILIZE_MAX_TIME = 300
Expand Down Expand Up @@ -144,7 +145,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):
result = parallel_run(_check_bgp_on_dut, args, kwargs, duthosts.frontend_nodes, timeout=600, init_result=init_result)
Expand Down Expand Up @@ -226,6 +227,11 @@ def _check_bgp_status_helper():
else:
logger.info('No BGP neighbors are down on %s' % dut.hostname)

mgFacts = dut.get_extended_minigraph_facts(tbinfo)
if dut.num_asics() == 1 and not wait_until(timeout, interval, 0, check_bgp_router_id, dut, mgFacts):
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