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
77 changes: 72 additions & 5 deletions ansible/roles/test/tasks/bgp_speaker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,45 @@
- {file_name: "config_3.ini", local_ip: '{{vlan_ips[0]}}', port_num: '7000'}
delegate_to: "{{ptf_host}}"

- set_fact: addr_family='ipv4'
when: addr_family is not defined

- set_fact: portchannel_name="{{minigraph_portchannel_interfaces[0].attachto}}"
when: addr_family == 'ipv6'

- set_fact: portchannel_peer="{%for p in minigraph_portchannel_interfaces%}{%if p['attachto']==portchannel_name and p['peer_addr']|ipv6%}{{p['peer_addr']}}{%endif %}{%endfor%}"
when: addr_family == 'ipv6'

- set_fact: mux_ip_1="{% if addr_family=='ipv4' %}{{vlan_ips[1]}}{% else %}{{portchannel_peer}}{% endif %}"
- set_fact: mux_ip_2="{% if addr_family=='ipv4' %}{{vlan_ips[2]}}{% else %}{{portchannel_peer}}{% endif %}"

- name: Set the prefix to be announced
set_fact: announce_prefix="10.10.10.10/26"
set_fact:
announce_prefix: "{% if addr_family=='ipv4' %}10.10.10.0/26{% else %}2010::/126{% endif %}"

- name: Generate routes to be announced
template: src=roles/test/templates/exabgp/routes.j2 dest={{exabgp_dir}}/routes
with_items:
- {speaker_ip: '{{vlan_ips[0]}}', mux_ip_1: '{{vlan_ips[1]}}', mux_ip_2: '{{vlan_ips[2]}}', port_num_1: '5000', port_num_2: '6000', port_num_3: '7000'}
- {speaker_ip: '{{vlan_ips[0]}}',
mux_ip_1: "{{mux_ip_1}}",
mux_ip_2: "{{mux_ip_2}}",
port_num_1: '5000',
port_num_2: '6000',
port_num_3: '7000'}
delegate_to: "{{ptf_host}}"

- name: Generate start file for exabgp instances
template: src=roles/test/templates/exabgp/start.j2 dest={{exabgp_dir}}/{{item.file_name}} mode=u+rwx
with_items:
- {file_name: 'start.sh', config_file_1: 'config_1.ini', config_file_2: 'config_2.ini', config_file_3: 'config_3.ini', phy_ip: '{{vlan_ips[0]}}', logical_ip_1: '{{speaker_ips[0]}}', logical_ip_2: '{{speaker_ips[1]}}'}
- {file_name: 'start.sh',
config_file_1: 'config_1.ini',
config_file_2: 'config_2.ini',
config_file_3: 'config_3.ini',
phy_ip: '{{vlan_ips[0]}}',
logical_ip_1: '{{speaker_ips[0]}}',
logical_ip_2: '{{speaker_ips[1]}}',
mux_ip_1: "{{mux_ip_1}}",
mux_ip_2: "{{mux_ip_2}}"}
delegate_to: "{{ptf_host}}"

- name: Kill exabgp instances if existing
Expand All @@ -100,13 +126,17 @@
shell: sh {{exabgp_dir}}/start.sh
delegate_to: "{{ptf_host}}"

- pause:
seconds: 5
prompt: "make sure dynamic bgp neighbors appear"

- name: Announce the routes
shell: python {{helper_dir}}/announce_routes.py {{exabgp_dir}}/routes >/dev/null 2>&1 &
delegate_to: "{{ptf_host}}"

- pause:
seconds: 10
prompt: "make sure dynamic bgp neighbors appear"
seconds: 30
prompt: "make sure routes announced to dynamic bgp neighbors"

- name: Gather bgp facts from bgp container
bgp_facts:
Expand All @@ -121,6 +151,43 @@
assert: {that: "'{{ bgp_neighbors[item]['accepted prefixes'] }}' == '1'"}
with_items: "['{{speaker_ips[0].split('/')[0]}}', '{{speaker_ips[1].split('/')[0]}}', '{{vlan_ips[0].split('/')[0]}}'] "

# Send packets to verify that accepted prefixes are correctly applied in HW.
# PTF FIB test is used to send the packets.

- name: Generate route-port map information
template: src=roles/test/templates/bgp_speaker_route.j2
dest=/tmp/bgp_speaker_route.txt
connection: local

- name: Copy the bgp_speaker_route to ptf container
copy: src=/tmp/bgp_speaker_route.txt dest=/root
delegate_to: "{{ptf_host}}"

- name: Copy the test to ptf container
copy: src=roles/test/files/ptftests dest=/root
delegate_to: "{{ ptf_host }}"

- set_fact: ipv4=true
when: addr_family == 'ipv4'

- set_fact: ipv6=true
when: addr_family == 'ipv6'

