Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions ansible/README.test.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,30 @@
## Run Tests
- Replace {DUT_NAME} in each command line with the host name of switch under test.

### NTP Test
### NTP test
```
ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME} --become --tags ntp
```

### Syslog Test
### Syslog test
```
ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME} --become --tags syslog
```

### SNMP Tests
### SNMP tests
```
ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME} --become --tags snmp,snmp_cpu,snmp_interfaces
```

### LLDP Test
### LLDP test
```
ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME},lldp_neighbors --become --tags lldp
```
- Required switch connected to a VM set testbed.

### BGP facts verification test
```
ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME} --become --tags bgp_fact
```
- Required switch connected to a VM set testbed.

31 changes: 31 additions & 0 deletions ansible/roles/test/tasks/bgp_fact.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Gather minigraph facts
- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
become: no
connection: local

- name: Print bgp neighbors in minigraph
debug: msg="{{ minigraph_bgp }}"

- name: Print AS numbers in minigraph
debug: msg="{{ minigraph_bgp_asn }}"

- name: Gather information from lldp
bgp_facts:

- name: Print bgp facts
debug: msg="{{ bgp_neighbors }}"

- name: Verify bgp sessions are established
assert: { that: "'{{ bgp_neighbors[item]['state'] }}' == 'established'" }
assert: { that: "'{{ bgp_neighbors[item]['local AS'] }}' == '{{ minigraph_bgp_asn }}'" }
with_items: bgp_neighbors.keys()

- name: Compare the bgp neighbors name with minigraph bgp neigbhors name
assert: { that: "'{{ item['name'] }}' == '{{ bgp_neighbors[item['addr']]['description'] }}'" }
with_items: minigraph_bgp

- name: Compare the bgp neighbors ASN with minigraph
assert: { that: "'{{ item['asn'] }}' == '{{ bgp_neighbors[item['addr']]['remote AS'] }}'" }
with_items: minigraph_bgp

12 changes: 8 additions & 4 deletions ansible/roles/test/tasks/sonic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
include: ntp.yml
tags: ntp

- name: Test Syslog Basic
include: syslog.yml
tags: syslog

- name: Test SNMP Basic
include: snmp.yml
tags: snmp
Expand All @@ -22,6 +26,10 @@
include: snmp/interfaces.yml
tags: snmp_interfaces

- name: BGP facts test
include: bgp_fact.yml
tags: bgp_fact

### when callng BGP flaps test, please add command line of which VMs host to test against
### -e "vmhost_num='01'"
- fail: msg="Please set vmhost_num variable"
Expand All @@ -32,10 +40,6 @@
include: bgp_flap.yml
tags: sync

- name: Test Syslog Basic
include: syslog.yml
tags: syslog

- name: Test Interface Flap from Neighbor
include: interface_up_down.yml
tags: link
Expand Down