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

[snmp] Add test cases for SONiC physical entity MIB feature #2379

Merged
merged 14 commits into from
Dec 2, 2020

Conversation

Junchao-Mellanox
Copy link
Contributor

Description of PR

Summary:
Add test cases for SONiC physical entity MIB feature

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Approach

What is the motivation for this PR?

There is no regression test case for physical entity MIB before, and we create a few new test cases to cover the existing/new MIB objects.

How did you do it?

  1. Adjust snmp_facts.py to support new MIB objects
  2. Add test case to verify transceiver related entities
  3. Add test case to verify PSU related entities
  4. Add test case to verify fan related entities
  5. Add test case to verify thermal related entities
  6. Add test case to verify PSU/fan remove

How did you verify/test it?

Run the new regression test cases

Any platform specific information?

N/A

Supported testbed topology if it's a new test case?

N/A

Documentation

@Junchao-Mellanox
Copy link
Contributor Author

retest vsimage please

@wangxin
Copy link
Collaborator

wangxin commented Oct 23, 2020

retest this please

@lguohan
Copy link
Contributor

lguohan commented Oct 24, 2020

can you please add the test to kvmtest.sh?

@Junchao-Mellanox
Copy link
Contributor Author

kvmtest.sh

Done.

@Junchao-Mellanox
Copy link
Contributor Author

retest vsimage please

2 similar comments
@Junchao-Mellanox
Copy link
Contributor Author

retest vsimage please

@Junchao-Mellanox
Copy link
Contributor Author

retest vsimage please

@liat-grozovik
Copy link
Collaborator

retest vsimage please

@liat-grozovik
Copy link
Collaborator

@Junchao-Mellanox kindly reminder that this feature will go only to master towards 202012.
As of that we need a way to run snmp test on 201911 which has no such capability. Should it work or need to find a solution to detect if the version expected to support this extended mib?

@Junchao-Mellanox
Copy link
Contributor Author

Hi @liat-grozovik , we can do this in sonic-tool. In sonic-tool, we can disable cases according to the image branch name. So once we merge this test case to our local repo, we need add the case to sonic-tool and disable it on 201911 branch in snmp.cases file.

@Junchao-Mellanox
Copy link
Contributor Author

retest vsimage please

1 similar comment
@keboliu
Copy link
Contributor

keboliu commented Nov 4, 2020

retest vsimage please

@keboliu
Copy link
Contributor

keboliu commented Nov 4, 2020

retest this please

@Junchao-Mellanox
Copy link
Contributor Author

retest vsimage please

3 similar comments
@Junchao-Mellanox
Copy link
Contributor Author

retest vsimage please

@Junchao-Mellanox
Copy link
Contributor Author

retest vsimage please

@Junchao-Mellanox
Copy link
Contributor Author

retest vsimage please

@Junchao-Mellanox
Copy link
Contributor Author

retest vsimage please

SENSOR_TYPE_PORT_TX_BIAS + 4,
SENSOR_TYPE_VOLTAGE]

# Redis Constants
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redis [](start = 2, length = 5)

Suggest remove Redis #Closed

assert fan_snmp_fact['entPhysMfgName'] == ''
assert fan_snmp_fact['entPhysModelName'] == '' if is_null_str(fan_info['model']) else fan_info['model']
assert fan_snmp_fact['entPhysIsFRU'] == REPLACEABLE if fan_info[
'is_replaceable'] == 'True' else NOT_REPLACEABLE
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'is_replaceable' [](start = 67, length = 16)

Line breaking at a weird position. #Closed

"""
keys = redis_get_keys(duthost, STATE_DB, PSU_KEY_TEMPLATE.format('*'))
if not keys:
pytest.skip('PSU information not exists in DB, skipping this test')
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not exists [](start = 37, length = 10)

does not exist #Closed

"""
keys = redis_get_keys(duthost, STATE_DB, PSU_KEY_TEMPLATE.format('*'))
if not keys:
pytest.skip('PSU information not exists in DB, skipping this test')
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest.skip [](start = 8, length = 11)

There are many pytest.skip(). Seems are a valid failure case.
Do you skip just for backward-compatible? If yes, I think this is not a good method. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I skip this for vsimage test. I found this testcase will be ran in vsimage, and there is no PSU information in DB.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wangxin What is best practice to skip test case in vsimage test?


In reply to: 532159260 [](ancestors = 532159260)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can mark the test case like below to specify that this test case is only applicable for physical testbed, not for vsimage.

@pytest.mark.device_type('physical')
def test_xxx

assert sensor_snmp_fact['entPhysContainedIn'] == psu_oid
assert sensor_snmp_fact['entPhysClass'] == PHYSICAL_CLASS_SENSOR
assert sensor_snmp_fact['entPhyParentRelPos'] == sensor_tuple[1]
assert sensor_snmp_fact['entPhysName'] == '{} for {}'.format(sensor_tuple[0], psu_name)
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'{} for {}'.format(sensor_tuple[0], psu_name) [](start = 50, length = 45)

Appear twice, use a variable? #Closed

for item in psu_status:
if not item['psu_on']:
psu_controller.turn_on_psu(item["psu_id"])
time.sleep(5)
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time.sleep(5) [](start = 12, length = 13)

What if no sleep? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PSU may take a few seconds to power on, so I add a sleep here, this code is similar with some test cases in platform tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to sleep only once after all PSU turned on?


In reply to: 532159395 [](ancestors = 532159395)

:param pattern: Redis key pattern
:return: A list of key name in string
"""
cmd = 'redis-cli --raw -n {} KEYS \"{}\"'.format(db_id, pattern)
Copy link
Contributor

@qiluo-msft qiluo-msft Nov 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redis-cli [](start = 11, length = 9)

redis-cli will not aware of multi-DB or multi-namespace. Use sonic-db-cli #Closed

Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As comments

@Junchao-Mellanox
Copy link
Contributor Author

Hi @wangxin , it seems the test was not skipped in vsimage after adding the pytest mark. I see following error in the test result:

11:08:57      @pytest.mark.device_type('physical')
11:08:57      def test_fan_info(duthost, snmp_physical_entity_info):
11:08:57          """
11:08:57          Verify fan information in physical entity mib with redis database
11:08:57          :param duthost: DUT host object
11:08:57          :param snmp_physical_entity_info: Physical entity information from snmp fact
11:08:57          :return:
11:08:57          """
11:08:57          keys = redis_get_keys(duthost, STATE_DB, FAN_KEY_TEMPLATE.format('*'))
11:08:57  >       assert keys, 'Fan information does not exist in DB'
11:08:57  E       AssertionError: Fan information does not exist in DB

@wangxin
Copy link
Collaborator

wangxin commented Dec 1, 2020

If all the test cases in this test script need physical testbed, then it should not be added to the list in kvmtest.sh.

@qiluo-msft qiluo-msft merged commit 92cb763 into sonic-net:master Dec 2, 2020
@Junchao-Mellanox Junchao-Mellanox deleted the phy-mibs-snmp branch December 3, 2020 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants