Skip to content

py.test run failed for lldp_neighbour with KeyError: 'ansible_facts' #1948

@stephengzh

Description

@stephengzh
py.test lldp/test_lldp.py --testbed=vms-kvm-t0 --inventory=/var/johnar/sonic-mgmt/ansible/lab --testbed_file=../ansible/testbed.csv --host-pattern=vms-kvm-t0 --module-path=../ansible/library -v


platform linux2 -- Python 2.7.12, pytest-4.6.5, py-1.8.1, pluggy-0.13.1 -- /usr/bin/python
cachedir: .pytest_cache
ansible: 2.8.7
rootdir: /var/johnar/sonic-mgmt/tests, inifile: pytest.ini
plugins: repeat-0.8.0, xdist-1.28.0, ansible-2.2.2, forked-1.1.3
collected 2 items                                                                                                                                                                                     

lldp/test_lldp.py::test_lldp PASSED                                                                                                                                                             [ 50%]
lldp/test_lldp.py::test_lldp_neighbor FAILED                                                                                                                                                    [100%]

============================================================================================== FAILURES ===============================================================================================
_________________________________________________________________________________________ test_lldp_neighbor __________________________________________________________________________________________

duthost = <tests.common.devices.SonicHost object at 0x7f1896914b10>, localhost = <tests.common.devices.Localhost object at 0x7f1896914a50>
eos = {'bgp_gr_timer': 700, 'ceos_image_mount_dir': '/data/ceos', 'snmp_location': 'str', 'snmp_rocommunity': 'strcommunity'}, collect_techsupport = None

    def test_lldp_neighbor(duthost, localhost, eos, collect_techsupport):
        """ verify LLDP information on neighbors """
    
        mg_facts  = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
        res = duthost.shell("docker exec -i lldp lldpcli show chassis | grep \"SysDescr:\" | sed -e 's/^\\s*SysDescr:\\s*//g'")
        dut_system_description = res['stdout']
        lldp_facts = duthost.lldp()['ansible_facts']
        host_facts  = duthost.setup()['ansible_facts']
    
        config_facts  = duthost.config_facts(host=duthost.hostname, source="running")['ansible_facts']
        nei_meta = config_facts.get('DEVICE_NEIGHBOR_METADATA', {})
    
        for k, v in lldp_facts['lldp'].items():
            if k == 'eth0':
                # skip test on management interface
                continue
    
            try:
                hostip = v['chassis']['mgmt-ip']
            except:
                logger.info("Neighbor device {} does not sent management IP via lldp".format(v['chassis']['name']))
                hostip = nei_meta[v['chassis']['name']]['mgmt_addr']
    #   print localhost.lldp_facts
    #   print hostip
    #   print logger.info
    #   raise Exception, 'test "%s"'%
>           nei_lldp_facts = localhost.lldp_facts(host=hostip, version='v2c', community=eos['snmp_rocommunity'])['ansible_facts']
E           KeyError: 'ansible_facts'

lldp/test_lldp.py:70: KeyError
======================================================================================= short test summary info =======================================================================================
FAILED lldp/test_lldp.py::test_lldp_neighbor - KeyError: 'ansible_facts'

Actually, anyone knows the location about "localhost"? It only shows the KeyError: 'ansible facts', but it should better print the error exact position. For me, if not very very familiar with the pytest structure, I will feel difficult to locate the source of each parameter...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions