Skip to content

Commit

Permalink
add retry_call to test_platform_info mock check (sonic-net#3684)
Browse files Browse the repository at this point in the history
  • Loading branch information
slutati1536 authored and vmittal-msft committed Sep 28, 2021
1 parent 8177aaf commit 393640d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 4 additions & 5 deletions tests/platform_tests/test_platform_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import logging
import time
from retry.api import retry_call

import pytest

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


pytest_assert(result, 'FAN mock data mismatch')


@pytest.mark.disable_loganalyzer
Expand All @@ -290,9 +291,7 @@ def test_show_platform_temperature_mocked(duthosts, enum_rand_one_per_hwsku_host
logging.info('Mock Thermal status data...')
mocker.mock_data()
logging.info('Wait and check actual data with mocked Thermal status data...')
result = check_cli_output_with_mocker(duthost, mocker, CMD_PLATFORM_TEMPER, THERMAL_CONTROL_TEST_WAIT_TIME)

pytest_assert(result, 'Thermal mock data mismatch')
retry_call(check_cli_output_with_mocker, fargs=[duthost, mocker, CMD_PLATFORM_TEMPER, THERMAL_CONTROL_TEST_WAIT_TIME], tries=3, delay=30)


@pytest.mark.disable_loganalyzer
Expand Down
8 changes: 5 additions & 3 deletions tests/platform_tests/thermal_control_test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

from tests.common.utilities import wait_until
from tests.common.helpers.assertions import pytest_assert
from tests.common.config_reload import config_reload
from tests.common.reboot import reboot

Expand Down Expand Up @@ -229,9 +230,10 @@ def check_cli_output_with_mocker(dut, mocker_object, command, max_wait_time, key
"""
time.sleep(max_wait_time)

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


def check_thermal_algorithm_status(dut, mocker_factory, expected_status):
Expand Down

0 comments on commit 393640d

Please sign in to comment.