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
79 changes: 79 additions & 0 deletions ansible/roles/test/tasks/neighbour-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# docker exec -it syncd sx_api_port_speed_set_100G.py
# Test run example:
# ansible-playbook -i inventory --limit arc-switch1027 test_sonic.yml -b -e "ptf_host=ptf-1" --tags neighbour

- set_fact:
host_if: eth0
dut_if: Ethernet0
host_ip: 20.0.0.2
dut_ip: 20.0.0.1
nei_mac1: 00:C0:CA:C0:1A:05
nei_mac2: 00:C0:CA:C0:1A:06

- name: Change DUT interface IP to test IP address
become: yes
command: /sbin/ifconfig {{ dut_if }} {{ dut_ip }} netmask 255.255.255.0

- name: Change host interface IP to test IP address
become: yes
command: /sbin/ifconfig {{ host_if }} {{ host_ip }} netmask 255.255.255.0
delegate_to: "{{ ptf_host }}"

- name: Get host MAC
become: true
shell: ifconfig {{ host_if }} | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'
register: host_mac
failed_when: host_mac.rc != 0
delegate_to: "{{ ptf_host }}"

- name: Set host MAC to pretend neighbour #1
become: true
shell: ifconfig {{ host_if }} down; ifconfig {{ host_if }} hw ether {{ nei_mac1 }}; ifconfig {{ host_if }} up
register: set1
failed_when: set1.rc != 0
delegate_to: "{{ ptf_host }}"

- name: Ping DUT to populate neighbour #1
become: true
shell: ping {{ dut_ip }} -c 3 -I {{ host_if }}
register: ping1
failed_when: ping1.rc != 0
delegate_to: "{{ ptf_host }}"

- name: Get the SONiC DB key holding neighbour MAC for {{ host_ip }}
become: true
shell: docker exec database redis-cli -n 1 KEYS ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY* | grep {{ host_ip }}
register: neighbour_key
failed_when: neighbour_key.rc != 0

- name: Check neighbour MAC1 on DUT. Should be {{ nei_mac1 }}
become: true
shell: docker exec database redis-cli -n 1 HGET '{{ neighbour_key.stdout }}' 'SAI_NEIGHBOR_ATTR_DST_MAC_ADDRESS'
register: neighbour_mac
failed_when: neighbour_mac.stdout != "{{ nei_mac1 }}"

- name: Set host MAC to pretend neighbour #2
become: true
shell: ifconfig {{ host_if }} down; ifconfig {{ host_if }} hw ether {{ nei_mac2 }}; ifconfig {{ host_if }} up
register: set2
failed_when: set2.rc != 0
delegate_to: "{{ ptf_host }}"

- name: Ping DUT to populate neighbour #2
become: true
shell: ping {{ dut_ip }} -c 3 -I {{ host_if }}
register: ping2
failed_when: ping2.rc != 0
delegate_to: "{{ ptf_host }}"

- name: Get the SONiC DB key holding neighbour MAC for {{ host_ip }}
become: true
shell: docker exec database redis-cli -n 1 KEYS ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY* | grep {{ host_ip }}
register: neighbour_key
failed_when: neighbour_key.rc != 0

- name: Check neighbour MAC2 on DUT. Should be {{ nei_mac2 }}
become: true
shell: docker exec database redis-cli -n 1 HGET '{{ neighbour_key.stdout }}' 'SAI_NEIGHBOR_ATTR_DST_MAC_ADDRESS'
register: neighbour_mac
failed_when: neighbour_mac.stdout != "{{ nei_mac2 }}"
4 changes: 4 additions & 0 deletions ansible/roles/test/tasks/sonic.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
- name: Neighbor mac change test
include: neighbour-mac.yml
tags: neighbour

- name: Test LLDP
include: lldp.yml
tags: lldp
Expand Down