- name: "Start PTF runner"
include: ptf_runner.yml
vars:
ptf_test_name: FIB test
ptf_test_dir: ptftests
ptf_test_path: fib_test.FibTest
ptf_platform: remote
ptf_test_params:
- testbed_type='{{testbed_type}}'
- router_mac='{{ansible_Ethernet0['macaddress']}}'
- fib_info='/root/bgp_speaker_route.txt'
- ipv4={{ ipv4|default(false) }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default true for ipv4?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and default value is set to IPv4 in line 80.

- ipv6={{ ipv6|default(false) }}
ptf_extra_options: "--relax --debug info --log-file /tmp/bgp_speaker_test.FibTest.log"

- name: Kill exabgp instances
shell: pkill exabgp
delegate_to: "{{ptf_host}}"
Expand Down
8 changes: 8 additions & 0 deletions ansible/roles/test/templates/bgp_speaker_route.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% if addr_family == 'ipv6' %}
{{announce_prefix}} [{% for member in minigraph_portchannels[portchannel_name].members %}{{ '%d' % minigraph_port_indices[member]}}{% if not loop.last %} {% endif %}{% endfor %}]{% if not loop.last %} {% endif %}

{% elif addr_family == 'ipv4' %}
0.0.0.0/0 {% for portchannel, v in minigraph_portchannels.iteritems() %}[{% for member in v.members %}{{ '%d' % minigraph_port_indices[member]}}{% if not loop.last %} {% endif %}{% endfor %}]{% if not loop.last %} {% endif %}{% endfor %}

{{announce_prefix}} {% for vlan, v in minigraph_vlans.iteritems() %}{% for member in v.members %}[{{ '%d' % minigraph_port_indices[member]}}]{% if not loop.last %} {% endif %}{% endfor %}{% if not loop.last %} {% endif %}{% endfor %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the nexthop vlan or portchannel?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Portchannel. Fixed it.

Copy link
Contributor

@sihuihan88 sihuihan88 Sep 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't sound right to me. We have announced the next-hop of the route as VLAN. Shouldn't expect packets on Portchannels. We might need to change both ipv4 and ipv6 to VLAN here.

I tested it locally, I think we also need to config the ips of two mux on PTF host to make sure it will not use default route.

one example: In in exabgp/start.sh template, to config one mux_ip: ifconfig eth{{ '%d' % (minigraph_vlans[minigraph_vlan_interfaces[0]['attachto']]['members'][1] | replace("Ethernet", "") | int / 4)}} {{item.mux_ip_1}}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{% endif %}
9 changes: 8 additions & 1 deletion ansible/roles/test/templates/exabgp/start.j2
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
ifconfig eth{{ '%d' % (minigraph_port_indices[minigraph_vlans[minigraph_vlan_interfaces[0]['attachto']]['members'][0]])}} {{item.phy_ip}}
ifconfig eth{{ '%d' % (minigraph_port_indices[minigraph_vlans[minigraph_vlan_interfaces[0]['attachto']]['members'][0]])}}:0 {{item.logical_ip_1}}
ifconfig eth{{ '%d' % (minigraph_port_indices[minigraph_vlans[minigraph_vlan_interfaces[0]['attachto']]['members'][0]])}}:1 {{item.logical_ip_2}}

ifconfig eth{{ '%d' % (minigraph_port_indices[minigraph_vlans[minigraph_vlan_interfaces[0]['attachto']]['members'][1]])}} {{item.mux_ip_1}}
ping {{minigraph_vlan_interfaces[0]['addr']}} -I eth{{ '%d' % (minigraph_port_indices[minigraph_vlans[minigraph_vlan_interfaces[0]['attachto']]['members'][1]])}} -c 4 >/dev/null 2>&1 &

ifconfig eth{{ '%d' % (minigraph_port_indices[minigraph_vlans[minigraph_vlan_interfaces[0]['attachto']]['members'][2]])}} {{item.mux_ip_2}}
ping {{minigraph_vlan_interfaces[0]['addr']}} -I eth{{ '%d' % (minigraph_port_indices[minigraph_vlans[minigraph_vlan_interfaces[0]['attachto']]['members'][2]])}} -c 4 >/dev/null 2>&1 &

ip route flush {{minigraph_lo_interfaces[0]['addr']}}/{{minigraph_lo_interfaces[0]['prefixlen']}}
ip route add {{minigraph_lo_interfaces[0]['addr']}}/{{minigraph_lo_interfaces[0]['prefixlen']}} via {{ minigraph_vlan_interfaces[0]['addr']}}
env exabgp.daemon.user=root exabgp {{exabgp_dir}}/{{item.config_file_1}} >/dev/null 2>&1 &
env exabgp.daemon.user=root exabgp {{exabgp_dir}}/{{item.config_file_2}} >/dev/null 2>&1 &
env exabgp.daemon.user=root exabgp {{exabgp_dir}}/{{item.config_file_3}} >/dev/null 2>&1 &
env exabgp.daemon.user=root exabgp {{exabgp_dir}}/{{item.config_file_3}} >/dev/null 2>&1 &