Skip to content

Commit 339a2df

Browse files
authored
Add bgp fact verification test (#53)
1 parent d88cbf5 commit 339a2df

File tree

3 files changed

+50
-8
lines changed

3 files changed

+50
-8
lines changed

ansible/README.test.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,30 @@
77
## Run Tests
88
- Replace {DUT_NAME} in each command line with the host name of switch under test.
99

10-
### NTP Test
10+
### NTP test
1111
```
1212
ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME} --become --tags ntp
1313
```
1414

15-
### Syslog Test
15+
### Syslog test
1616
```
1717
ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME} --become --tags syslog
1818
```
1919

20-
### SNMP Tests
20+
### SNMP tests
2121
```
2222
ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME} --become --tags snmp,snmp_cpu,snmp_interfaces
2323
```
2424

25-
### LLDP Test
25+
### LLDP test
2626
```
2727
ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME},lldp_neighbors --become --tags lldp
2828
```
2929
- Required switch connected to a VM set testbed.
30+
31+
### BGP facts verification test
32+
```
33+
ansible-playbook test_sonic.yml -i inventory --limit {DUT_NAME} --become --tags bgp_fact
34+
```
35+
- Required switch connected to a VM set testbed.
36+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Gather minigraph facts
2+
- name: Gathering minigraph facts about the device
3+
minigraph_facts: host={{ inventory_hostname }}
4+
become: no
5+
connection: local
6+
7+
- name: Print bgp neighbors in minigraph
8+
debug: msg="{{ minigraph_bgp }}"
9+
10+
- name: Print AS numbers in minigraph
11+
debug: msg="{{ minigraph_bgp_asn }}"
12+
13+
- name: Gather information from lldp
14+
bgp_facts:
15+
16+
- name: Print bgp facts
17+
debug: msg="{{ bgp_neighbors }}"
18+
19+
- name: Verify bgp sessions are established
20+
assert: { that: "'{{ bgp_neighbors[item]['state'] }}' == 'established'" }
21+
assert: { that: "'{{ bgp_neighbors[item]['local AS'] }}' == '{{ minigraph_bgp_asn }}'" }
22+
with_items: bgp_neighbors.keys()
23+
24+
- name: Compare the bgp neighbors name with minigraph bgp neigbhors name
25+
assert: { that: "'{{ item['name'] }}' == '{{ bgp_neighbors[item['addr']]['description'] }}'" }
26+
with_items: minigraph_bgp
27+
28+
- name: Compare the bgp neighbors ASN with minigraph
29+
assert: { that: "'{{ item['asn'] }}' == '{{ bgp_neighbors[item['addr']]['remote AS'] }}'" }
30+
with_items: minigraph_bgp
31+

ansible/roles/test/tasks/sonic.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
include: ntp.yml
1111
tags: ntp
1212

13+
- name: Test Syslog Basic
14+
include: syslog.yml
15+
tags: syslog
16+
1317
- name: Test SNMP Basic
1418
include: snmp.yml
1519
tags: snmp
@@ -22,6 +26,10 @@
2226
include: snmp/interfaces.yml
2327
tags: snmp_interfaces
2428

29+
- name: BGP facts test
30+
include: bgp_fact.yml
31+
tags: bgp_fact
32+
2533
### when callng BGP flaps test, please add command line of which VMs host to test against
2634
### -e "vmhost_num='01'"
2735
- fail: msg="Please set vmhost_num variable"
@@ -32,10 +40,6 @@
3240
include: bgp_flap.yml
3341
tags: sync
3442

35-
- name: Test Syslog Basic
36-
include: syslog.yml
37-
tags: syslog
38-
3943
- name: Test Interface Flap from Neighbor
4044
include: interface_up_down.yml
4145
tags: link

0 commit comments

Comments
 (0)