From 0cb2c9e39e6f507ae92856ee9e6453ecf49a1352 Mon Sep 17 00:00:00 2001 From: sanrajen Date: Mon, 18 Nov 2024 16:32:06 -0500 Subject: [PATCH] tsa-tsb: Add timer check before checking service status --- tests/bgp/test_startup_tsa_tsb_service.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/bgp/test_startup_tsa_tsb_service.py b/tests/bgp/test_startup_tsa_tsb_service.py index 4170fdb766a..5432b0d042f 100644 --- a/tests/bgp/test_startup_tsa_tsb_service.py +++ b/tests/bgp/test_startup_tsa_tsb_service.py @@ -130,6 +130,15 @@ def check_tsc_command_error(duthost): return False +def check_tsa_tsb_service_run_time_diff(service_uptime, configured_service_timer): + """ + @summary: Determine time difference between service runtime and configured value + """ + current_time = datetime.datetime.now() + actual_service_timer = (current_time - service_uptime).total_seconds() + return int(actual_service_timer) < configured_service_timer + + def nbrhosts_to_dut(duthost, nbrhosts): """ @summary: Fetch the neighbor hosts' details for duthost @@ -1102,7 +1111,8 @@ def test_user_init_tsb_on_sup_while_service_run_on_dut(duthosts, localhost, suphost.shell('TSB') for linecard in duthosts.frontend_nodes: - if get_tsa_tsb_service_status(linecard, 'running'): + if get_tsa_tsb_service_status(linecard, 'running') and \ + check_tsa_tsb_service_run_time_diff(service_uptime, tsa_tsb_timer[linecard]): # Verify DUT continues to be in maintenance state if the timer is running. pytest_assert(TS_MAINTENANCE == get_traffic_shift_state(linecard, cmd='TSC no-stats'), "DUT is not in maintenance state when startup_tsa_tsb service is running")