Skip to content

Commit 734fda3

Browse files
authored
add retry_call to test_platform_info mock check (#3684)
1 parent 6f62ca0 commit 734fda3

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

tests/platform_tests/test_platform_info.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import json
88
import logging
99
import time
10+
from retry.api import retry_call
1011

1112
import pytest
1213

@@ -271,9 +272,9 @@ def test_show_platform_fanstatus_mocked(duthosts, enum_rand_one_per_hwsku_hostna
271272
logging.info('Mock FAN status data...')
272273
mocker.mock_data()
273274
logging.info('Wait and check actual data with mocked FAN status data...')
274-
result = check_cli_output_with_mocker(duthost, mocker, CMD_PLATFORM_FANSTATUS, THERMAL_CONTROL_TEST_WAIT_TIME, 2)
275+
retry_call(check_cli_output_with_mocker, fargs=[duthost, mocker, CMD_PLATFORM_FANSTATUS, THERMAL_CONTROL_TEST_WAIT_TIME, 2], tries=3, delay=30)
276+
275277

276-
pytest_assert(result, 'FAN mock data mismatch')
277278

278279

279280
@pytest.mark.disable_loganalyzer
@@ -290,9 +291,7 @@ def test_show_platform_temperature_mocked(duthosts, enum_rand_one_per_hwsku_host
290291
logging.info('Mock Thermal status data...')
291292
mocker.mock_data()
292293
logging.info('Wait and check actual data with mocked Thermal status data...')
293-
result = check_cli_output_with_mocker(duthost, mocker, CMD_PLATFORM_TEMPER, THERMAL_CONTROL_TEST_WAIT_TIME)
294-
295-
pytest_assert(result, 'Thermal mock data mismatch')
294+
retry_call(check_cli_output_with_mocker, fargs=[duthost, mocker, CMD_PLATFORM_TEMPER, THERMAL_CONTROL_TEST_WAIT_TIME], tries=3, delay=30)
296295

297296

298297
@pytest.mark.disable_loganalyzer

tests/platform_tests/thermal_control_test_helper.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66

77
from tests.common.utilities import wait_until
8+
from tests.common.helpers.assertions import pytest_assert
89
from tests.common.config_reload import config_reload
910
from tests.common.reboot import reboot
1011

@@ -229,9 +230,10 @@ def check_cli_output_with_mocker(dut, mocker_object, command, max_wait_time, key
229230
"""
230231
time.sleep(max_wait_time)
231232

232-
result = dut.show_and_parse(command)
233-
assert len(result) > 0, "Run and parse output of command '{}' failed".format(command)
234-
return mocker_object.check_result(result)
233+
parsed_output = dut.show_and_parse(command)
234+
assert len(parsed_output) > 0, "Run and parse output of command '{}' failed".format(command)
235+
result = mocker_object.check_result(parsed_output)
236+
pytest_assert(result, 'mock data and command \"{}\" output are mismatched'.format(command))
235237

236238

237239
def check_thermal_algorithm_status(dut, mocker_factory, expected_status):

0 commit comments

Comments
 (0)