Skip to content

Commit 1dac841

Browse files
taoyl-msShuotian Cheng
authored andcommitted
test: Fix LLDP Test (#51)
Use overlay minigraph instead of underlay Add minigraph files Fix the issue that an empty LLDP fact will not cause test failure Enable the verification on LLDP neighbor
1 parent 2bc5ab0 commit 1dac841

12 files changed

Lines changed: 2184 additions & 55 deletions

File tree

ansible/README.test.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
# Placeholder for SONiC tests
1+
# ansible playbooks for SONiC testing
2+
3+
## Requirements
4+
- A testbed needed to be set up before hand. See [Testbed Readme](README_testbed.md) for more information.
5+
-- Depending on the test, either a PTF testbed or a VM set testbed might be required.
6+
7+
## Run Tests
8+
- Replace {DUT_NAME} in each command line with the host name of switch under test.
9+
10+
### NTP Test
11+
```
12+
ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME} --become --tags ntp
13+
```
14+
15+
### Syslog Test
16+
```
17+
ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME} --become --tags syslog
18+
```
19+
20+
### SNMP Tests
21+
```
22+
ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME} --become --tags snmp,snmp_cpu,snmp_interfaces
23+
```
24+
25+
### LLDP Test
26+
```
27+
ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME},lldp_neighbors --become --tags lldp
28+
```
29+
- Required switch connected to a VM set testbed.

ansible/README.testbed.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,22 +260,23 @@ sent to the vlan interface. It allows us to inject packets from the PTF host to
260260
### Deploy testbed with one VM set
261261
1. clone sonic-mgmt repo to local directory
262262
2. Edit 'ansible/veos' file. Put ip address of your server after 'ansible_host='
263-
3. Edit 'ansible/group_vars/vm_host'. Put your credentials to reach the server
264-
4. Check, that you can reach the server by running command 'ansible -i veos -m ping vm_host_1' from ansible directory. The output should contain 'pong'
265-
5. Edit 'ansible/group_vars/vm_host/main.yml'.
263+
3. Edit 'ansible/group_vars/eos/eos.yml' file. Put your internal snmp community string after 'snmp_rocommunity:'.
264+
4. Edit 'ansible/group_vars/vm_host'. Put your credentials to reach the server
265+
5. Check, that you can reach the server by running command 'ansible -i veos -m ping vm_host_1' from ansible directory. The output should contain 'pong'
266+
6. Edit 'ansible/group_vars/vm_host/main.yml'.
266267
* 'root_path': path where VMs virtual disks resides
267268
* 'vm_images_url': URL where VM images could be downloaded
268269
* 'cd_image_filename': filename of cd image of veos
269270
* 'hdd_image_filename': filename of hdd image of veos
270271
* 'http_proxy': your http_proxy
271272
* 'http_proxy': your https_proxy
272-
6. Edit 'ansible/host_vars/STR-ACS-SERV-01.yml'. It contains settings for STR-ACS-SERV-01. STR-ACS-SERV-02 contains similar settings which are applied to STR-ACS-SERV-02
273+
7. Edit 'ansible/host_vars/STR-ACS-SERV-01.yml'. It contains settings for STR-ACS-SERV-01. STR-ACS-SERV-02 contains similar settings which are applied to STR-ACS-SERV-02
273274
* 'mgmt_gw': ip address of gateway for management interfaces of VM. See 3.2
274275
* 'vm_X_enabled': true, if you want to run X vm set
275276
* 'vm_X_vlan_base': vlan number which is used for connection to first port of DUT.
276277
* 'vlans': list of vlan offsets for the VM FP ports. For example: if vlans equal to "5,6" it means that the VM frontpanel port 0 will be connected to vlan {{ vm_X_vlan_base + 5 - 1 }} and VM frontpanel port 1 will be connected to vlan {{ vm_X_vlan_base + 6 - 1 }}
277-
7. Edit 'ansible/minigraph/*.xml' files. You need to adjust following xml nodes to settings of your network:
278+
8. Edit 'ansible/minigraph/*.xml' files. You need to adjust following xml nodes to settings of your network:
278279
* DeviceMiniGraph/DpgDec/DeviceDataPlaneInfo/ManagementIPInterfaces/ManagementIPInterface/Prefix/IPPrefix
279280
* DeviceMiniGraph/DpgDec/DeviceDataPlaneInfo/ManagementIPInterfaces/ManagementIPInterface/PrefixStr
280-
8. Start testbed with command 'ANSIBLE_SCP_IF_SSH=y ansible-playbook -i veos start_vm_sets.yml --limit server_1 -e vm_set_1=true'
281-
9. Stop testbed with command 'ANSIBLE_SCP_IF_SSH=y ansible-playbook -i veos stop_vm_sets.yml --limit server_1 -e vm_set_1=true'
281+
9. Start testbed with command 'ANSIBLE_SCP_IF_SSH=y ansible-playbook -i veos start_vm_sets.yml --limit server_1 -e vm_set_1=true'
282+
10. Stop testbed with command 'ANSIBLE_SCP_IF_SSH=y ansible-playbook -i veos stop_vm_sets.yml --limit server_1 -e vm_set_1=true'

ansible/group_vars/eos/eos.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# snmp variables
2+
snmp_rocommunity: public
3+

ansible/library/lldp_facts.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def __init__(self,dotprefix=False):
9494

9595
# From LLDP-MIB
9696
self.lldp_rem_port_id = dp + "1.0.8802.1.1.2.1.4.1.1.7"
97+
self.lldp_rem_port_desc = dp + "1.0.8802.1.1.2.1.4.1.1.8"
9798
self.lldp_rem_sys_desc = dp + "1.0.8802.1.1.2.1.4.1.1.10"
9899
self.lldp_rem_sys_name = dp + "1.0.8802.1.1.2.1.4.1.1.9"
99100
self.lldp_rem_chassis_id = dp + "1.0.8802.1.1.2.1.4.1.1.5"
@@ -207,6 +208,7 @@ def main():
207208
snmp_auth,
208209
cmdgen.UdpTransportTarget((host, 161)),
209210
cmdgen.MibVariable(p.lldp_rem_port_id,),
211+
cmdgen.MibVariable(p.lldp_rem_port_desc,),
210212
cmdgen.MibVariable(p.lldp_rem_sys_desc,),
211213
cmdgen.MibVariable(p.lldp_rem_sys_name,),
212214
cmdgen.MibVariable(p.lldp_rem_chassis_id,),
@@ -217,6 +219,7 @@ def main():
217219

218220
lldp_rem_sys = dict()
219221
lldp_rem_port_id = dict()
222+
lldp_rem_port_desc = dict()
220223
lldp_rem_chassis_id = dict()
221224
lldp_rem_sys_desc = dict()
222225

@@ -243,6 +246,9 @@ def main():
243246
if v.lldp_rem_port_id in current_oid:
244247
lldp_rem_port_id[if_name] = current_val
245248
continue
249+
if v.lldp_rem_port_desc in current_oid:
250+
lldp_rem_port_desc[if_name] = current_val
251+
continue
246252
if v.lldp_rem_chassis_id in current_oid:
247253
lldp_rem_chassis_id[if_name] = current_val
248254
continue
@@ -254,6 +260,7 @@ def main():
254260

255261
for intf in lldp_rem_sys.viewkeys():
256262
lldp_data[intf] = {'neighbor_sys_name': lldp_rem_sys[intf],
263+
'neighbor_port_desc': lldp_rem_port_desc[intf],
257264
'neighbor_port_id': lldp_rem_port_id[intf],
258265
'neighbor_sys_desc': lldp_rem_sys_desc[intf],
259266
'neighbor_chassis_id': lldp_rem_chassis_id[intf]}

0 commit comments

Comments
 (0)