Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

@wangxin wangxin Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like a new dependency is introduced here: https://pypi.org/project/retry/
Is there a way to avoid this dependency?
If not, can you update the sonic-mgmt Dockerfile in the sonic-buildimage repo to include installation of this retry package?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't notice that it has been added to the sonic-mgmt image in PR sonic-net/sonic-buildimage#7997. LGTM then.


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