Skip to content

Commit cf9e1c1

Browse files
authored
[T2 chassis] Accommodate timeout for bgpMon peer connection to establish base on inventory file (sonic-net#8264)
* Update test_bgpmon.py * import get_plt_reboot_ctrl
1 parent 184fbd5 commit cf9e1c1

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

tests/bgp/test_bgpmon.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from tests.common.fixtures.ptfhost_utils import remove_ip_addresses # noqa F401
1111
from tests.common.helpers.generators import generate_ip_through_default_route
1212
from tests.common.helpers.assertions import pytest_assert
13-
from tests.common.utilities import wait_until
13+
from tests.common.utilities import wait_until, get_plt_reboot_ctrl
1414
from tests.common.utilities import wait_tcp_connection
1515
from bgp_helpers import BGPMON_TEMPLATE_FILE, BGPMON_CONFIG_FILE, BGP_MONITOR_NAME, BGP_MONITOR_PORT
1616
pytestmark = [
@@ -19,10 +19,23 @@
1919

2020
BGP_PORT = 179
2121
BGP_CONNECT_TIMEOUT = 121
22+
MAX_TIME_FOR_BGPMON = 180
2223
ZERO_ADDR = r'0.0.0.0/0'
2324
logger = logging.getLogger(__name__)
2425

2526

27+
@pytest.fixture
28+
def set_timeout_for_bgpmon(duthost):
29+
"""
30+
For chassis testbeds, we need to specify plt_reboot_ctrl in inventory file,
31+
to let MAX_TIME_TO_REBOOT to be overwritten by specified timeout value
32+
"""
33+
global MAX_TIME_FOR_BGPMON
34+
plt_reboot_ctrl = get_plt_reboot_ctrl(duthost, 'test_bgpmon.py', 'cold')
35+
if plt_reboot_ctrl:
36+
MAX_TIME_FOR_BGPMON = plt_reboot_ctrl.get('timeout', 180)
37+
38+
2639
def get_default_route_ports(host, tbinfo):
2740
mg_facts = host.get_extended_minigraph_facts(tbinfo)
2841
route_info = json.loads(host.shell("show ip route {} json".format(ZERO_ADDR))['stdout'])
@@ -130,7 +143,7 @@ def build_syn_pkt(local_addr, peer_addr):
130143

131144

132145
def test_bgpmon(dut_with_default_route, localhost, enum_rand_one_frontend_asic_index,
133-
common_setup_teardown, ptfadapter, ptfhost):
146+
common_setup_teardown, set_timeout_for_bgpmon, ptfadapter, ptfhost):
134147
"""
135148
Add a bgp monitor on ptf and verify that DUT is attempting to establish connection to it
136149
"""
@@ -176,7 +189,7 @@ def bgpmon_peer_connected(duthost, bgpmon_peer):
176189
try:
177190
pytest_assert(wait_tcp_connection(localhost, ptfhost.mgmt_ip, BGP_MONITOR_PORT, timeout_s=60),
178191
"Failed to start bgp monitor session on PTF")
179-
pytest_assert(wait_until(180, 5, 0, bgpmon_peer_connected, duthost, peer_addr),
192+
pytest_assert(wait_until(MAX_TIME_FOR_BGPMON, 5, 0, bgpmon_peer_connected, duthost, peer_addr),
180193
"BGPMon Peer connection not established")
181194
finally:
182195
ptfhost.exabgp(name=BGP_MONITOR_NAME, state="absent")

0 commit comments

Comments
 (0)