Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Platform API]: Updates to make use of additional capabilities in pla… #4521

Merged
merged 2 commits into from
Oct 26, 2021
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
13 changes: 13 additions & 0 deletions tests/platform_tests/api/test_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from tests.common.helpers.platform_api import chassis, component

from platform_api_test_base import PlatformApiTestBase
from tests.common.utilities import skip_release_for_platform

###################################################
# TODO: Remove this after we transition to Python 3
Expand Down Expand Up @@ -164,6 +165,9 @@ def test_get_firmware_version(self, duthosts, enum_rand_one_per_hwsku_hostname,
self.assert_expectations()

def test_get_available_firmware_version(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
skip_release_for_platform(duthost, ["202012", "201911", "201811"], ["nokia"])

if self.num_components == 0:
pytest.skip("No components found on device")

Expand All @@ -175,6 +179,9 @@ def test_get_available_firmware_version(self, duthosts, enum_rand_one_per_hwsku_
self.assert_expectations()

def test_get_firmware_update_notification(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
skip_release_for_platform(duthost, ["202012", "201911", "201811"], ["nokia"])

if self.num_components == 0:
pytest.skip("No components found on device")

Expand All @@ -185,6 +192,9 @@ def test_get_firmware_update_notification(self, duthosts, enum_rand_one_per_hwsk
pytest_assert(isinstance(notif, STRING_TYPE), "Component {}: Firmware update notification appears to be incorrect from image {}".format(i, image))

def test_install_firmware(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
skip_release_for_platform(duthost, ["202012", "201911", "201811"], ["nokia"])

if self.num_components == 0:
pytest.skip("No components found on device")

Expand All @@ -197,6 +207,9 @@ def test_install_firmware(self, duthosts, enum_rand_one_per_hwsku_hostname, loca


def test_update_firmware(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
skip_release_for_platform(duthost, ["202012", "201911", "201811"], ["nokia"])

if self.num_components == 0:
pytest.skip("No components found on device")

Expand Down
12 changes: 12 additions & 0 deletions tests/platform_tests/api/test_fan_drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,22 @@ def test_set_fan_drawers_led(self, duthosts, enum_rand_one_per_hwsku_hostname, l
self.assert_expectations()

def test_get_maximum_consumed_power(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
max_power_skipped = 0

for i in range(self.num_fan_drawers):
max_power_supported = self.get_fan_drawer_facts(duthost, i, True, "max_consumed_power")
if not max_power_supported:
logger.info("test_get_maximum_consumed_power: Skipping drawer {} (max power not supported)".format(i))
max_power_skipped += 1
continue

fan_drawer_max_con_power = fan_drawer.get_maximum_consumed_power(platform_api_conn, i)
if self.expect(fan_drawer_max_con_power is not None, "Unable to retrieve module {} slot id".format(i)):
self.expect(isinstance(fan_drawer_max_con_power, float),
"Module {} max consumed power format appears incorrect ".format(i))

if max_power_skipped == self.num_fan_drawers:
pytest.skip("skipped as all chassis fan drawers' max consumed power is not supported")

self.assert_expectations()
61 changes: 42 additions & 19 deletions tests/platform_tests/api/test_psu.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ def test_fans(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platf
self.expect(fan and fan == fan_list[i], "Fan {} of PSU {} is incorrect".format(i, psu_id))
self.assert_expectations()


def test_power(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
''' PSU power test '''
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
Expand All @@ -185,16 +184,25 @@ def test_power(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, plat
voltage = psu.get_voltage(platform_api_conn, psu_id)
if self.expect(voltage is not None, "Failed to retrieve voltage of PSU {}".format(psu_id)):
self.expect(isinstance(voltage, float), "PSU {} voltage appears incorrect".format(psu_id))
current = psu.get_current(platform_api_conn, psu_id)
if self.expect(current is not None, "Failed to retrieve current of PSU {}".format(psu_id)):
self.expect(isinstance(current, float), "PSU {} current appears incorrect".format(psu_id))
power = psu.get_power(platform_api_conn, psu_id)
if self.expect(power is not None, "Failed to retrieve power of PSU {}".format(psu_id)):
self.expect(isinstance(power, float), "PSU {} power appears incorrect".format(psu_id))
max_supp_power = psu.get_maximum_supplied_power(platform_api_conn, psu_id)
if self.expect(max_supp_power is not None,
"Failed to retrieve maximum supplied power power of PSU {}".format(psu_id)):
self.expect(isinstance(power, float), "PSU {} power appears incorrect".format(psu_id))
current = None
current_supported = self.get_psu_facts(duthost, psu_id, True, "current")
if current_supported:
current = psu.get_current(platform_api_conn, psu_id)
if self.expect(current is not None, "Failed to retrieve current of PSU {}".format(psu_id)):
self.expect(isinstance(current, float), "PSU {} current appears incorrect".format(psu_id))
power = None
power_supported = self.get_psu_facts(duthost, psu_id, True, "power")
if power_supported:
power = psu.get_power(platform_api_conn, psu_id)
if self.expect(power is not None, "Failed to retrieve power of PSU {}".format(psu_id)):
self.expect(isinstance(power, float), "PSU {} power appears incorrect".format(psu_id))
max_supp_power = None
max_power_supported = self.get_psu_facts(duthost, psu_id, True, "max_power")
if max_power_supported:
max_supp_power = psu.get_maximum_supplied_power(platform_api_conn, psu_id)
if self.expect(max_supp_power is not None,
"Failed to retrieve maximum supplied power power of PSU {}".format(psu_id)):
self.expect(isinstance(power, float), "PSU {} power appears incorrect".format(psu_id))

if current is not None and voltage is not None and power is not None:
self.expect(abs(power - (voltage*current)) < power*0.1, "PSU {} reading does not make sense \
Expand All @@ -204,30 +212,42 @@ def test_power(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, plat
if self.expect(powergood_status is not None, "Failed to retrieve operational status of PSU {}".format(psu_id)):
self.expect(powergood_status is True, "PSU {} is not operational".format(psu_id))

high_threshold = psu.get_voltage_high_threshold(platform_api_conn, psu_id)
if self.expect(high_threshold is not None, "Failed to retrieve the high voltage threshold of PSU {}".format(psu_id)):
self.expect(isinstance(high_threshold, float), "PSU {} voltage high threshold appears incorrect".format(psu_id))
low_threshold = psu.get_voltage_low_threshold(platform_api_conn, psu_id)
if self.expect(low_threshold is not None, "Failed to retrieve the low voltage threshold of PSU {}".format(psu_id)):
self.expect(isinstance(low_threshold, float), "PSU {} voltage low threshold appears incorrect".format(psu_id))
high_threshold = None
voltage_high_threshold_supported = self.get_psu_facts(duthost, psu_id, True, "voltage_high_threshold")
if voltage_high_threshold_supported:
high_threshold = psu.get_voltage_high_threshold(platform_api_conn, psu_id)
if self.expect(high_threshold is not None, "Failed to retrieve the high voltage threshold of PSU {}".format(psu_id)):
self.expect(isinstance(high_threshold, float), "PSU {} voltage high threshold appears incorrect".format(psu_id))
low_threshold = None
voltage_low_threshold_supported = self.get_psu_facts(duthost, psu_id, True, "voltage_low_threshold")
if voltage_low_threshold_supported:
low_threshold = psu.get_voltage_low_threshold(platform_api_conn, psu_id)
if self.expect(low_threshold is not None, "Failed to retrieve the low voltage threshold of PSU {}".format(psu_id)):
self.expect(isinstance(low_threshold, float), "PSU {} voltage low threshold appears incorrect".format(psu_id))
if high_threshold is not None and low_threshold is not None:
self.expect(voltage < high_threshold and voltage > low_threshold,
"Voltage {} of PSU {} is not in between {} and {}".format(voltage, psu_id,
low_threshold,
high_threshold))
self.assert_expectations()


def test_temperature(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
''' PSU temperature test '''
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
skip_release_for_platform(duthost, ["202012", "201911", "201811"], ["arista"])
psus_skipped = 0

for psu_id in range(self.num_psus):
name = psu.get_name(platform_api_conn, psu_id)
if name in self.psu_skip_list:
logger.info("skipping check for {}".format(name))
else:
temperature_supported = self.get_psu_facts(duthost, psu_id, True, "temperature")
if not temperature_supported:
logger.info("test_set_fans_speed: Skipping chassis fan {} (speed not controllable)".format(psu_id))
psus_skipped += 1
continue

temperature = psu.get_temperature(platform_api_conn, psu_id)
if self.expect(temperature is not None, "Failed to retrieve temperature of PSU {}".format(psu_id)):
self.expect(isinstance(temperature, float), "PSU {} temperature appears incorrect".format(psu_id))
Expand All @@ -240,8 +260,11 @@ def test_temperature(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost
self.expect(temperature < temp_threshold,
"Temperature {} of PSU {} is over the threshold {}".format(temperature, psu_id,
temp_threshold))
self.assert_expectations()

if psus_skipped == self.num_psus:
pytest.skip("skipped as all chassis psus' temperature sensor is not supported")

self.assert_expectations()

def test_led(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
''' PSU status led test '''
Expand Down
6 changes: 3 additions & 3 deletions tests/platform_tests/api/test_psu_fans.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def test_get_fans_target_speed(self, duthosts, enum_rand_one_per_hwsku_hostname,
self.expect(target_speed == speed_target_val, "psu {} fan {} target speed setting is not correct, speed_target_val {} target_speed = {}".format(
j, i, speed_target_val, target_speed))

if fans_skipped == num_fans:
if num_fans != 0 and fans_skipped == num_fans:
psus_skipped += 1

if psus_skipped == self.num_psus:
Expand Down Expand Up @@ -301,7 +301,7 @@ def test_set_fans_speed(self, duthosts, enum_rand_one_per_hwsku_hostname, localh
self.expect(abs(act_speed - target_speed) <= speed_tol,
"psu {} fan {} speed change from {} to {} is not within tolerance, actual speed {}".format(j, i, speed, target_speed, act_speed))

if fans_skipped == num_fans:
if num_fans != 0 and fans_skipped == num_fans:
psus_skipped += 1

if psus_skipped == self.num_psus:
Expand Down Expand Up @@ -344,7 +344,7 @@ def test_set_fans_led(self, duthosts, enum_rand_one_per_hwsku_hostname, localhos
self.expect(color == color_actual, "Status LED color incorrect (expected: {}, actual: {} for fan {})".format(
color, color_actual, i))

if fans_skipped == num_fans:
if num_fans != 0 and fans_skipped == num_fans:
psus_skipped += 1

if psus_skipped == self.num_psus:
Expand Down
4 changes: 2 additions & 2 deletions tests/platform_tests/api/test_sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def test_tx_disable(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost,
def test_tx_disable_channel(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
"""This function tests both the get_tx_disable_channel() and tx_disable_channel() APIs"""
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
skip_release_for_platform(duthost, ["202012"], ["arista", "mlnx"])
skip_release_for_platform(duthost, ["202012"], ["arista", "mlnx", "nokia"])

for i in self.sfp_setup["sfp_test_port_indices"]:
# First ensure that the transceiver type supports setting TX disable on individual channels
Expand Down Expand Up @@ -516,7 +516,7 @@ def test_lpmode(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, pla
def test_power_override(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
"""This function tests both the get_power_override() and set_power_override() APIs"""
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
skip_release_for_platform(duthost, ["202012"], ["arista", "mlnx"])
skip_release_for_platform(duthost, ["202012"], ["arista", "mlnx", "nokia"])

for i in self.sfp_setup["sfp_test_port_indices"]:
info_dict = sfp.get_transceiver_info(platform_api_conn, i)
Expand Down
Loading