CSIT-1459: Migrate IP libraries from VAT to PAPI
[csit.git] / resources / libraries / robot / ip / ip4.robot
1 # Copyright (c) 2019 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 | resources.libraries.python.InterfaceUtil
16 | Library | resources.libraries.python.IPUtil
17 | Library | resources.libraries.python.NodePath
18 | Library | resources.libraries.python.TrafficScriptExecutor
19 | ...
20 | Resource | resources/libraries/robot/shared/counters.robot
21 | Resource | resources/libraries/robot/shared/default.robot
22 | Resource | resources/libraries/robot/shared/testing_path.robot
23 | ...
24 | Documentation | IPv4 keywords
25
26 *** Keywords ***
27 | Get interface Ipv4 addresses
28 | | [Documentation] | Get IPv4 address for the given interface of the node.
29 | | ...
30 | | ... | *Arguments:*
31 | | ... | - node - DUT node data. Type: dictionary
32 | | ... | - interface - Name of the interface on the VPP node. Type: string
33 | | ...
34 | | [Arguments] | ${node} | ${interface}
35 | | ...
36 | | [Return] | ${ip_data}
37 | | ...
38 | | ${ip_data}= | VPP get interface ip addresses
39 | | ... | ${node} | ${interface} | ipv4
40
41 | Configure IP addresses on interfaces
42 | | [Documentation] | Iterates through @{args} list and set interface IP address
43 | | ... | for every (${dut_node}, ${interface}, ${address},
44 | | ... | ${prefix}) tuple.
45 | | ...
46 | | ... | *Arguments:*
47 | | ... | - dut_node - Node where IP address should be set to.
48 | | ... | Type: dictionary
49 | | ... | - interface - Interface name. Type: string
50 | | ... | - address - IP address. Type: string
51 | | ... | - prefix - Prefix length. Type: integer
52 | | ...
53 | | ... | *Example:*
54 | | ...
55 | | ... | \| Configure IP addresses on interfaces \
56 | | ... | \| ${dut1_node} \| ${dut1_to_dut2} \| 192.168.1.1 \| 24 \|
57 | | ... | \| ... \| ${dut1_node} \| ${dut1_to_tg} \| 192.168.2.1 \| 24 \|
58 | | ...
59 | | [Arguments] | @{args}
60 | | :FOR | ${dut_node} | ${interface} | ${address} | ${prefix} | IN | @{args}
61 | | | VPP Interface Set IP Address
62 | | | ... | ${dut_node} | ${interface} | ${address} | ${prefix}
63
64 | Send ICMP echo request and verify answer
65 | | [Documentation] | Run traffic script that waits for ICMP reply and ignores
66 | | ... | all other packets.
67 | | ...
68 | | ... | *Arguments:*
69 | | ... | - tg_node - TG node where run traffic script. Type: dictionary
70 | | ... | - tg_interface - TG interface where send ICMP echo request.
71 | | ... | Type: string
72 | | ... | - dst_mac - Destination MAC address. Type: string
73 | | ... | - src_mac - Source MAC address. Type: string
74 | | ... | - dst_ip - Destination IP address. Type: string
75 | | ... | - src_ip - Source IP address. Type: string
76 | | ... | - timeout - Wait timeout in seconds (Default: 10). Type: integer
77 | | ...
78 | | ... | *Example:*
79 | | ...
80 | | ... | \| Send ICMP echo request and verify answer \
81 | | ... | \| ${nodes['TG']} \| eth2 \
82 | | ... | \| 08:00:27:46:2b:4c \| 08:00:27:66:b8:57 \
83 | | ... | \| 192.168.23.10 \| 192.168.23.1 \| 10 \|
84 | | ...
85 | | [Arguments] | ${tg_node} | ${tg_interface}
86 | | ... | ${dst_mac} | ${src_mac} | ${dst_ip} | ${src_ip} | ${timeout}=${10}
87 | | ...
88 | | ${tg_interface_name}= | Get interface name | ${tg_node} | ${tg_interface}
89 | | ${args}= | Catenate | --rx_if ${tg_interface_name}
90 | | ... | --tx_if ${tg_interface_name} | --dst_mac ${dst_mac}
91 | | ... | --src_mac ${src_mac} | --dst_ip ${dst_ip} | --src_ip ${src_ip}
92 | | ... | --timeout ${timeout}
93 | | Run Traffic Script On Node | send_icmp_wait_for_reply.py
94 | | ... | ${tg_node} | ${args}
95
96 | Configure IPv4 forwarding in circular topology
97 | | [Documentation]
98 | | ... | Set UP state on VPP interfaces in path on nodes in 2-node / 3-node
99 | | ... | circular topology. Get the interface MAC addresses and setup ARP on
100 | | ... | all VPP interfaces. Setup IPv4 addresses with /24 prefix on DUT-TG
101 | | ... | links. In case of 3-node topology setup IPv4 adresses with /30 prefix
102 | | ... | on DUT1-DUT2 link and set routing on both DUT nodes with prefix /24
103 | | ... | and next hop of neighbour DUT interface IPv4 address. Configure route
104 | | ... | entries for remote hosts IPv4 addresses if required.
105 | | ...
106 | | ... | *Arguments:*
107 | | ... | - tg_if1_ip4 - IP address of TG interface1. Type: string
108 | | ... | - tg_if2_ip4 - IP address of TG interface2. Type: string
109 | | ... | - dut1_if1_ip4 - IP address of DUT1 interface1. Type: string
110 | | ... | - dut1_if2_ip4 - IP address of DUT1 interface1. Type: string
111 | | ... | - dut2_if1_ip4 - IP address of DUT2 interface1 (Optional).
112 | | ... | Type: string
113 | | ... | - dut2_if2_ip4 - IP address of DUT2 interface2 (Optional).
114 | | ... | Type: string
115 | | ... | - remote_host1_ip4 - IP address of remote host1 (Optional).
116 | | ... | Type: string
117 | | ... | - remote_host2_ip4 - IP address of remote host2 (Optional).
118 | | ... | Type: string
119 | | ... | - remote_host_ip4_prefix - IP address prefix for host IP addresses
120 | | ... | (Optional). Type: string or integer
121 | | ...
122 | | ... | *Example:*
123 | | ...
124 | | ... | \| Configure IPv4 forwarding in circular topology \
125 | | ... | \| 10.10.10.2 \| 20.20.20.2 \| 10.10.10.1 \| 20.20.20.1 \|
126 | | ... | \| Configure IPv4 forwarding in circular topology \
127 | | ... | \| 10.10.10.2 \| 20.20.20.2 \| 10.10.10.1 \| 20.20.20.1 \
128 | | ... | \| remote_host1_ip4=192.168.0.1 \| remote_host2_ip4=192.168.0.2 \
129 | | ... | \| remote_host_ip4_prefix=32 \|
130 | | ... | \| Configure IPv4 forwarding in circular topology \
131 | | ... | \| 10.10.10.2 \| 20.20.20.2 \| 10.10.10.1 \| 1.1.1.1 \| 1.1.1.2 \
132 | | ... | \| 20.20.20.1 \|
133 | | ... | \| Configure IPv4 forwarding in circular topology \
134 | | ... | \| 10.10.10.2 \| 20.20.20.2 \| 10.10.10.1 \| 1.1.1.1 \| 1.1.1.2 \
135 | | ... | \| 20.20.20.1 \| remote_host1_ip4=192.168.0.1 \
136 | | ... | \| remote_host2_ip4=192.168.0.2 \| remote_host_ip4_prefix=32 \|
137 | | ...
138 | | [Arguments] | ${tg_if1_ip4} | ${tg_if2_ip4} | ${dut1_if1_ip4}
139 | | ... | ${dut1_if2_ip4} | ${dut2_if1_ip4}=${NONE} | ${dut2_if2_ip4}=${NONE}
140 | | ... | ${remote_host1_ip4}=${NONE} | ${remote_host2_ip4}=${NONE}
141 | | ... | ${remote_host_ip4_prefix}=${NONE}
142 | | ...
143 | | Configure interfaces in path up
144 | | ...
145 | | ${dut2_status} | ${value}= | Run Keyword And Ignore Error
146 | | ... | Variable Should Exist | ${dut2_node}
147 | | ...
148 | | Run Keyword If | '${dut2_status}' == 'PASS'
149 | | ... | Configure IPv4 forwarding in 3-node circular topology
150 | | ... | ${tg_if1_ip4} | ${tg_if2_ip4} | ${dut1_if1_ip4} | ${dut1_if2_ip4}
151 | | ... | ${dut2_if1_ip4} | ${dut2_if2_ip4} | ${remote_host1_ip4}
152 | | ... | ${remote_host2_ip4} | ${remote_host_ip4_prefix}
153 | | ... | ELSE
154 | | ... | Configure IPv4 forwarding in 2-node circular topology
155 | | ... | ${tg_if1_ip4} | ${tg_if2_ip4} | ${dut1_if1_ip4} | ${dut1_if2_ip4}
156 | | ... | remote_host1_ip4=${remote_host1_ip4}
157 | | ... | remote_host2_ip4=${remote_host2_ip4}
158 | | ... | remote_host_ip4_prefix=${remote_host_ip4_prefix}
159
160 | Configure IPv4 forwarding in 2-node circular topology
161 | | [Documentation]
162 | | ... | Set UP state on VPP interfaces on DUT node in 2-node circular
163 | | ... | topology. Get the interface MAC addresses and setup ARP on
164 | | ... | all VPP interfaces. Setup IPv4 addresses with /24 prefix on DUT-TG
165 | | ... | links. Configure route entries for remote hosts IPv4 addresses
166 | | ... | if required.
167 | | ...
168 | | ... | *Arguments:*
169 | | ... | - tg_if1_ip4 - IP address of TG interface1. Type: string
170 | | ... | - tg_if2_ip4 - IP address of TG interface2. Type: string
171 | | ... | - dut1_if1_ip4 - IP address of DUT1 interface1. Type: string
172 | | ... | - dut1_if2_ip4 - IP address of DUT1 interface1. Type: string
173 | | ... | - remote_host1_ip4 - IP address of remote host1 (Optional).
174 | | ... | Type: string
175 | | ... | - remote_host2_ip4 - IP address of remote host2 (Optional).
176 | | ... | Type: string
177 | | ... | - remote_host_ip4_prefix - IP address prefix for host IP addresses
178 | | ... | (Optional). Type: string or integer
179 | | ...
180 | | ... | *Example:*
181 | | ...
182 | | ... | \| Configure IPv4 forwarding in circular topology \
183 | | ... | \| 10.10.10.2 \| 20.20.20.2 \| 10.10.10.1 \| 20.20.20.1 \|
184 | | ... | \| Configure IPv4 forwarding in circular topology \
185 | | ... | \| 10.10.10.2 \| 20.20.20.2 \| 10.10.10.1 \| 20.20.20.1 \
186 | | ... | \| 192.168.0.1 \| 192.168.0.2 \| 32 \|
187 | | ...
188 | | [Arguments] | ${tg_if1_ip4} | ${tg_if2_ip4} | ${dut1_if1_ip4}
189 | | ... | ${dut1_if2_ip4} | ${remote_host1_ip4}=${NONE}
190 | | ... | ${remote_host2_ip4}=${NONE} | ${remote_host_ip4_prefix}=${NONE}
191 | | ...
192 | | ${dut_tg_ip4_prefix}= | Set Variable | 24
193 | | ...
194 | | VPP Add IP Neighbor | ${dut_node} | ${dut_to_tg_if1} | ${tg_if1_ip4}
195 | | ... | ${tg_to_dut_if1_mac}
196 | | VPP Add IP Neighbor | ${dut_node} | ${dut_to_tg_if2} | ${tg_if2_ip4}
197 | | ... | ${tg_to_dut_if2_mac}
198 | | ...
199 | | Configure IP addresses on interfaces | ${dut_node} | ${dut_to_tg_if1}
200 | | ... | ${dut1_if1_ip4} | ${dut_tg_ip4_prefix}
201 | | Configure IP addresses on interfaces | ${dut_node} | ${dut_to_tg_if2}
202 | | ... | ${dut1_if2_ip4} | ${dut_tg_ip4_prefix}
203 | | ...
204 | | Run Keyword Unless | '${remote_host1_ip4}' == '${NONE}'
205 | | ... | Vpp Route Add | ${dut_node} | ${remote_host1_ip4}
206 | | ... | ${remote_host_ip4_prefix} | gateway=${tg_if1_ip4}
207 | | ... | interface=${dut_to_tg_if1}
208 | | Run Keyword Unless | '${remote_host2_ip4}' == '${NONE}'
209 | | ... | Vpp Route Add | ${dut_node} | ${remote_host2_ip4}
210 | | ... | ${remote_host_ip4_prefix} | gateway=${tg_if2_ip4}
211 | | ... | interface=${dut_to_tg_if2}
212
213 | Configure IPv4 forwarding in 3-node circular topology
214 | | [Documentation]
215 | | ... | Set UP state on VPP interfaces in path on nodes in 3-node circular
216 | | ... | topology. Get the interface MAC addresses and setup ARP on all VPP
217 | | ... | interfaces. Setup IPv4 addresses with /24 prefix on DUT-TG links.
218 | | ... | Configure IPv4 adresses with /30 prefix on DUT1-DUT2 link and set
219 | | ... | routing on both DUT nodes with prefix /24 and next hop of neighbour
220 | | ... | DUT interface IPv4 address. Configure route entries for remote hosts
221 | | ... | IPv4 addresses if required.
222 | | ...
223 | | ... | *Arguments:*
224 | | ... | - tg_if1_ip4 - IP address of TG interface1. Type: string
225 | | ... | - tg_if2_ip4 - IP address of TG interface2. Type: string
226 | | ... | - dut1_if1_ip4 - IP address of DUT1 interface1. Type: string
227 | | ... | - dut1_if2_ip4 - IP address of DUT1 interface1. Type: string
228 | | ... | - dut2_if1_ip4 - IP address of DUT2 interface1. Type: string
229 | | ... | - dut2_if2_ip4 - IP address of DUT2 interface2. Type: string
230 | | ... | - remote_host1_ip4 - IP address of remote host1 (Optional).
231 | | ... | Type: string
232 | | ... | - remote_host2_ip4 - IP address of remote host2 (Optional).
233 | | ... | Type: string
234 | | ... | - remote_host_ip4_prefix - IP address prefix for host IP addresses
235 | | ... | (Optional). Type: string or integer
236 | | ...
237 | | ... | *Example:*
238 | | ...
239 | | ... | \| Configure IPv4 forwarding in circular topology \
240 | | ... | \| 10.10.10.2 \| 20.20.20.2 \| 10.10.10.1 \| 1.1.1.1 \| 1.1.1.2 \
241 | | ... | \| 20.20.20.1 \|
242 | | ... | \| Configure IPv4 forwarding in circular topology \
243 | | ... | \| 10.10.10.2 \| 20.20.20.2 \| 10.10.10.1 \| 1.1.1.1 \| 1.1.1.2 \
244 | | ... | \| 20.20.20.1 \| 192.168.0.1 \| 192.168.0.2 \| 32 \|
245 | | ...
246 | | [Arguments] | ${tg_if1_ip4} | ${tg_if2_ip4} | ${dut1_if1_ip4}
247 | | ... | ${dut1_if2_ip4} | ${dut2_if1_ip4} | ${dut2_if2_ip4}
248 | | ... | ${remote_host1_ip4}=${NONE} | ${remote_host2_ip4}=${NONE}
249 | | ... | ${remote_host_ip4_prefix}=${NONE}
250 | | ...
251 | | ${dut_tg_ip4_prefix}= | Set Variable | 24
252 | | ${dut_link_ip4_prefix}= | Set Variable | 30
253 | | ...
254 | | VPP Add IP Neighbor | ${dut1_node} | ${dut1_to_tg} | ${tg_if1_ip4}
255 | | ... | ${tg_to_dut1_mac}
256 | | VPP Add IP Neighbor | ${dut1_node} | ${dut1_to_dut2} | ${dut2_if1_ip4}
257 | | ... | ${dut2_to_dut1_mac}
258 | | VPP Add IP Neighbor | ${dut2_node} | ${dut2_to_dut1} | ${dut1_if2_ip4}
259 | | ... | ${dut1_to_dut2_mac}
260 | | VPP Add IP Neighbor | ${dut2_node} | ${dut2_to_tg} | ${tg_if2_ip4}
261 | | ... | ${tg_to_dut2_mac}
262 | | ...
263 | | Configure IP addresses on interfaces | ${dut1_node} | ${dut1_to_tg}
264 | | ... | ${dut1_if1_ip4} | ${dut_tg_ip4_prefix}
265 | | Configure IP addresses on interfaces | ${dut1_node} | ${dut1_to_dut2}
266 | | ... | ${dut1_if2_ip4} | ${dut_link_ip4_prefix}
267 | | Configure IP addresses on interfaces | ${dut2_node} | ${dut2_to_dut1}
268 | | ... | ${dut2_if1_ip4} | ${dut_link_ip4_prefix}
269 | | Configure IP addresses on interfaces | ${dut2_node} | ${dut2_to_tg}
270 | | ... | ${dut2_if2_ip4} | ${dut_tg_ip4_prefix}
271 | | ...
272 | | Vpp Route Add | ${dut1_node} | ${tg_if2_ip4} | ${dut_tg_ip4_prefix}
273 | | ... | gateway=${dut2_if1_ip4} | interface=${dut1_to_dut2}
274 | | Vpp Route Add | ${dut2_node} | ${tg_if1_ip4} | ${dut_tg_ip4_prefix}
275 | | ... | gateway=${dut1_if2_ip4} | interface=${dut2_to_dut1}
276 | | ...
277 | | Run Keyword Unless | '${remote_host1_ip4}' == '${NONE}'
278 | | ... | Vpp Route Add | ${dut1_node} | ${remote_host1_ip4}
279 | | ... | ${remote_host_ip4_prefix} | gateway=${tg_if1_ip4}
280 | | ... | interface=${dut1_to_tg}
281 | | Run Keyword Unless | '${remote_host2_ip4}' == '${NONE}'
282 | | ... | Vpp Route Add | ${dut1_node} | ${remote_host2_ip4}
283 | | ... | ${remote_host_ip4_prefix} | gateway=${dut2_if1_ip4}
284 | | ... | interface=${dut1_to_dut2}
285 | | Run Keyword Unless | '${remote_host1_ip4}' == '${NONE}'
286 | | ... | Vpp Route Add | ${dut2_node} | ${remote_host1_ip4}
287 | | ... | ${remote_host_ip4_prefix} | gateway=${dut1_if2_ip4}
288 | | ... | interface=${dut2_to_dut1}
289 | | Run Keyword Unless | '${remote_host2_ip4}' == '${NONE}'
290 | | ... | Vpp Route Add | ${dut2_node} | ${remote_host2_ip4}
291 | | ... | ${remote_host_ip4_prefix} | gateway=${tg_if2_ip4}
292 | | ... | interface=${dut2_to_tg}