diff --git a/ansible/roles/test/tasks/lldp.yml b/ansible/roles/test/tasks/lldp.yml index 050edd95a33..1f07e1cddf1 100644 --- a/ansible/roles/test/tasks/lldp.yml +++ b/ansible/roles/test/tasks/lldp.yml @@ -1,61 +1,4 @@ -# Gather minigraph facts -- name: Gathering minigraph facts about the device - minigraph_facts: - host: "{{ inventory_hostname }}" - -- name: Print neighbors in minigraph - debug: msg="{{ minigraph_neighbors }}" - -- name: find minigraph lldp neighbor - set_fact: - minigraph_lldp_nei: "{{ minigraph_lldp_nei|default({}) | combine({ item.key : item.value}) }}" - when: "'server' not in item.value['name'] | lower" - with_dict: minigraph_neighbors - -- name: Gather information from LLDP - lldp: +- name: run test + include: roles/test/tasks/pytest_runner.yml vars: - ansible_shell_type: docker - ansible_python_interpreter: docker exec -i lldp python - -- name: Print LLDP information - debug: msg="{{ lldp }}" - -- name: Verify LLDP information is available on most interfaces - assert: { that: "{{ lldp|length }} > {{ minigraph_lldp_nei|length * 0.8 }}"} - -- name: Compare the LLDP neighbor name with minigraph neigbhor name (exclude the management port) - assert: { that: "'{{ lldp[item]['chassis']['name'] }}' == '{{ minigraph_lldp_nei[item]['name'] }}'" } - with_items: "{{ lldp.keys() }}" - when: item != "eth0" - -- name: Compare the LLDP neighbor interface with minigraph neigbhor interface (exclude the management port) - assert: { that: "'{{ lldp[item]['port']['ifname'] }}' == '{{ minigraph_neighbors[item]['port'] }}'" } - with_items: "{{ lldp.keys() }}" - when: item != "eth0" - -- block: - - name: Obtain the system description of the DUT chassis - shell: "docker exec -i lldp lldpcli show chassis | grep \"SysDescr:\" | sed -e 's/^\\s*SysDescr:\\s*//g'" - register: result - - - name: Store system description of the DUT chassis as a fact - set_fact: - dut_system_description: "{{ result.stdout }}" - -###TODO: fix this lldp_neighbor validation, this part is not running -- name: Iterate through each LLDP neighbor and verify the information received by neighbor is correct - add_host: - name: "{{ lldp[item]['chassis']['mgmt-ip'] }}" - groups: "lldp_neighbors,eos" - neighbor_interface: "{{ lldp[item]['port']['ifname'] }}" - dut_interface: "{{ item }}" - hname: "{{ lldp[item]['chassis']['mgmt-ip'] }}" - dut_chassis_id: "0x{{ ansible_eth0['macaddress'] | replace(':', '') }}" - dut_hostname: "{{ inventory_hostname }}" - dut_port_alias: "{{ minigraph_ports[item]['alias'] }}" - dut_port_description: "{{ minigraph_neighbors[item]['name'] }}:{{ minigraph_neighbors[item]['port'] }}" - dut_system_description: "{{ dut_system_description }}" - with_items: "{{ lldp.keys() }}" - when: item != "eth0" - + test_node: test_lldp.py diff --git a/ansible/roles/test/tasks/lldp_neighbor.yml b/ansible/roles/test/tasks/lldp_neighbor.yml deleted file mode 100644 index 54b8db32963..00000000000 --- a/ansible/roles/test/tasks/lldp_neighbor.yml +++ /dev/null @@ -1,25 +0,0 @@ -- name: Gather LLDP information from all neighbors by performing a SNMP walk - lldp_facts: - host: "{{ hname }}" - version: "v2c" - community: "{{ snmp_rocommunity }}" - connection: local - -- name: Print LLDP facts from neighbors - debug: msg="{{ ansible_lldp_facts }}" - -- name: Verify the published DUT system name field is correct - assert: {that: "'{{ ansible_lldp_facts[neighbor_interface]['neighbor_sys_name'] }}' == '{{ dut_hostname }}'"} - -# FIXME: use more strict assertion -- name: Verify the published DUT chassis id field is not empty - assert: {that: "'{{ ansible_lldp_facts[neighbor_interface]['neighbor_chassis_id'] }}' == '{{ dut_chassis_id }}'"} - -- name: Verify the published DUT system description field is correct - assert: {that: "'{{ ansible_lldp_facts[neighbor_interface]['neighbor_sys_desc'] }}' == '{{ dut_system_description }}'"} - -- name: Verify the published DUT port id field is correct - assert: {that: "'{{ ansible_lldp_facts[neighbor_interface]['neighbor_port_id'] }}' == '{{ dut_port_alias }}'"} - -- name: Verify the published DUT port description field is correct - assert: {that: "'{{ ansible_lldp_facts[neighbor_interface]['neighbor_port_desc'] }}' == '{{ dut_port_description }}'"}