diff --git a/tests/platform_tests/files/invalid_format_policy.json b/tests/common/helpers/files/invalid_format_policy.json similarity index 100% rename from tests/platform_tests/files/invalid_format_policy.json rename to tests/common/helpers/files/invalid_format_policy.json diff --git a/tests/platform_tests/files/invalid_value_policy.json b/tests/common/helpers/files/invalid_value_policy.json similarity index 100% rename from tests/platform_tests/files/invalid_value_policy.json rename to tests/common/helpers/files/invalid_value_policy.json diff --git a/tests/platform_tests/files/valid_policy.json b/tests/common/helpers/files/valid_policy.json similarity index 100% rename from tests/platform_tests/files/valid_policy.json rename to tests/common/helpers/files/valid_policy.json diff --git a/tests/platform_tests/mellanox/mellanox_thermal_control_test_helper.py b/tests/common/helpers/mellanox_thermal_control_test_helper.py similarity index 99% rename from tests/platform_tests/mellanox/mellanox_thermal_control_test_helper.py rename to tests/common/helpers/mellanox_thermal_control_test_helper.py index ff489bcc655..786ce5352c9 100644 --- a/tests/platform_tests/mellanox/mellanox_thermal_control_test_helper.py +++ b/tests/common/helpers/mellanox_thermal_control_test_helper.py @@ -5,10 +5,10 @@ import logging import time from pkg_resources import parse_version -from tests.platform_tests.thermal_control_test_helper import mocker, FanStatusMocker, ThermalStatusMocker, \ +from tests.common.helpers.thermal_control_test_helper import mocker, FanStatusMocker, ThermalStatusMocker, \ SingleFanMocker from tests.common.mellanox_data import get_hw_management_version, get_platform_data -from .minimum_table import get_min_table +from tests.common.helpers.minimum_table import get_min_table from tests.common.utilities import wait_until from tests.common.helpers.assertions import pytest_assert diff --git a/tests/platform_tests/mellanox/minimum_table.py b/tests/common/helpers/minimum_table.py similarity index 100% rename from tests/platform_tests/mellanox/minimum_table.py rename to tests/common/helpers/minimum_table.py diff --git a/tests/platform_tests/thermal_control_test_helper.py b/tests/common/helpers/thermal_control_test_helper.py similarity index 99% rename from tests/platform_tests/thermal_control_test_helper.py rename to tests/common/helpers/thermal_control_test_helper.py index fb9e4feb4ca..9f1dab9e214 100644 --- a/tests/platform_tests/thermal_control_test_helper.py +++ b/tests/common/helpers/thermal_control_test_helper.py @@ -114,7 +114,6 @@ def _create_mocker(dut, mocker_name): mocker_object = None if 'mlnx' in platform or 'nvidia' in platform: - from tests.platform_tests.mellanox import mellanox_thermal_control_test_helper # noqa F401 mocker_type = BaseMocker.get_mocker_type(mocker_name) if mocker_type: mocker_object = mocker_type(dut) diff --git a/tests/platform_tests/api/test_chassis_fans.py b/tests/platform_tests/api/test_chassis_fans.py index 664463a65ea..b94f6b97a12 100644 --- a/tests/platform_tests/api/test_chassis_fans.py +++ b/tests/platform_tests/api/test_chassis_fans.py @@ -5,7 +5,7 @@ from tests.common.helpers.platform_api import chassis, fan from .platform_api_test_base import PlatformApiTestBase -from tests.platform_tests.thermal_control_test_helper import start_thermal_control_daemon, stop_thermal_control_daemon +from tests.common.helpers.thermal_control_test_helper import start_thermal_control_daemon, stop_thermal_control_daemon ################################################### # TODO: Remove this after we transition to Python 3 diff --git a/tests/platform_tests/api/test_fan_drawer_fans.py b/tests/platform_tests/api/test_fan_drawer_fans.py index 1f284da3f68..03f6f0eac1f 100644 --- a/tests/platform_tests/api/test_fan_drawer_fans.py +++ b/tests/platform_tests/api/test_fan_drawer_fans.py @@ -5,7 +5,7 @@ import pytest from tests.common.helpers.platform_api import chassis, fan_drawer, fan_drawer_fan -from tests.platform_tests.thermal_control_test_helper import start_thermal_control_daemon, stop_thermal_control_daemon +from tests.common.helpers.thermal_control_test_helper import start_thermal_control_daemon, stop_thermal_control_daemon from .platform_api_test_base import PlatformApiTestBase ################################################### diff --git a/tests/platform_tests/conftest.py b/tests/platform_tests/conftest.py index 2c3f98eac3f..f4d9d8aac6b 100644 --- a/tests/platform_tests/conftest.py +++ b/tests/platform_tests/conftest.py @@ -14,7 +14,7 @@ from tests.common.plugins.loganalyzer.loganalyzer import LogAnalyzer from tests.common.plugins.sanity_check.recover import neighbor_vm_restore from .args.counterpoll_cpu_usage_args import add_counterpoll_cpu_usage_args -from .mellanox.mellanox_thermal_control_test_helper import suspend_hw_tc_service, resume_hw_tc_service +from tests.common.helpers.mellanox_thermal_control_test_helper import suspend_hw_tc_service, resume_hw_tc_service TEMPLATES_DIR = os.path.join(os.path.dirname( diff --git a/tests/platform_tests/mellanox/test_psu_power_threshold.py b/tests/platform_tests/mellanox/test_psu_power_threshold.py index 9a1c220a32e..3213777da13 100644 --- a/tests/platform_tests/mellanox/test_psu_power_threshold.py +++ b/tests/platform_tests/mellanox/test_psu_power_threshold.py @@ -6,8 +6,8 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.mellanox_data import get_platform_data from tests.common.utilities import wait_until # noqa F401 -from tests.platform_tests.thermal_control_test_helper import mocker_factory # noqa F401 -from .mellanox_thermal_control_test_helper import MockerHelper, PsuPowerThresholdMocker # noqa F401 +from tests.common.helpers.thermal_control_test_helper import mocker_factory # noqa F401 +from tests.common.helpers.mellanox_thermal_control_test_helper import MockerHelper, PsuPowerThresholdMocker # noqa F401 pytestmark = [ pytest.mark.asic('mellanox'), diff --git a/tests/platform_tests/mellanox/test_reboot_cause.py b/tests/platform_tests/mellanox/test_reboot_cause.py index e77915e2c11..04c8701cbb4 100644 --- a/tests/platform_tests/mellanox/test_reboot_cause.py +++ b/tests/platform_tests/mellanox/test_reboot_cause.py @@ -2,7 +2,7 @@ import logging import pytest from tests.common.reboot import REBOOT_TYPE_BIOS, REBOOT_TYPE_ASIC, check_reboot_cause -from tests.platform_tests.thermal_control_test_helper import mocker_factory # noqa: F401 +from tests.common.helpers.thermal_control_test_helper import mocker_factory # noqa: F401 pytestmark = [ pytest.mark.asic('mellanox'), diff --git a/tests/platform_tests/test_platform_info.py b/tests/platform_tests/test_platform_info.py index d458ebc97fc..c4a8c23e5f8 100644 --- a/tests/platform_tests/test_platform_info.py +++ b/tests/platform_tests/test_platform_info.py @@ -14,8 +14,8 @@ from tests.common.plugins.loganalyzer.loganalyzer import LogAnalyzer from tests.common.utilities import wait_until, get_sup_node_or_random_node from tests.common.platform.device_utils import get_dut_psu_line_pattern -from .thermal_control_test_helper import ThermalPolicyFileContext,\ - check_cli_output_with_mocker, restart_thermal_control_daemon, check_thermal_algorithm_status,\ +from tests.common.helpers.thermal_control_test_helper import ThermalPolicyFileContext,\ + check_cli_output_with_mocker, restart_thermal_control_daemon, check_thermal_algorithm_status, \ mocker_factory, disable_thermal_policy # noqa F401 pytestmark = [ diff --git a/tests/snmp/test_snmp_phy_entity.py b/tests/snmp/test_snmp_phy_entity.py index 67e18f35f34..10dfbf3d5f0 100644 --- a/tests/snmp/test_snmp_phy_entity.py +++ b/tests/snmp/test_snmp_phy_entity.py @@ -7,7 +7,7 @@ from tests.common.utilities import wait_until from tests.common.helpers.assertions import pytest_require from tests.common.helpers.snmp_helpers import get_snmp_facts -from tests.platform_tests.thermal_control_test_helper import mocker_factory # noqa F401 +from tests.common.helpers.thermal_control_test_helper import mocker_factory # noqa F401 pytestmark = [ pytest.mark.topology('any'), @@ -808,6 +808,8 @@ def redis_hgetall(duthost, db_id, key): return {} # fix to make literal_eval() work with nested dictionaries content = content.replace("'{", '"{').replace("}'", '}"') + # Remove any null characters + content = content.replace('\x00', '') return ast.literal_eval(content) diff --git a/tests/system_health/mellanox/mellanox_device_mocker.py b/tests/system_health/mellanox/mellanox_device_mocker.py index 6ddbc95eca6..0165242d018 100644 --- a/tests/system_health/mellanox/mellanox_device_mocker.py +++ b/tests/system_health/mellanox/mellanox_device_mocker.py @@ -1,7 +1,7 @@ from ..device_mocker import DeviceMocker from pkg_resources import parse_version from tests.common.mellanox_data import get_platform_data, get_hw_management_version -from tests.platform_tests.mellanox.mellanox_thermal_control_test_helper import MockerHelper, FanDrawerData, FanData, \ +from tests.common.helpers.mellanox_thermal_control_test_helper import MockerHelper, FanDrawerData, FanData, \ FAN_NAMING_RULE HW_MANAGE_VER = '7.0030.2003' diff --git a/tests/system_health/test_system_health.py b/tests/system_health/test_system_health.py index 4a1aa8f477b..eca0bddc598 100644 --- a/tests/system_health/test_system_health.py +++ b/tests/system_health/test_system_health.py @@ -9,7 +9,7 @@ from tests.common.utilities import wait_until from tests.common.helpers.assertions import pytest_require from tests.common.plugins.loganalyzer.loganalyzer import LogAnalyzer -from tests.platform_tests.thermal_control_test_helper import disable_thermal_policy # noqa F401 +from tests.common.helpers.thermal_control_test_helper import disable_thermal_policy # noqa F401 from .device_mocker import device_mocker_factory # noqa F401 from tests.common.helpers.assertions import pytest_assert from tests.common.fixtures.duthost_utils import is_support_mock_asic # noqa F401