diff --git a/tests/common/helpers/platform_api/fan.py b/tests/common/helpers/platform_api/fan.py index 6c17424c823..e75f527b91a 100644 --- a/tests/common/helpers/platform_api/fan.py +++ b/tests/common/helpers/platform_api/fan.py @@ -65,8 +65,12 @@ def get_target_speed(conn, index): return fan_api(conn, index, 'get_target_speed') -def get_speed_tolerance(conn, index): - return fan_api(conn, index, 'get_speed_tolerance') +def is_under_speed(conn, index): + return fan_api(conn, index, 'is_under_speed') + + +def is_over_speed(conn, index): + return fan_api(conn, index, 'is_over_speed') def set_speed(conn, index, speed): diff --git a/tests/common/helpers/platform_api/fan_drawer_fan.py b/tests/common/helpers/platform_api/fan_drawer_fan.py index 6a16bc76a5f..29e48b185d6 100644 --- a/tests/common/helpers/platform_api/fan_drawer_fan.py +++ b/tests/common/helpers/platform_api/fan_drawer_fan.py @@ -67,8 +67,12 @@ def get_target_speed(conn, fan_drawer_idx, fan_idx): return fan_drawer_fan_api(conn, fan_drawer_idx, fan_idx, 'get_target_speed') -def get_speed_tolerance(conn, fan_drawer_idx, fan_idx): - return fan_drawer_fan_api(conn, fan_drawer_idx, fan_idx, 'get_speed_tolerance') +def is_under_speed(conn, fan_drawer_idx, fan_idx): + return fan_drawer_fan_api(conn, fan_drawer_idx, fan_idx, 'is_under_speed') + + +def is_over_speed(conn, fan_drawer_idx, fan_idx): + return fan_drawer_fan_api(conn, fan_drawer_idx, fan_idx, 'is_over_speed') def set_speed(conn, fan_drawer_idx, fan_idx, speed): diff --git a/tests/common/helpers/platform_api/psu_fan.py b/tests/common/helpers/platform_api/psu_fan.py index edbc0598dca..f943d7f5a10 100644 --- a/tests/common/helpers/platform_api/psu_fan.py +++ b/tests/common/helpers/platform_api/psu_fan.py @@ -67,8 +67,12 @@ def get_target_speed(conn, psu_idx, fan_idx): return psu_fan_api(conn, psu_idx, fan_idx, 'get_target_speed') -def get_speed_tolerance(conn, psu_idx, fan_idx): - return psu_fan_api(conn, psu_idx, fan_idx, 'get_speed_tolerance') +def is_under_speed(conn, psu_idx, fan_idx): + return psu_fan_api(conn, psu_idx, fan_idx, 'is_under_speed') + + +def is_over_speed(conn, psu_idx, fan_idx): + return psu_fan_api(conn, psu_idx, fan_idx, 'is_over_speed') def set_speed(conn, psu_idx, fan_idx, speed): diff --git a/tests/common/plugins/conditional_mark/tests_mark_conditions_platform_tests.yaml b/tests/common/plugins/conditional_mark/tests_mark_conditions_platform_tests.yaml index 053c45c6d7c..c9847ebd5ea 100644 --- a/tests/common/plugins/conditional_mark/tests_mark_conditions_platform_tests.yaml +++ b/tests/common/plugins/conditional_mark/tests_mark_conditions_platform_tests.yaml @@ -89,14 +89,6 @@ platform_tests/api/test_chassis_fans.py::TestChassisFans::test_get_direction: - "hwsku in ['Celestica-DX010-C32']" - https://github.com/sonic-net/sonic-mgmt/issues/6512 -platform_tests/api/test_chassis_fans.py::TestChassisFans::test_get_fans_speed_tolerance: - #get_speed_tolerance API was disabled so platform code can perform fan tolerance checks - #using RPM rather than thermalctld checking tolerance on percentages - skip: - reason: "Unsupported platform API" - conditions: - - "asic_type in ['cisco-8000']" - platform_tests/api/test_chassis_fans.py::TestChassisFans::test_get_fans_target_speed: xfail: reason: "Testcase consistently fails, raised issue to track" @@ -130,13 +122,10 @@ platform_tests/api/test_chassis_fans.py::TestChassisFans::test_set_fans_led: - https://github.com/sonic-net/sonic-mgmt/issues/6512 platform_tests/api/test_chassis_fans.py::TestChassisFans::test_set_fans_speed: - #test_set_fans_speed requires get_speed_tolerance to be implemented - #get_speed_tolerance API was disabled so platform code can perform fan tolerance checks - #using RPM rather than thermalctld checking tolerance on percentages skip: reason: "Unsupported platform API" conditions: - - "asic_type in ['mellanox', 'cisco-8000']" + - "asic_type in ['mellanox']" xfail: reason: "Testcase consistently fails, raised issue to track" conditions: @@ -269,14 +258,6 @@ platform_tests/api/test_fan_drawer.py::TestFanDrawerApi::test_set_fan_drawers_le ##### api/test_fan_drawer_fans.py ##### ####################################### -platform_tests/api/test_fan_drawer_fans.py::TestFanDrawerFans::test_get_fans_speed_tolerance: - #get_speed_tolerance API was disabled so platform code can perform fan tolerance checks - #using RPM rather than thermalctld checking tolerance on percentages - skip: - reason: "Unsupported platform API" - conditions: - - "asic_type in ['cisco-8000']" - platform_tests/api/test_fan_drawer_fans.py::TestFanDrawerFans::test_get_model: skip: reason: "Unsupported platform API" @@ -298,13 +279,10 @@ platform_tests/api/test_fan_drawer_fans.py::TestFanDrawerFans::test_set_fans_led - "asic_type in ['mellanox', 'cisco-8000']" platform_tests/api/test_fan_drawer_fans.py::TestFanDrawerFans::test_set_fans_speed: - #test_set_fans_speed requires get_speed_tolerance to be implemented - #get_speed_tolerance API was disabled so platform code can perform fan tolerance checks - #using RPM rather than thermalctld checking tolerance on percentages skip: reason: "Unsupported platform API" conditions: - - "asic_type in ['mellanox', 'cisco-8000']" + - "asic_type in ['mellanox']" xfail: reason: "Testcase consistently fails, raised issue to track" conditions: diff --git a/tests/platform_tests/api/test_chassis_fans.py b/tests/platform_tests/api/test_chassis_fans.py index 74a0466eaaf..b11e8e799cf 100644 --- a/tests/platform_tests/api/test_chassis_fans.py +++ b/tests/platform_tests/api/test_chassis_fans.py @@ -217,19 +217,6 @@ def test_get_fans_target_speed(self, duthosts, enum_rand_one_per_hwsku_hostname, self.assert_expectations() - def test_get_fans_speed_tolerance(self, duthosts, enum_rand_one_per_hwsku_hostname, - localhost, platform_api_conn): - - for i in range(self.num_fans): - speed_tolerance = fan.get_speed_tolerance(platform_api_conn, i) - if self.expect(speed_tolerance is not None, "Unable to retrieve Fan {} speed tolerance".format(i)): - if self.expect(isinstance(speed_tolerance, int), - "Fan {} speed tolerance appears incorrect".format(i)): - self.expect(speed_tolerance > 0 and speed_tolerance <= 100, - "Fan {} speed tolerance {} reading does not make sense".format(i, speed_tolerance)) - - self.assert_expectations() - def test_set_fans_speed(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn): fans_skipped = 0 @@ -252,13 +239,14 @@ def test_set_fans_speed(self, duthosts, enum_rand_one_per_hwsku_hostname, localh target_speed = random.randint(speed_minimum, speed_maximum) speed = fan.get_speed(platform_api_conn, i) - speed_tol = fan.get_speed_tolerance(platform_api_conn, i) speed_set = fan.set_speed(platform_api_conn, i, target_speed) # noqa F841 - time.sleep(5) + time.sleep(self.get_fan_facts(duthost, i, 5, "speed", "delay")) act_speed = fan.get_speed(platform_api_conn, i) - self.expect(abs(act_speed - target_speed) <= speed_tol, + under_speed = fan.is_under_speed(platform_api_conn, i) + over_speed = fan.is_over_speed(platform_api_conn, i) + self.expect(not under_speed and not over_speed, "Fan {} speed change from {} to {} is not within tolerance, actual speed {}" .format(i, speed, target_speed, act_speed)) diff --git a/tests/platform_tests/api/test_fan_drawer_fans.py b/tests/platform_tests/api/test_fan_drawer_fans.py index 0a3058f588b..932e4b90dba 100644 --- a/tests/platform_tests/api/test_fan_drawer_fans.py +++ b/tests/platform_tests/api/test_fan_drawer_fans.py @@ -280,23 +280,6 @@ def test_get_fans_target_speed(self, duthosts, enum_rand_one_per_hwsku_hostname, self.assert_expectations() - def test_get_fans_speed_tolerance(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn): - - for j in range(self.num_fan_drawers): - num_fans = fan_drawer.get_num_fans(platform_api_conn, j) - - for i in range(num_fans): - speed_tolerance = fan_drawer_fan.get_speed_tolerance(platform_api_conn, j, i) - if self.expect(speed_tolerance is not None, - "Unable to retrieve fan drawer {} fan {} speed tolerance".format(j, i)): - if self.expect(isinstance(speed_tolerance, int), - "Fan drawer {} fan {} speed tolerance appears incorrect".format(j, i)): - self.expect(speed_tolerance > 0 and speed_tolerance <= 100, - "Fan drawer {} fan {} speed tolerance {} reading does not make sense" - .format(j, i, speed_tolerance)) - - self.assert_expectations() - def test_set_fans_speed(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn): duthost = duthosts[enum_rand_one_per_hwsku_hostname] @@ -321,13 +304,14 @@ def test_set_fans_speed(self, duthosts, enum_rand_one_per_hwsku_hostname, localh target_speed = random.randint(speed_minimum, speed_maximum) speed = fan_drawer_fan.get_speed(platform_api_conn, j, i) - speed_tol = fan_drawer_fan.get_speed_tolerance(platform_api_conn, j, i) speed_set = fan_drawer_fan.set_speed(platform_api_conn, j, i, target_speed) # noqa F841 - time.sleep(5) + time.sleep(self.get_fan_facts(duthost, j, i, 5, "speed", "delay")) act_speed = fan_drawer_fan.get_speed(platform_api_conn, j, i) - self.expect(abs(act_speed - target_speed) <= speed_tol, + under_speed = fan_drawer_fan.is_under_speed(platform_api_conn, j, i) + over_speed = fan_drawer_fan.is_over_speed(platform_api_conn, j, i) + self.expect(not under_speed and not over_speed, "Fan drawer {} fan {} speed change from {} to {} is not within tolerance, actual speed {}" .format(j, i, speed, target_speed, act_speed)) diff --git a/tests/platform_tests/api/test_psu_fans.py b/tests/platform_tests/api/test_psu_fans.py index d844dd9c250..4f3823cc7d5 100644 --- a/tests/platform_tests/api/test_psu_fans.py +++ b/tests/platform_tests/api/test_psu_fans.py @@ -295,28 +295,6 @@ def test_get_fans_target_speed(self, duthosts, enum_rand_one_per_hwsku_hostname, self.assert_expectations() - def test_get_fans_speed_tolerance(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn): - duthost = duthosts[enum_rand_one_per_hwsku_hostname] - for j in range(self.num_psus): - num_fans = psu.get_num_fans(platform_api_conn, j) - - for i in range(num_fans): - speed_controllable = self.get_fan_facts(duthost, j, i, True, "speed", "controllable") - if not speed_controllable: - logger.info("test_get_fans_speed_tolerance: Skipping PSU {} fan {} (speed not controllable)" - .format(j, i)) - continue - speed_tolerance = psu_fan.get_speed_tolerance(platform_api_conn, j, i) - if self.expect(speed_tolerance is not None, - "Unable to retrieve psu {} fan {} speed tolerance".format(j, i)): - if self.expect(isinstance(speed_tolerance, int), "psu {} fan {} speed tolerance appears incorrect" - .format(j, i)): - self.expect(speed_tolerance > 0 and speed_tolerance <= 100, - "psu {} fan {} speed tolerance {} reading does not make sense" - .format(j, i, speed_tolerance)) - - self.assert_expectations() - def test_set_fans_speed(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn): duthost = duthosts[enum_rand_one_per_hwsku_hostname] @@ -340,13 +318,14 @@ def test_set_fans_speed(self, duthosts, enum_rand_one_per_hwsku_hostname, localh target_speed = random.randint(speed_minimum, speed_maximum) speed = psu_fan.get_speed(platform_api_conn, j, i) - speed_tol = psu_fan.get_speed_tolerance(platform_api_conn, j, i) speed_set = psu_fan.set_speed(platform_api_conn, j, i, target_speed) # noqa F841 - time.sleep(5) + time.sleep(self.get_fan_facts(duthost, j, i, 5, "speed", "delay")) act_speed = psu_fan.get_speed(platform_api_conn, j, i) - self.expect(abs(act_speed - target_speed) <= speed_tol, + under_speed = psu_fan.is_under_speed(platform_api_conn, j, i) + over_speed = psu_fan.is_over_speed(platform_api_conn, j, i) + self.expect(not under_speed and not over_speed, "psu {} fan {} speed change from {} to {} is not within tolerance, actual speed {}" .format(j, i, speed, target_speed, act_speed))