diff --git a/tests/common/helpers/platform_api/chassis.py b/tests/common/helpers/platform_api/chassis.py index 1893f9e9cbe..953b48ee09e 100644 --- a/tests/common/helpers/platform_api/chassis.py +++ b/tests/common/helpers/platform_api/chassis.py @@ -41,6 +41,13 @@ def get_status(conn): return chassis_api(conn, 'get_status') +def get_position_in_parent(conn): + return chassis_api(conn, 'get_position_in_parent') + + +def is_replaceable(conn): + return chassis_api(conn, 'is_replaceable') + # # Methods defined in ChassisBase class # diff --git a/tests/common/helpers/platform_api/fan.py b/tests/common/helpers/platform_api/fan.py index f6e8b010b71..6c17424c823 100644 --- a/tests/common/helpers/platform_api/fan.py +++ b/tests/common/helpers/platform_api/fan.py @@ -40,6 +40,14 @@ def get_serial(conn, index): def get_status(conn, index): return fan_api(conn, index, 'get_status') + +def get_position_in_parent(conn, index): + return fan_api(conn, index, 'get_position_in_parent') + + +def is_replaceable(conn, index): + return fan_api(conn, index, 'is_replaceable') + # # Methods defined in fanBase class # diff --git a/tests/common/helpers/platform_api/fan_drawer.py b/tests/common/helpers/platform_api/fan_drawer.py index fa0a1101b2a..9b909b6ed6d 100644 --- a/tests/common/helpers/platform_api/fan_drawer.py +++ b/tests/common/helpers/platform_api/fan_drawer.py @@ -40,6 +40,14 @@ def get_serial(conn, index): def get_status(conn, index): return fan_drawer_api(conn, index, 'get_status') + +def get_position_in_parent(conn, index): + return fan_drawer_api(conn, index, 'get_position_in_parent') + + +def is_replaceable(conn, index): + return fan_drawer_api(conn, index, 'is_replaceable') + # # Methods defined in fan_drawerBase class # diff --git a/tests/common/helpers/platform_api/psu.py b/tests/common/helpers/platform_api/psu.py index b2722428646..3a73ffd4206 100644 --- a/tests/common/helpers/platform_api/psu.py +++ b/tests/common/helpers/platform_api/psu.py @@ -43,6 +43,13 @@ def get_status(conn, index): return psu_api(conn, index, 'get_status') +def get_position_in_parent(conn, psu_id): + return psu_api(conn, psu_id, 'get_position_in_parent') + + +def is_replaceable(conn, psu_id): + return psu_api(conn, psu_id, 'is_replaceable') + # # Methods defined in PsuBase class # @@ -99,3 +106,14 @@ def get_voltage_high_threshold(conn, psu_id): def get_voltage_low_threshold(conn, psu_id): return psu_api(conn, psu_id, 'get_voltage_low_threshold') + +def get_num_thermals(conn, psu_id): + return psu_api(conn, psu_id, 'get_num_thermals') + + +def get_all_thermals(conn, psu_id): + return psu_api(conn, psu_id, 'get_all_thermals') + + +def get_thermal(conn, psu_id, index): + return psu_api(conn, psu_id, 'get_thermal', [index]) diff --git a/tests/common/helpers/platform_api/sfp.py b/tests/common/helpers/platform_api/sfp.py index 6950bcfa8e3..a5bf42624c0 100644 --- a/tests/common/helpers/platform_api/sfp.py +++ b/tests/common/helpers/platform_api/sfp.py @@ -43,6 +43,13 @@ def get_status(conn, index): return sfp_api(conn, index, 'get_status') +def get_position_in_parent(conn, index): + return sfp_api(conn, index, 'get_position_in_parent') + + +def is_replaceable(conn, index): + return sfp_api(conn, index, 'is_replaceable') + # # Methods defined in SfpBase class # @@ -128,3 +135,15 @@ def set_lpmode(conn, index, lpmode): def set_power_override(conn, index, power_override, power_set): return sfp_api(conn, index, 'set_power_override', [power_override, power_set]) + + +def get_num_thermals(conn, index): + return sfp_api(conn, index, 'get_num_thermals') + + +def get_all_thermals(conn, index): + return sfp_api(conn, index, 'get_all_thermals') + + +def get_thermal(conn, index, thermal_index): + return sfp_api(conn, index, 'get_thermal', [thermal_index]) diff --git a/tests/common/helpers/platform_api/thermal.py b/tests/common/helpers/platform_api/thermal.py index 3bfe6ed242b..7710bf62563 100644 --- a/tests/common/helpers/platform_api/thermal.py +++ b/tests/common/helpers/platform_api/thermal.py @@ -40,6 +40,14 @@ def get_serial(conn, index): def get_status(conn, index): return thermal_api(conn, index, 'get_status') + +def get_position_in_parent(conn, index): + return thermal_api(conn, index, 'get_position_in_parent') + + +def is_replaceable(conn, index): + return thermal_api(conn, index, 'is_replaceable') + # # Methods defined in thermalBase class # diff --git a/tests/platform_tests/api/test_chassis.py b/tests/platform_tests/api/test_chassis.py index 63973f65702..217bb4fc7bc 100644 --- a/tests/platform_tests/api/test_chassis.py +++ b/tests/platform_tests/api/test_chassis.py @@ -135,6 +135,18 @@ def test_get_status(self, duthost, localhost, platform_api_conn): pytest_assert(status is not None, "Unable to retrieve chassis status") pytest_assert(isinstance(status, bool), "Chassis status appears incorrect") + def test_get_position_in_parent(self, platform_api_conn): + position = chassis.get_position_in_parent(platform_api_conn) + if self.expect(position is not None, "Failed to perform get_position_in_parent"): + self.expect(isinstance(position, int), "Position value must be an integer value") + self.assert_expectations() + + def test_is_replaceable(self, platform_api_conn): + replaceable = chassis.is_replaceable(platform_api_conn) + if self.expect(replaceable is not None, "Failed to perform is_replaceable"): + self.expect(isinstance(replaceable, bool), "Replaceable value must be a bool value") + self.assert_expectations() + # # Functions to test methods defined in ChassisBase class # diff --git a/tests/platform_tests/api/test_chassis_fans.py b/tests/platform_tests/api/test_chassis_fans.py index c9358ef2a90..1daedd5e4f0 100644 --- a/tests/platform_tests/api/test_chassis_fans.py +++ b/tests/platform_tests/api/test_chassis_fans.py @@ -129,6 +129,20 @@ def test_get_status(self, duthost, localhost, platform_api_conn): self.assert_expectations() + def test_get_position_in_parent(self, platform_api_conn): + for i in range(self.num_fans): + position = fan.get_position_in_parent(platform_api_conn, i) + if self.expect(position is not None, "Failed to perform get_position_in_parent for fan {}".format(i)): + self.expect(isinstance(position, int), "Position value must be an integer value for fan {}".format(i)) + self.assert_expectations() + + def test_is_replaceable(self, platform_api_conn): + for i in range(self.num_fans): + replaceable = fan.is_replaceable(platform_api_conn, i) + if self.expect(replaceable is not None, "Failed to perform is_replaceable for fan {}".format(i)): + self.expect(isinstance(replaceable, bool), "Replaceable value must be a bool value for fan {}".format(i)) + self.assert_expectations() + # # Functions to test methods defined in FanBase class # diff --git a/tests/platform_tests/api/test_fan_drawer.py b/tests/platform_tests/api/test_fan_drawer.py index d67b0d27448..100ee11c9fb 100644 --- a/tests/platform_tests/api/test_fan_drawer.py +++ b/tests/platform_tests/api/test_fan_drawer.py @@ -110,6 +110,20 @@ def test_get_status(self, duthost, localhost, platform_api_conn): self.assert_expectations() + def test_get_position_in_parent(self, platform_api_conn): + for i in range(self.num_fan_drawers): + position = fan_drawer.get_position_in_parent(platform_api_conn, i) + if self.expect(position is not None, "Failed to perform get_position_in_parent for fan drawer {}".format(i)): + self.expect(isinstance(position, int), "Position value must be an integer value for fan drawer {}".format(i)) + self.assert_expectations() + + def test_is_replaceable(self, platform_api_conn): + for i in range(self.num_fan_drawers): + replaceable = fan_drawer.is_replaceable(platform_api_conn, i) + if self.expect(replaceable is not None, "Failed to perform is_replaceable for fan drawer {}".format(i)): + self.expect(isinstance(replaceable, bool), "Replaceable value must be a bool value for fan drawer {}".format(i)) + self.assert_expectations() + # # Functions to test methods defined in Fan_drawerBase class # diff --git a/tests/platform_tests/api/test_psu.py b/tests/platform_tests/api/test_psu.py index 679ceaed152..6494cfc6e40 100644 --- a/tests/platform_tests/api/test_psu.py +++ b/tests/platform_tests/api/test_psu.py @@ -111,6 +111,20 @@ def test_get_status(self, duthost, localhost, platform_api_conn): self.expect(isinstance(status, bool), "PSU {} status appears incorrect".format(i)) self.assert_expectations() + def test_get_position_in_parent(self, platform_api_conn): + for psu_id in range(self.num_psus): + position = psu.get_position_in_parent(platform_api_conn, psu_id) + if self.expect(position is not None, "Failed to perform get_position_in_parent for psu id {}".format(psu_id)): + self.expect(isinstance(position, int), "Position value must be an integer value for psu id {}".format(psu_id)) + self.assert_expectations() + + def test_is_replaceable(self, platform_api_conn): + for psu_id in range(self.num_psus): + replaceable = psu.is_replaceable(platform_api_conn, psu_id) + if self.expect(replaceable is not None, "Failed to perform is_replaceable for psu id {}".format(psu_id)): + self.expect(isinstance(replaceable, bool), "Replaceable value must be a bool value for psu id {}".format(psu_id)) + self.assert_expectations() + # # Functions to test methods defined in PsuBase class # @@ -200,3 +214,19 @@ def test_led(self, duthost, localhost, platform_api_conn): self.expect(color == color_actual, "Status LED color incorrect (expected: {}, actual: {}) from PSU {}".format(color, color_actual, psu_id)) self.assert_expectations() + def test_thermals(self, platform_api_conn): + for psu_id in range(self.num_psus): + try: + num_thermals = int(psu.get_num_thermals(platform_api_conn, psu_id)) + except Exception: + pytest.fail("PSU {}: num_thermals is not an integer".format(psu_id)) + + thermal_list = psu.get_all_thermals(platform_api_conn, psu_id) + pytest_assert(thermal_list is not None, "Failed to retrieve thermals for psu {}".format(psu_id)) + pytest_assert(isinstance(thermal_list, list) and len(thermal_list) == num_thermals, "Thermals appear to be incorrect for psu {}".format(psu_id)) + + for i in range(num_thermals): + thermal = psu.get_thermal(platform_api_conn, psu_id, i) + self.expect(thermal and thermal == thermal_list[i], "Thermal {} is incorrect for psu {}".format(i, psu_id)) + self.assert_expectations() + diff --git a/tests/platform_tests/api/test_sfp.py b/tests/platform_tests/api/test_sfp.py index 95c105f39c7..f68ab88d66c 100644 --- a/tests/platform_tests/api/test_sfp.py +++ b/tests/platform_tests/api/test_sfp.py @@ -177,6 +177,20 @@ def test_get_status(self, duthost, localhost, platform_api_conn): self.expect(isinstance(status, bool), "Transceiver {} status appears incorrect".format(i)) self.assert_expectations() + def test_get_position_in_parent(self, platform_api_conn): + for i in range(self.num_sfps): + position = sfp.get_position_in_parent(platform_api_conn, i) + if self.expect(position is not None, "Failed to perform get_position_in_parent for sfp {}".format(i)): + self.expect(isinstance(position, int), "Position value must be an integer value for sfp {}".format(i)) + self.assert_expectations() + + def test_is_replaceable(self, platform_api_conn): + for sfp_id in range(self.num_sfps): + replaceable = sfp.is_replaceable(platform_api_conn, sfp_id) + if self.expect(replaceable is not None, "Failed to perform is_replaceable for sfp {}".format(sfp_id)): + self.expect(isinstance(replaceable, bool), "Replaceable value must be a bool value for sfp {}".format(sfp_id)) + self.assert_expectations() + # # Functions to test methods defined in SfpBase class # @@ -423,3 +437,19 @@ def test_power_override(self, duthost, localhost, platform_api_conn): if self.expect(power_override is not None, "Unable to retrieve transceiver {} power override data".format(i)): self.expect(power_override is False, "Transceiver {} power override data is incorrect".format(i)) self.assert_expectations() + + def test_thermals(self, platform_api_conn): + for sfp_id in range(self.num_sfps): + try: + num_thermals = int(sfp.get_num_thermals(platform_api_conn, sfp_id)) + except Exception: + pytest.fail("SFP {}: num_thermals is not an integer".format(sfp_id)) + + thermal_list = sfp.get_all_thermals(platform_api_conn, i) + pytest_assert(thermal_list is not None, "Failed to retrieve thermals for sfp {}".format(sfp_id)) + pytest_assert(isinstance(thermal_list, list) and len(thermal_list) == num_thermals, "Thermals appear to be incorrect for sfp {}".format(sfp_id)) + + for thermal_index in range(num_thermals): + thermal = sfp.get_thermal(platform_api_conn, i, thermal_index) + self.expect(thermal and thermal == thermal_list[i], "Thermal {} is incorrect for sfp {}".format(thermal_index, sfp_id)) + self.assert_expectations() diff --git a/tests/platform_tests/api/test_thermal.py b/tests/platform_tests/api/test_thermal.py index 9a61d750447..3c960949512 100644 --- a/tests/platform_tests/api/test_thermal.py +++ b/tests/platform_tests/api/test_thermal.py @@ -118,6 +118,20 @@ def test_get_status(self, duthost, localhost, platform_api_conn): self.assert_expectations() + def test_get_position_in_parent(self, platform_api_conn): + for i in range(self.num_thermals): + position = thermal.get_position_in_parent(platform_api_conn, i) + if self.expect(position is not None, "Failed to perform get_position_in_parent for thermal {}".format(i)): + self.expect(isinstance(position, int), "Position value must be an integer value for thermal {}".format(i)) + self.assert_expectations() + + def test_is_replaceable(self, platform_api_conn): + for i in range(self.num_thermals): + replaceable = thermal.is_replaceable(platform_api_conn, i) + if self.expect(replaceable is not None, "Failed to perform is_replaceable for thermal {}".format(i)): + self.expect(isinstance(replaceable, bool), "Replaceable value must be a bool value for thermal {}".format(i)) + self.assert_expectations() + # # Functions to test methods defined in ThermalBase class #