Skip to content

Commit

Permalink
[Platform API][Chassis][Module] Remove tests for deprecated, redundan…
Browse files Browse the repository at this point in the history
…t get_serial_number() methods (#2343)

No longer test deprecated get_serial_number() methods of Chassis and Module classes

The get_serial_number() methods are redundant and are being removed in sonic-net/sonic-platform-common#130
  • Loading branch information
jleveque authored Oct 14, 2020
1 parent ad43809 commit 0b312e6
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 41 deletions.
4 changes: 0 additions & 4 deletions tests/common/helpers/platform_api/chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ def get_base_mac(conn):
return chassis_api(conn, 'get_base_mac')


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


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

Expand Down
4 changes: 0 additions & 4 deletions tests/common/helpers/platform_api/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ def get_base_mac(conn, mod_idx):
return module_api(conn, mod_idx, 'get_base_mac')


def get_serial_number(conn, mod_idx):
return module_api(conn, mod_idx, 'get_serial_number')


def get_system_eeprom_info(conn, mod_idx):
return module_api(conn, mod_idx, 'get_system_eeprom_info')

Expand Down
13 changes: 0 additions & 13 deletions tests/platform_tests/api/test_chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,6 @@ def test_get_base_mac(self, duthost, localhost, platform_api_conn):
pytest_assert(re.match(REGEX_MAC_ADDRESS, base_mac), "Base MAC address appears to be incorrect")
self.compare_value_with_device_facts('base_mac', base_mac, False)

def test_get_serial_number(self, duthost, localhost, platform_api_conn):
# Ensure the serial number is sane
# Note: It appears that when retrieving some variable-length fields,
# the value is padded with trailing '\x00' bytes because the field
# length is longer than the actual value, so we strip those bytes
# here before comparing. We may want to change the EEPROM parsing
# logic to ensure that trailing '\x00' bytes are removed when retreiving
# a variable-length value.
serial = chassis.get_serial_number(platform_api_conn).rstrip('\x00')
pytest_assert(serial is not None, "Failed to retrieve serial number")
pytest_assert(re.match(REGEX_SERIAL_NUMBER, serial), "Serial number appears to be incorrect")
self.compare_value_with_device_facts('serial', serial)

def test_get_system_eeprom_info(self, duthost, localhost, platform_api_conn):
''' Test that we can retrieve sane system EEPROM info from the DUT via the platform API
'''
Expand Down
21 changes: 1 addition & 20 deletions tests/platform_tests/api/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_get_serial(self, duthost, localhost, platform_api_conn):

for i in range(self.num_modules):
serial = module.get_serial(platform_api_conn, i)
if self.expect(serial is not None, "Unable to retrieve module {} serial number".format(i)):
if self.expect(serial is not None, "Module {}: Failed to retrieve serial number".format(i)):
self.expect(isinstance(serial, STRING_TYPE), "Module {} serial number appears incorrect".format(i))
self.assert_expectations()

Expand Down Expand Up @@ -138,25 +138,6 @@ def test_get_base_mac(self, duthost, localhost, platform_api_conn):
self.expect(re.match(REGEX_MAC_ADDRESS, base_mac), "Module {}: Base MAC address appears to be incorrect".format(i))
self.assert_expectations()

def test_get_serial_number(self, duthost, localhost, platform_api_conn):
if self.num_modules == 0:
pytest.skip("No modules found on device")

# Ensure the serial number of each module is sane
# Note: It appears that when retrieving some variable-length fields,
# the value is padded with trailing '\x00' bytes because the field
# length is longer than the actual value, so we strip those bytes
# here before comparing. We may want to change the EEPROM parsing
# logic to ensure that trailing '\x00' bytes are removed when retreiving
# a variable-length value.
# TODO: Add expected serial number of each module to inventory file and compare against it
for i in range(self.num_modules):
serial = module.get_serial_number(platform_api_conn, i).rstrip('\x00')
if not self.expect(serial is not None, "Module {}: Failed to retrieve serial number".format(i)):
continue
self.expect(re.match(REGEX_SERIAL_NUMBER, serial), "Module {}: Serial number appears to be incorrect".format(i))
self.assert_expectations()

def test_get_system_eeprom_info(self, duthost, localhost, platform_api_conn):
"""
Test that we can retrieve sane system EEPROM info from each module of the DUT via the platform API
Expand Down

0 comments on commit 0b312e6

Please sign in to comment.