Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[T2-Chassis] - New tests for Reliable-TSA feature #13290

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
62 changes: 61 additions & 1 deletion tests/bgp/bgp_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
import ipaddr as ipaddress
from tests.common.helpers.assertions import pytest_require
from tests.common.helpers.assertions import pytest_assert
from tests.common.helpers.constants import UPSTREAM_NEIGHBOR_MAP, DOWNSTREAM_NEIGHBOR_MAP, DEFAULT_NAMESPACE
from tests.common.helpers.constants import UPSTREAM_NEIGHBOR_MAP, DOWNSTREAM_NEIGHBOR_MAP, DEFAULT_NAMESPACE, \
DEFAULT_ASIC_ID
from tests.common.helpers.parallel import reset_ansible_local_tmp
from tests.common.helpers.parallel import parallel_run
from tests.common.utilities import wait_until
from tests.bgp.traffic_checker import get_traffic_shift_state
from tests.bgp.constants import TS_NORMAL

BASE_DIR = os.path.dirname(os.path.realpath(__file__))
DUT_TMP_DIR = os.path.join('tmp', os.path.basename(BASE_DIR))
Expand Down Expand Up @@ -845,3 +848,60 @@ def fetch_and_delete_pcap_file(bgp_pcap, log_dir, duthost, request):
duthost.fetch(src=bgp_pcap, dest=local_pcap_filename, flat=True)
duthost.file(path=bgp_pcap, state="absent")
return local_pcap_filename


def get_tsa_chassisdb_config(duthost):
"""
@summary: Returns the dut's CHASSIS_APP_DB value for BGP_DEVICE_GLOBAL.STATE.tsa_enabled flag
"""
tsa_conf = duthost.shell('sonic-db-cli CHASSIS_APP_DB HGET \'BGP_DEVICE_GLOBAL|STATE\' tsa_enabled')['stdout']
return tsa_conf


def get_sup_cfggen_tsa_value(suphost):
"""
@summary: Returns the supervisor sonic-cfggen value for BGP_DEVICE_GLOBAL.STATE.tsa_enabled flag
"""
tsa_conf = suphost.shell('sonic-cfggen -d -v BGP_DEVICE_GLOBAL.STATE.tsa_enabled')['stdout']
return tsa_conf


def verify_dut_configdb_tsa_value(duthost):
"""
@summary: Returns the line cards' asic CONFIG_DB value for BGP_DEVICE_GLOBAL.STATE.tsa_enabled flag
"""
tsa_config = list()
tsa_enabled = 'false'
for asic_index in duthost.get_frontend_asic_ids():
prefix = "-n asic{}".format(asic_index) if asic_index != DEFAULT_ASIC_ID else ''
output = duthost.shell('sonic-db-cli {} CONFIG_DB HGET \'BGP_DEVICE_GLOBAL|STATE\' \'tsa_enabled\''.
format(prefix))['stdout']
tsa_config.append(output)
if 'true' in tsa_config:
tsa_enabled = 'true'

return tsa_enabled


def initial_tsa_check_before_and_after_test(duthosts):
"""
@summary: Common method to make sure the supervisor and line cards are in normal state before and after the test
"""
for duthost in duthosts:
if duthost.is_supervisor_node():
# Initially make sure both supervisor and line cards are in BGP operational normal state
if get_tsa_chassisdb_config(duthost) != 'false' or get_sup_cfggen_tsa_value(duthost) != 'false':
duthost.shell('TSB')
duthost.shell('sudo config save -y')
pytest_assert('false' == get_tsa_chassisdb_config(duthost),
"Supervisor {} tsa_enabled config is enabled".format(duthost.hostname))

for linecard in duthosts.frontend_nodes:
# Issue TSB on the line card before proceeding further
if verify_dut_configdb_tsa_value(linecard) != 'false' or get_tsa_chassisdb_config(linecard) != 'false' or \
get_traffic_shift_state(linecard, cmd='TSC no-stats') != TS_NORMAL:
linecard.shell('TSB')
linecard.shell('sudo config save -y')
# Ensure that the DUT is not in maintenance already before start of the test
pytest_assert(TS_NORMAL == get_traffic_shift_state(linecard, cmd='TSC no-stats'),
"DUT is not in normal state")
2 changes: 1 addition & 1 deletion tests/bgp/route_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import ipaddr as ipaddress
import re
import json
from bgp_helpers import parse_rib
from tests.bgp.bgp_helpers import parse_rib
from tests.common.devices.eos import EosHost
from tests.common.helpers.assertions import pytest_assert
from tests.common.helpers.parallel import parallel_run
Expand Down
Loading
Loading