Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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: 8 additions & 0 deletions tests/common/helpers/platform_api/chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,11 @@ def get_watchdog(conn):

def get_eeprom(conn):
return chassis_api(conn, 'get_eeprom')


def get_position_in_parent(conn):
return chassis_api(conn, 'get_position_in_parent')


def is_replaceable(conn):
return chassis_api(conn, 'is_replaceable')
8 changes: 8 additions & 0 deletions tests/common/helpers/platform_api/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,11 @@ def set_status_led(conn, index, color):

def get_status_led(conn, index):
return fan_api(conn, index, 'get_status_led')


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')
8 changes: 8 additions & 0 deletions tests/common/helpers/platform_api/fan_drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,11 @@ def set_status_led(conn, index, color):

def get_status_led(conn, index):
return fan_drawer_api(conn, index, 'get_status_led')


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')
19 changes: 19 additions & 0 deletions tests/common/helpers/platform_api/psu.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,22 @@ 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_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')


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])
20 changes: 20 additions & 0 deletions tests/common/helpers/platform_api/sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,23 @@ 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_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')


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])
8 changes: 8 additions & 0 deletions tests/common/helpers/platform_api/thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,11 @@ def get_high_critical_threshold(conn, index):

def get_low_critical_threshold(conn, index):
return thermal_api(conn, index, 'get_low_critical_threshold')


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')
12 changes: 12 additions & 0 deletions tests/platform_tests/api/test_chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,15 @@ def test_get_watchdog(self, duthost, localhost, platform_api_conn):
def test_get_eeprom(self, duthost, localhost, platform_api_conn):
eeprom = chassis.get_eeprom(platform_api_conn)
pytest_assert(eeprom is not None, "Failed to retrieve system EEPROM")

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()
14 changes: 14 additions & 0 deletions tests/platform_tests/api/test_chassis_fans.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,17 @@ def test_set_fans_led(self, duthost, localhost, platform_api_conn):
color, color_actual, i))

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()
14 changes: 14 additions & 0 deletions tests/platform_tests/api/test_fan_drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,17 @@ def test_set_fan_drawers_led(self, duthost, localhost, platform_api_conn):
color, color_actual, i))

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()
30 changes: 30 additions & 0 deletions tests/platform_tests/api/test_psu.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,33 @@ 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_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()

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()

30 changes: 30 additions & 0 deletions tests/platform_tests/api/test_sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,3 +423,33 @@ 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_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()

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()
14 changes: 14 additions & 0 deletions tests/platform_tests/api/test_thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,17 @@ def test_set_high_threshold(self, duthost, localhost, platform_api_conn):
self.expect(temperature == 80,
"Thermal {} high threshold {} is not matching the set value {}".format(i, temperature, high_temperature))
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()