sonic-net / sonic-mgmt

Configuration management examples for SONiC
Other
201 stars 727 forks source link

[masic][pytest fails] fix test snmp cpu test #5121

Open smaheshm opened 2 years ago

smaheshm commented 2 years ago

Description Pipelines - Run NightlyTest_vmsvc1-t1-nmasic-acs-1.201911_ptest-azp_68453_20220128.1 (azure.com)

pytest snmp/test_snmp_cpu.py --testbed=vmsvc1-t1-nmasic-acs-1 --inventory=../ansible/strsvc,../ansible/veos --testbed_file=../ansible/testbed.csv --host-pattern=svcstr-nmasic-acs-1 --module-path=../ansible/library -s -k test_snmp_cpu

    TODO: abstract the snmp OID by SKU
    """
    duthost = duthosts[enum_rand_one_per_hwsku_hostname]

    hostip = duthost.host.options['inventory_manager'].get_host(duthost.hostname).vars['ansible_host']
    host_facts = duthost.setup()['ansible_facts']
    if host_facts.has_key("ansible_processor_vcpus"):
        host_vcpus = int(host_facts['ansible_processor_vcpus'])
    else:
        res = duthost.shell("nproc")
        host_vcpus = int(res['stdout'])

    logger.info("found {} cpu on the dut".format(host_vcpus))

    # Gather facts with SNMP version 2
    snmp_facts = get_snmp_facts(localhost, host=hostip, version="v2c", community=creds_all_duts[duthost]["snmp_rocommunity"], is_dell=True, wait=True)['ansible_facts']

    assert int(snmp_facts['ansible_ChStackUnitCpuUtil5sec'])

    try:
        for i in range(host_vcpus):
            duthost.shell("nohup yes > /dev/null 2>&1 & sleep 1")

        # Wait for load to reflect in SNMP
        time.sleep(20)

        # Gather facts with SNMP version 2
      snmp_facts = get_snmp_facts(localhost, host=hostip, version="v2c", community=creds_all_duts[duthost]["snmp_rocommunity"], is_dell=True, wait=True)['ansible_facts']

snmp/test_snmp_cpu.py:51:


localhost = <tests.common.devices.local.Localhost object at 0x7f4aca1c1810>, host = u'10.206.144.15', version = 'v2c', community = 'msft', is_dell = True, module_ignore_errors = False, wait = True, timeout = 300, interval = 10

def get_snmp_facts(localhost, host, version, community, is_dell=False, module_ignore_errors=False,
                   wait=False, timeout=DEF_WAIT_TIMEOUT, interval=DEF_CHECK_INTERVAL):
    if not wait:
        return _get_snmp_facts(localhost, host, version, community, is_dell, module_ignore_errors)

    global global_snmp_facts

    pytest_assert(wait_until(timeout, interval, 0, _update_snmp_facts, localhost, host, version,
                           community, is_dell), "Timeout waiting for SNMP facts")

E Failed: Timeout waiting for SNMP facts

common/helpers/snmp_helpers.py:39: Failed

Steps to reproduce the issue: 1. 2. 3.

Describe the results you received:

Describe the results you expected:

Additional information you deem important:

**Output of `show version`:**

```
(paste your output here)
```

**Attach debug file `sudo generate_dump`:**

```
(paste your output here)
```
anamehra commented 1 year ago

Hi @SuvarnaMeenakshi , @abdosi , we are seeing this issue on CHassis as well. Is someone looking into this? I see get_snmp_facts has this param hardcoded is_dell = True. Is this correct?