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
8 changes: 6 additions & 2 deletions tests/common/helpers/platform_api/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 6 additions & 2 deletions tests/common/helpers/platform_api/fan_drawer_fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 6 additions & 2 deletions tests/common/helpers/platform_api/psu_fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand All @@ -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:
Expand Down
20 changes: 4 additions & 16 deletions tests/platform_tests/api/test_chassis_fans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))

Expand Down
24 changes: 4 additions & 20 deletions tests/platform_tests/api/test_fan_drawer_fans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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))

Expand Down
29 changes: 4 additions & 25 deletions tests/platform_tests/api/test_psu_fans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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))

Expand Down