diff --git a/ansible/README.test.md b/ansible/README.test.md index 9abc67b7d7b..4d3e7ed6532 100644 --- a/ansible/README.test.md +++ b/ansible/README.test.md @@ -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. + diff --git a/ansible/roles/test/tasks/bgp_fact.yml b/ansible/roles/test/tasks/bgp_fact.yml new file mode 100644 index 00000000000..4bd4a7e1956 --- /dev/null +++ b/ansible/roles/test/tasks/bgp_fact.yml @@ -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 + diff --git a/ansible/roles/test/tasks/sonic.yml b/ansible/roles/test/tasks/sonic.yml index b3a071d57de..f35ca2befcb 100644 --- a/ansible/roles/test/tasks/sonic.yml +++ b/ansible/roles/test/tasks/sonic.yml @@ -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 @@ -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" @@ -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