Skip to content

Commit

Permalink
fix wrong dut was selected to stop themalctrld (#16162)
Browse files Browse the repository at this point in the history
Description of PR
Summary:
Fixes wrong dut maybe selected to stop thermalctrl in chassis_fan tests.

TestChassisFans::setup fixture will select the first DUT as the duthost to stop/start thermal control daemon.
However, in the test case, it will enum_rand_one_per_hwsku_hostname to do the test.

Therefore, we will see something like the following. that lc4 is being selected to stop thermalctld, but the test is running on supervisor.

16/12/2024 12:42:40 base._run                                L0071 DEBUG  | /var/src/sonic-mgmt_xxx/tests/common/devices/sonic.py::stop_pmon_daemon_service#888: [xxx-lc4-1] AnsibleModule::shell, args=["docker exec pmon supervisorctl stop thermalctld"], kwargs={"module_ignore_errors": true}
......
16/12/2024 12:42:54 __init__._log_sep_line                   L0170 INFO   | ==================== platform_tests/api/test_chassis_fans.py::TestChassisFans::test_set_fans_speed[xxx-sup-1] call ====================

Approach
What is the motivation for this PR?
flaky test case in test_set_fans_speed

How did you do it?
use enum_rand_one_per_hwsku_hostname instead of duthost to align with the test case.

How did you verify/test it?
ran the test 3 times, all passed.

co-authorized by: [email protected]
  • Loading branch information
sdszhang authored and mssonicbld committed Jan 3, 2025
1 parent 4ea3709 commit 00bd09d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/platform_tests/api/test_chassis_fans.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class TestChassisFans(PlatformApiTestBase):
# level, so we must do the same here to prevent a scope mismatch.

@pytest.fixture(scope="function", autouse=True)
def setup(self, platform_api_conn, duthost): # noqa F811
def setup(self, platform_api_conn, enum_rand_one_per_hwsku_hostname, duthosts): # noqa F811
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
if self.num_fans is None:
try:
self.num_fans = int(chassis.get_num_fans(platform_api_conn))
Expand Down

0 comments on commit 00bd09d

Please sign in to comment.