FIX: Layer dot1q logic
[csit.git] / resources / libraries / robot / shared / interfaces.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 *** Settings ***
14 | Library | resources.libraries.python.InterfaceUtil
15 | Library | resources.libraries.python.NodePath
16 | Library | resources.libraries.python.VatExecutor
17
18 *** Keywords ***
19 | VPP reports interfaces through VAT on '${node}'
20 | | Execute Script | dump_interfaces.vat | ${node}
21 | | Script Should Have Passed
22
23 | Configure MTU on TG based on MTU on DUT
24 | | [Documentation] | Type of the tg_node must be TG and dut_node must be DUT
25 | | [Arguments] | ${tg_node} | ${dut_node}
26 | | Append Nodes | ${tg_node} | ${dut_node}
27 | | Compute Path
28 | | ${tg_port} | ${tg_node}= | First Interface
29 | | ${dut_port} | ${dut_node}= | Last Interface
30 | | # get physical layer MTU (max. size of Ethernet frame)
31 | | ${mtu}= | Get Interface MTU | ${dut_node} | ${dut_port}
32 | | # Ethernet MTU is physical layer MTU minus size of Ethernet header and FCS
33 | | ${eth_mtu}= | Evaluate | ${mtu} - 14 - 4
34 | | Set Interface Ethernet MTU | ${tg_node} | ${tg_port} | ${eth_mtu}
35
36 | Get Vhost dump
37 | | [Documentation] | Get vhost-user dump.
38 | | ...
39 | | ... | *Arguments:*
40 | | ... | - node - DUT node data. Type: dictionary
41 | | ...
42 | | [Arguments] | ${dut_node}
43 | | ...
44 | | [Return] | ${vhost_dump}
45 | | ...
46 | | ${vhost_dump}= | Vhost User Dump | ${dut_node}
47
48 | Initialize layer interface on node
49 | | [Documentation]
50 | | ... | Baseline interfaces variables to be created.
51 | | ...
52 | | ... | *Arguments:*
53 | | ... | - dut - DUT node. Type: string
54 | | ... | - count - Number of baseline interface variables. Type: integer
55 | | ...
56 | | ... | *Example:*
57 | | ...
58 | | ... | \| Initialize layer interface on node \| DUT1 \| 1 \|
59 | | ...
60 | | [Arguments] | ${dut} | ${count}=${1}
61 | | ...
62 | | ${dut_str}= | Convert To Lowercase | ${dut}
63 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
64 | | | Set Test Variable | ${${dut_str}_if_${id}_1} | ${${dut_str}_if1}
65 | | | Set Test Variable | ${${dut_str}_if_${id}_2} | ${${dut_str}_if2}
66
67 | Initialize layer interface
68 | | [Documentation]
69 | | ... | Physical interfaces variables to be created on all DUTs.
70 | | ...
71 | | ... | *Arguments:*
72 | | ... | - count - Number of untagged interfaces variables. Type: integer
73 | | ...
74 | | ... | *Example:*
75 | | ...
76 | | ... | \| Initialize layer interface \| 1 \|
77 | | ...
78 | | [Arguments] | ${count}=${1}
79 | | ...
80 | | :FOR | ${dut} | IN | @{duts}
81 | | | Initialize layer interface on node | ${dut} | count=${count}
82 | | Set Test Variable | ${prev_layer} | if
83 | | Set interfaces in path up
84
85 | Initialize layer bonding on node
86 | | [Documentation]
87 | | ... | Bonded interface and variables to be created on across east and
88 | | ... | west DUT's node interfaces.
89 | | ...
90 | | ... | *Arguments:*
91 | | ... | - dut - DUT node. Type: string
92 | | ... | - bond_mode - Link bonding mode. Type: string
93 | | ... | - lb_mode - Load balance mode. Type: string
94 | | ... | - count - Number of bond interface variables. Type: integer
95 | | ...
96 | | ... | *Example:*
97 | | ...
98 | | ... | \| Initialize layer bonding on node \| DUT1 \| xor \| l34 \| 1 \|
99 | | ...
100 | | [Arguments] | ${dut} | ${bond_mode}=xor | ${lb_mode}=l34 | ${count}=${1}
101 | | ...
102 | | ${dut_str}= | Convert To Lowercase | ${dut}
103 | | ${if_index}= | VPP Create Bond Interface
104 | | ... | ${nodes['${dut}']} | ${bond_mode} | load_balance=${lb_mode}
105 | | ... | mac=00:00:00:01:01:01
106 | | Set Interface State | ${nodes['${dut}']} | ${if_index} | up
107 | | VPP Enslave Physical Interface
108 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_1} | ${if_index}
109 | | VPP Enslave Physical Interface
110 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_2} | ${if_index}
111 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
112 | | | Set Test Variable | ${${dut_str}_bond_${id}_1} | ${if_index}
113 | | | Set Test Variable | ${${dut_str}_bond_${id}_2} | ${if_index}
114
115 | Initialize layer bonding
116 | | [Documentation]
117 | | ... | Bonded interfaces and variables to be created on all DUT's interfaces.
118 | | ...
119 | | ... | *Arguments:*
120 | | ... | - bond_mode - Link bonding mode. Type: string
121 | | ... | - lb_mode - Load balance mode. Type: string
122 | | ... | - count - Number of bond interface variables. Type: integer
123 | | ...
124 | | ... | *Example:*
125 | | ...
126 | | ... | \| Initialize layer bonding \| xor \| l34 \| 1 \|
127 | | ...
128 | | [Arguments] | ${bond_mode}=xor | ${lb_mode}=l34 | ${count}=${1}
129 | | ...
130 | | :FOR | ${dut} | IN | @{duts}
131 | | | Initialize layer bonding on node
132 | | | ... | ${dut} | bond_mode=${bond_mode} | lb_mode=${lb_mode}
133 | | | ... | count=${count}
134 | | Set Test Variable | ${prev_layer} | bond
135
136 | Initialize layer dot1q on node
137 | | [Documentation]
138 | | ... | Dot1q interfaces and variables to be created on all DUT's node
139 | | ... | interfaces.
140 | | ...
141 | | ... | *Arguments:*
142 | | ... | - dut - DUT node. Type: string
143 | | ... | - count - Number of tagged interfaces. Type: integer
144 | | ... | - create - Whether to create vlan subinterface for each chain.
145 | | ... |     Type: boolean
146 | | ...
147 | | ... | *Example:*
148 | | ...
149 | | ... | \| Initialize layer dot1q on node \| DUT1 \| 1 \| True \|
150 | | ...
151 | | [Arguments] | ${dut} | ${count}=${1} | ${create}=${True}
152 | | ...
153 | | ${dut_str}= | Convert To Lowercase | ${dut}
154 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
155 | | | ${if1_vlan}= | Evaluate | ${100} + ${id} - ${1}
156 | | | ${if2_vlan}= | Evaluate | ${200} + ${id} - ${1}
157 | | | ${if1_name} | ${if1_index}= | Run Keyword If
158 | | | ... | ${create} or ${id} == ${1}
159 | | | ... | Create Vlan Subinterface
160 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
161 | | | ... | ${if1_vlan}
162 | | | ${if2_name} | ${if2_index}= | Run Keyword If
163 | | | ... | ${create} or ${id} == ${1}
164 | | | ... | Create Vlan Subinterface
165 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
166 | | | ... | ${if2_vlan}
167 | | | Run Keyword If | ${create} or ${id} == ${1}
168 | | | ... | Set Interface State | ${nodes['${dut}']} | ${if1_index} | up
169 | | | Run Keyword If | ${create} or ${id} == ${1}
170 | | | ... | Set Interface State | ${nodes['${dut}']} | ${if2_index} | up
171 | | | Run Keyword If | ${create} or ${id} == ${1}
172 | | | ... | Configure L2 tag rewrite method on interfaces
173 | | | ... | ${nodes['${dut}']} | ${if1_index} | TAG_REWRITE_METHOD=pop-1
174 | | | Run Keyword If | ${create} or ${id} == ${1}
175 | | | ... | Configure L2 tag rewrite method on interfaces
176 | | | ... | ${nodes['${dut}']} | ${if2_index} | TAG_REWRITE_METHOD=pop-1
177 | | | ${if1_index}= | Set Variable If | '${if1_index}' == '${NONE}'
178 | | | ... | ${${dut_str}_dot1q_1_1} | ${if1_index}
179 | | | ${if2_index}= | Set Variable If | '${if2_index}' == '${NONE}'
180 | | | ... | ${${dut_str}_dot1q_1_2} | ${if2_index}
181 | | | Set Test Variable | ${${dut_str}_dot1q_${id}_1} | ${if1_index}
182 | | | Set Test Variable | ${${dut_str}_dot1q_${id}_2} | ${if2_index}
183
184 | Initialize layer dot1q
185 | | [Documentation]
186 | | ... | Dot1q interfaces and variables to be created on all DUT's interfaces.
187 | | ...
188 | | ... | *Arguments:*
189 | | ... | - count - Number of tagged interfaces. Type: integer
190 | | ... | - create - Whether to create vlan for each chain. Type: boolean
191 | | ...
192 | | ... | \| Initialize layer dot1q \| 1 \| True \|
193 | | ...
194 | | [Arguments] | ${count}=${1} | ${create}=${True}
195 | | ...
196 | | :FOR | ${dut} | IN | @{duts}
197 | | | Initialize layer dot1q on node | ${dut} | count=${count}
198 | | | ... | create=${create}
199 | | Set Test Variable | ${prev_layer} | dot1q
200
201 | Initialize layer ip4vxlan on node
202 | | [Documentation]
203 | | ... | Setup VXLANoIPv4 between TG and DUTs and DUT to DUT by connecting
204 | | ... | physical and vxlan interfaces on each DUT. All interfaces are brought
205 | | ... | up. IPv4 addresses with prefix /24 are configured on interfaces
206 | | ... | towards TG. VXLAN sub-interfaces has same IPv4 address as interfaces.
207 | | ...
208 | | ... | *Arguments:*
209 | | ... | - dut - DUT node. Type: string
210 | | ... | - count - Number of vxlan interfaces. Type: integer
211 | | ...
212 | | ... | *Example:*
213 | | ...
214 | | ... | \| Initialize layer ip4vxlan on node \| DUT1 \| 1 \|
215 | | ...
216 | | [Arguments] | ${dut} | ${count}=${1}
217 | | ...
218 | | ${dut_str}= | Convert To Lowercase | ${dut}
219 | | Configure IP addresses on interfaces
220 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_1}
221 | | ... | 172.16.0.1 | 24
222 | | Configure IP addresses on interfaces
223 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_2}
224 | | ... | 172.26.0.1 | 24
225 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
226 | | | ${subnet}= | Evaluate | ${id} - 1
227 | | | ${vni}= | Evaluate | ${id} - 1
228 | | | ${ip4vxlan_1}= | Create VXLAN interface
229 | | | ... | ${nodes['${dut}']} | ${vni} | 172.16.0.1 | 172.17.${subnet}.2
230 | | | ${ip4vxlan_2}= | Create VXLAN interface
231 | | | ... | ${nodes['${dut}']} | ${vni} | 172.26.0.1 | 172.27.${subnet}.2
232 | | | ${prev_mac}= | Set Variable If | '${dut}' == 'DUT1'
233 | | | ... | ${tg_if1_mac} | ${dut1_if2_mac}
234 | | | ${next_mac}= | Set Variable If | '${dut}' == 'DUT1' and ${duts_count} == 2
235 | | | ... | ${dut2_if1_mac} | ${tg_if2_mac}
236 | | | VPP Add IP Neighbor
237 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
238 | | | ... | 172.16.${subnet}.2 | ${prev_mac}
239 | | | VPP Add IP Neighbor
240 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
241 | | | ... | 172.26.${subnet}.2 | ${next_mac}
242 | | | VPP Route Add
243 | | | ... | ${nodes['${dut}']} | 172.17.${subnet}.0 | 24
244 | | | ... | gateway=172.16.${subnet}.2
245 | | | ... | interface=${${dut_str}_${prev_layer}_${id}_1}
246 | | | VPP Route Add
247 | | | ... | ${nodes['${dut}']} | 172.27.${subnet}.0 | 24
248 | | | ... | gateway=172.26.${subnet}.2
249 | | | ... | interface=${${dut_str}_${prev_layer}_${id}_2}
250 | | | Set VXLAN Bypass
251 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
252 | | | Set VXLAN Bypass
253 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
254 | | | Set Test Variable
255 | | | ... | ${${dut_str}_ip4vxlan_${id}_1} | ${ip4vxlan_1}
256 | | | Set Test Variable
257 | | | ... | ${${dut_str}_ip4vxlan_${id}_2} | ${ip4vxlan_2}
258
259 | Initialize layer ip4vxlan
260 | | [Documentation]
261 | | ... | VXLAN interfaces and variables to be created on all DUT's interfaces.
262 | | ...
263 | | ... | *Arguments:*
264 | | ... | - count - Number of vxlan interfaces. Type: integer
265 | | ...
266 | | ... | \| Initialize layer ip4vxlan \| 1 \|
267 | | ...
268 | | [Arguments] | ${count}=${1}
269 | | ...
270 | | :FOR | ${dut} | IN | @{duts}
271 | | | Initialize layer ip4vxlan on node | ${dut} | count=${count}
272 | | Set Test Variable | ${prev_layer} | ip4vxlan