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
7 changes: 7 additions & 0 deletions tests/common/helpers/platform_api/chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ def get_status(conn):
return chassis_api(conn, 'get_status')


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


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

#
# Methods defined in ChassisBase class
#
Expand Down
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 @@ -40,6 +40,14 @@ def get_serial(conn, index):
def get_status(conn, index):
return fan_api(conn, index, 'get_status')


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

#
# Methods defined in fanBase class
#
Expand Down
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 @@ -40,6 +40,14 @@ def get_serial(conn, index):
def get_status(conn, index):
return fan_drawer_api(conn, index, 'get_status')


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

#
# Methods defined in fan_drawerBase class
#
Expand Down
18 changes: 18 additions & 0 deletions tests/common/helpers/platform_api/psu.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ def get_status(conn, index):
return psu_api(conn, index, 'get_status')


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

#
# Methods defined in PsuBase class
#
Expand Down Expand Up @@ -99,3 +106,14 @@ 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_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])
19 changes: 19 additions & 0 deletions tests/common/helpers/platform_api/sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ def get_status(conn, index):
return sfp_api(conn, index, 'get_status')


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

#
# Methods defined in SfpBase class
#
Expand Down Expand Up @@ -128,3 +135,15 @@ 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_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 @@ -40,6 +40,14 @@ def get_serial(conn, index):
def get_status(conn, index):
return thermal_api(conn, index, 'get_status')


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

#
# Methods defined in thermalBase class
#
Expand Down
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 @@ -135,6 +135,18 @@ def test_get_status(self, duthost, localhost, platform_api_conn):
pytest_assert(status is not None, "Unable to retrieve chassis status")
pytest_assert(isinstance(status, bool), "Chassis status appears incorrect")

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

#
# Functions to test methods defined in ChassisBase class
#
Expand Down
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 @@ -129,6 +129,20 @@ def test_get_status(self, duthost, localhost, platform_api_conn):

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

#
# Functions to test methods defined in FanBase class
#
Expand Down
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 @@ -110,6 +110,20 @@ def test_get_status(self, duthost, localhost, platform_api_conn):

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

#
# Functions to test methods defined in Fan_drawerBase class
#
Expand Down
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 @@ -111,6 +111,20 @@ def test_get_status(self, duthost, localhost, platform_api_conn):
self.expect(isinstance(status, bool), "PSU {} status appears incorrect".format(i))
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()

#
# Functions to test methods defined in PsuBase class
#
Expand Down Expand Up @@ -200,3 +214,19 @@ 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_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 @@ -177,6 +177,20 @@ def test_get_status(self, duthost, localhost, platform_api_conn):
self.expect(isinstance(status, bool), "Transceiver {} status appears 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()

#
# Functions to test methods defined in SfpBase class
#
Expand Down Expand Up @@ -423,3 +437,19 @@ 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_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 @@ -118,6 +118,20 @@ def test_get_status(self, duthost, localhost, platform_api_conn):

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

#
# Functions to test methods defined in ThermalBase class
#
Expand Down