66ffa3dfa1d2e9337c1d4481e46a1e38e229f14b
[csit.git] / resources / libraries / robot / overlay / vxlan.robot
1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 *** Settings ***
15 | Library  | Collections
16 | Resource | resources/libraries/robot/shared/default.robot
17 | Resource | resources/libraries/robot/shared/interfaces.robot
18 | Resource | resources/libraries/robot/l2/l2_bridge_domain.robot
19 | Resource | resources/libraries/robot/l2/l2_xconnect.robot
20 | Library  | resources.libraries.python.InterfaceUtil
21 | Library  | resources.libraries.python.IPUtil
22 | Library  | resources.libraries.python.IPv4Util
23 | Library  | resources.libraries.python.IPv6Util
24 | Library  | resources.libraries.python.IPv4Setup
25 | Library  | resources.libraries.python.L2Util
26 | Library  | resources.libraries.python.NodePath
27
28 *** Keywords ***
29 | Configure IP addresses and neighbors on interfaces
30 | | [Documentation] | *Set IPv4 addresses on interfaces on DUTs.*
31 | | ... | If interface index is None then is determines with Get Interface Sw
32 | | ... | Index in this case it is required the interface to be present in
33 | | ... | topology dict. It also executes VPP IP Probe to determine MACs to IPs
34 | | ... | on DUTs.
35 | | ...
36 | | ... | _Set testcase variables with IP addresses and prefix length:_
37 | | ... | - ${dut1s_ip_address}
38 | | ... | - ${dut2s_ip_address}
39 | | ... | - ${duts_ip_address_prefix}
40 | | ...
41 | | [Arguments] | ${DUT1} | ${DUT1_INT_NAME} | ${DUT1_INT_INDEX}
42 | | ... | ${DUT2} | ${DUT2_INT_NAME} | ${DUT2_INT_INDEX}
43 | | Set Test Variable | ${dut1s_ip_address} | 172.16.0.1
44 | | Set Test Variable | ${dut2s_ip_address} | 172.16.0.2
45 | | Set Test Variable | ${duts_ip_address_prefix} | 24
46 | | ${DUT1_INT_KEY}= | Run Keyword If | ${DUT1_INT_INDEX} is None
47 | | ... | Get Interface by name | ${DUT1} | ${DUT1_INT_NAME}
48 | | ${DUT2_INT_KEY}= | Run Keyword If | ${DUT2_INT_INDEX} is None
49 | | ... | Get Interface by name | ${DUT2} | ${DUT2_INT_NAME}
50 | | ${DUT1_INT_INDEX}= | Run Keyword If | ${DUT1_INT_INDEX} is None
51 | | ... | Get Interface Sw Index | ${DUT1} | ${DUT1_INT_KEY}
52 | | ... | ELSE | Set Variable | ${DUT1_INT_INDEX}
53 | | ${DUT2_INT_INDEX}= | Run Keyword If | ${DUT2_INT_INDEX} is None
54 | | ... | Get Interface Sw Index | ${DUT2} | ${DUT2_INT_KEY}
55 | | ... | ELSE | Set Variable | ${DUT2_INT_INDEX}
56 | | ${DUT1_INT_MAC}= | Vpp Get Interface Mac | ${DUT1} | ${DUT1_INT_INDEX}
57 | | ${DUT2_INT_MAC}= | Vpp Get Interface Mac | ${DUT2} | ${DUT2_INT_INDEX}
58 | | Set Interface Address | ${DUT1} | ${DUT1_INT_INDEX}
59 | | ... | ${dut1s_ip_address} | ${duts_ip_address_prefix}
60 | | Set Interface Address | ${DUT2} | ${DUT2_INT_INDEX}
61 | | ... | ${dut2s_ip_address} | ${duts_ip_address_prefix}
62 | | Add IP Neighbor | ${DUT1} | ${DUT1_INT_INDEX} | ${dut2s_ip_address}
63 | | ... | ${DUT2_INT_MAC}
64 | | Add IP Neighbor | ${DUT2} | ${DUT2_INT_INDEX} | ${dut1s_ip_address}
65 | | ... | ${DUT1_INT_MAC}
66
67 | Add interfaces to L2BD
68 | | [Arguments] | ${DUT} | ${BID} | ${INTERFACE_1} | ${INTERFACE_2}
69 | | Vpp Add L2 Bridge Domain | ${DUT} | ${BID} | ${INTERFACE_1} | ${INTERFACE_2}
70
71 | Create vlan interfaces for VXLAN
72 | | [Documentation] | *Create VLAN subinterface on interfaces on DUTs with given
73 | | ... | VLAN ID.*
74 | | ...
75 | | ... | _Set testcase variables with name and index of created interfaces:_
76 | | ... | - ${dut1s_vlan_name}
77 | | ... | - ${dut1s_vlan_index}
78 | | ... | - ${dut2s_vlan_name}
79 | | ... | - ${dut2s_vlan_index}
80 | | ...
81 | | [Arguments] | ${VLAN} | ${DUT1} | ${INT1} | ${DUT2} | ${INT2}
82 | | ${INT1_NAME}= | Get interface name | ${DUT1} | ${INT1}
83 | | ${INT2_NAME}= | Get interface name | ${DUT2} | ${INT2}
84 | | ${dut1s_vlan_name} | ${dut1s_vlan_index}= | Create Vlan Subinterface
85 | | ... | ${DUT1} | ${INT1_NAME} | ${VLAN}
86 | | ${dut2s_vlan_name} | ${dut2s_vlan_index}= | Create Vlan Subinterface
87 | | ... | ${DUT2} | ${INT2_NAME} | ${VLAN}
88 | | Set Interface State | ${DUT1} | ${dut1s_vlan_index} | up
89 | | Set Interface State | ${DUT2} | ${dut2s_vlan_index} | up
90 | | Set Test Variable | ${dut1s_vlan_name}
91 | | Set Test Variable | ${dut1s_vlan_index}
92 | | Set Test Variable | ${dut2s_vlan_name}
93 | | Set Test Variable | ${dut2s_vlan_index}
94
95 | Send VXLAN encapsulated packet and verify received packet
96 | | [Documentation] | Send VXLAN encapsulated Ethernet frame and check \
97 | | ... | received one.
98 | | ...
99 | | ... | *Arguments:*
100 | | ... | - tg_node - Node where to run traffic script. Type: dictionary
101 | | ... | - tx_if - Interface from where send VXLAN packet. Type: string
102 | | ... | - rx_if - Interface where receive VXLAN packet. Type: string
103 | | ... | - tx_src_mac - Source MAC address of sent packet. Type: string
104 | | ... | - tx_dst_mac - Destination MAC address of sent packet. Type: string
105 | | ... | - tx_src_ip - Source IP address of sent VXLAN packet. Type: string
106 | | ... | - tx_dst_ip - Destination IP address of sent VXLAN packet.
107 | | ... | Type: string
108 | | ... | - tx_vni - VNI of sent VXLAN packet. Type: string
109 | | ... | - rx_src_ip - Source IP address of received VXLAN packet. Type: string
110 | | ... | - rx_dst_ip - Destination IP address of received VXLAN packet.
111 | | ... | Type: string
112 | | ... | - rx_vni - VNI of received VXLAN packet. Type: string
113 | | ...
114 | | ... | *Return:*
115 | | ... | - No value returned
116 | | ...
117 | | ... | *Example:*
118 | | ...
119 | | ... | \| Send VXLAN encapsulated packet and verify received packet \
120 | | ... | \| ${tg_node} \| port4 \| port4 \
121 | | ... | \| fa:16:3e:6d:f9:c5 \| fa:16:3e:e6:6d:9a \| 192.168.0.1 \
122 | | ... | \| 192.168.0.2 \| ${101} \| 192.168.0.2 \| 192.168.0.1 \| ${102} \|
123 | | ...
124 | | [Arguments] | ${tg_node} | ${tx_if} | ${rx_if}
125 | | ... | ${tx_src_mac} | ${tx_dst_mac}
126 | | ... | ${tx_src_ip} | ${tx_dst_ip} | ${tx_vni}
127 | | ... | ${rx_src_ip} | ${rx_dst_ip} | ${rx_vni}
128 | | ${tx_if_name}= | Get interface name | ${tg_node} | ${tx_if}
129 | | ${rx_if_name}= | Get interface name | ${tg_node} | ${rx_if}
130 | | ${args}= | Catenate
131 | | ... | --tx_if ${tx_if_name}
132 | | ... | --rx_if ${rx_if_name}
133 | | ... | --tx_src_mac ${tx_src_mac}
134 | | ... | --tx_dst_mac ${tx_dst_mac}
135 | | ... | --tx_src_ip ${tx_src_ip}
136 | | ... | --tx_dst_ip ${tx_dst_ip}
137 | | ... | --tx_vni ${tx_vni}
138 | | ... | --rx_src_ip ${rx_src_ip}
139 | | ... | --rx_dst_ip ${rx_dst_ip}
140 | | ... | --rx_vni ${rx_vni}
141 | | Run Traffic Script On Node | send_vxlan_check_vxlan.py | ${tg_node}
142 | | ... | ${args}
143
144 | Get VXLAN dump
145 | | [Documentation] | Get VXLAN dump.
146 | | ...
147 | | ... | *Arguments:*
148 | | ... | - node - DUT node data. Type: dictionary
149 | | ... | - interface - Interface on the VPP node (Optional). Type: string
150 | | ...
151 | | [Arguments] | ${dut_node} | ${interface}=${None}
152 | | ...
153 | | [Return] | ${vxlan_dump}
154 | | ...
155 | | ${vxlan_dump}= | VXLAN Dump | ${dut_node} | ${interface}