|
10 | 10 | from tests.common.fixtures.ptfhost_utils import remove_ip_addresses # noqa F401
|
11 | 11 | from tests.common.helpers.generators import generate_ip_through_default_route
|
12 | 12 | 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 |
14 | 14 | from tests.common.utilities import wait_tcp_connection
|
15 | 15 | from bgp_helpers import BGPMON_TEMPLATE_FILE, BGPMON_CONFIG_FILE, BGP_MONITOR_NAME, BGP_MONITOR_PORT
|
16 | 16 | pytestmark = [
|
|
19 | 19 |
|
20 | 20 | BGP_PORT = 179
|
21 | 21 | BGP_CONNECT_TIMEOUT = 121
|
| 22 | +MAX_TIME_FOR_BGPMON = 180 |
22 | 23 | ZERO_ADDR = r'0.0.0.0/0'
|
23 | 24 | logger = logging.getLogger(__name__)
|
24 | 25 |
|
25 | 26 |
|
| 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 | + |
26 | 39 | def get_default_route_ports(host, tbinfo):
|
27 | 40 | mg_facts = host.get_extended_minigraph_facts(tbinfo)
|
28 | 41 | 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):
|
130 | 143 |
|
131 | 144 |
|
132 | 145 | 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): |
134 | 147 | """
|
135 | 148 | Add a bgp monitor on ptf and verify that DUT is attempting to establish connection to it
|
136 | 149 | """
|
@@ -176,7 +189,7 @@ def bgpmon_peer_connected(duthost, bgpmon_peer):
|
176 | 189 | try:
|
177 | 190 | pytest_assert(wait_tcp_connection(localhost, ptfhost.mgmt_ip, BGP_MONITOR_PORT, timeout_s=60),
|
178 | 191 | "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), |
180 | 193 | "BGPMon Peer connection not established")
|
181 | 194 | finally:
|
182 | 195 | ptfhost.exabgp(name=BGP_MONITOR_NAME, state="absent")
|
|
0 commit comments