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:
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
14 | Library | resources.libraries.python.InterfaceUtil
15 | Library | resources.libraries.python.NodePath
16 | Library | resources.libraries.python.VatExecutor
19 | VPP reports interfaces through VAT on '${node}'
20 | | Execute Script | dump_interfaces.vat | ${node}
21 | | Script Should Have Passed
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}
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}
37 | | [Documentation] | Get vhost-user dump.
39 | | ... | *Arguments:*
40 | | ... | - node - DUT node data. Type: dictionary
42 | | [Arguments] | ${dut_node}
44 | | [Return] | ${vhost_dump}
46 | | ${vhost_dump}= | Vhost User Dump | ${dut_node}
48 | Initialize layer interface on node
50 | | ... | Baseline interfaces variables to be created.
52 | | ... | *Arguments:*
53 | | ... | - dut - DUT node. Type: string
54 | | ... | - count - Number of baseline interface variables. Type: integer
58 | | ... | \| Initialize layer interface on node \| DUT1 \| 1 \|
60 | | [Arguments] | ${dut} | ${count}=${1}
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}
67 | Initialize layer interface
69 | | ... | Physical interfaces variables to be created on all DUTs.
71 | | ... | *Arguments:*
72 | | ... | - count - Number of untagged interfaces variables. Type: integer
76 | | ... | \| Initialize layer interface \| 1 \|
78 | | [Arguments] | ${count}=${1}
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
85 | Initialize layer bonding on node
87 | | ... | Bonded interface and variables to be created on across east and
88 | | ... | west DUT's node interfaces.
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
98 | | ... | \| Initialize layer bonding on node \| DUT1 \| xor \| l34 \| 1 \|
100 | | [Arguments] | ${dut} | ${bond_mode}=xor | ${lb_mode}=l34 | ${count}=${1}
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}
115 | Initialize layer bonding
117 | | ... | Bonded interfaces and variables to be created on all DUT's interfaces.
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
126 | | ... | \| Initialize layer bonding \| xor \| l34 \| 1 \|
128 | | [Arguments] | ${bond_mode}=xor | ${lb_mode}=l34 | ${count}=${1}
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
136 | Initialize layer dot1q on node
138 | | ... | Dot1q interfaces and variables to be created on all DUT's node
139 | | ... | interfaces.
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
149 | | ... | \| Initialize layer dot1q on node \| DUT1 \| 1 \| True \|
151 | | [Arguments] | ${dut} | ${count}=${1} | ${create}=${True}
153 | | ${dut_str}= | Convert To Lowercase | ${dut}
154 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
155 | | | ${vlan_west}= | Evaluate | 100 + ${id} - 1
156 | | | ${vlan_east}= | Evaluate | 200 + ${id} - 1
157 | | | ${if1_name} | ${if1_index}= | Run Keyword Unless
158 | | | ... | ${create} and ${id} > ${1}
159 | | | ... | Create Vlan Subinterface
160 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
161 | | | ... | ${vlan_west}
162 | | | ${if2_name} | ${if2_index}= | Run Keyword Unless
163 | | | ... | ${create} and ${id} > ${1}
164 | | | ... | Create Vlan Subinterface
165 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
166 | | | ... | ${vlan_east}
167 | | | Run Keyword Unless | ${create} and ${id} > ${1}
168 | | | ... | Set Interface State | ${nodes['${dut}']} | ${if1_index} | up
169 | | | Run Keyword Unless | ${create} and ${id} > ${1}
170 | | | ... | Set Interface State | ${nodes['${dut}']} | ${if2_index} | up
171 | | | Set Test Variable | ${${dut_str}_dot1q_${id}_1} | ${if1_index}
172 | | | Set Test Variable | ${${dut_str}_dot1q_${id}_2} | ${if2_index}
174 | Initialize layer dot1q
176 | | ... | Dot1q interfaces and variables to be created on all DUT's interfaces.
178 | | ... | *Arguments:*
179 | | ... | - count - Number of tagged interfaces. Type: integer
180 | | ... | - create - Whether to create vlan for each chain. Type: boolean
182 | | ... | \| Initialize layer dot1q \| 1 \| True \|
184 | | [Arguments] | ${count}=${1} | ${create}=${True}
186 | | :FOR | ${dut} | IN | @{duts}
187 | | | Initialize layer dot1q on node | ${dut} | count=${count}
188 | | | ... | create=${create}
189 | | Set Test Variable | ${prev_layer} | dot1q
191 | Initialize layer ip4vxlan on node
193 | | ... | Setup VXLANoIPv4 between TG and DUTs and DUT to DUT by connecting
194 | | ... | physical and vxlan interfaces on each DUT. All interfaces are brought
195 | | ... | up. IPv4 addresses with prefix /24 are configured on interfaces
196 | | ... | towards TG. VXLAN sub-interfaces has same IPv4 address as interfaces.
198 | | ... | *Arguments:*
199 | | ... | - dut - DUT node. Type: string
200 | | ... | - count - Number of vxlan interfaces. Type: integer
204 | | ... | \| Initialize layer ip4vxlan on node \| DUT1 \| 1 \|
206 | | [Arguments] | ${dut} | ${count}=${1}
208 | | ${dut_str}= | Convert To Lowercase | ${dut}
209 | | Configure IP addresses on interfaces
210 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_1}
211 | | ... | 172.16.0.1 | 24
212 | | Configure IP addresses on interfaces
213 | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_2}
214 | | ... | 172.26.0.1 | 24
215 | | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
216 | | | ${subnet}= | Evaluate | ${id} - 1
217 | | | ${vni}= | Evaluate | ${id} - 1
218 | | | ${ip4vxlan_1}= | Create VXLAN interface
219 | | | ... | ${nodes['${dut}']} | ${vni} | 172.16.0.1 | 172.17.${subnet}.2
220 | | | ${ip4vxlan_2}= | Create VXLAN interface
221 | | | ... | ${nodes['${dut}']} | ${vni} | 172.26.0.1 | 172.27.${subnet}.2
222 | | | ${prev_mac}= | Set Variable If | '${dut}' == 'DUT1'
223 | | | ... | ${tg_if1_mac} | ${dut1_if2_mac}
224 | | | ${next_mac}= | Set Variable If | '${dut}' == 'DUT1' and ${duts_count} == 2
225 | | | ... | ${dut2_if1_mac} | ${tg_if2_mac}
226 | | | VPP Add IP Neighbor
227 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
228 | | | ... | 172.16.${subnet}.2 | ${prev_mac}
229 | | | VPP Add IP Neighbor
230 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
231 | | | ... | 172.26.${subnet}.2 | ${next_mac}
233 | | | ... | ${nodes['${dut}']} | 172.17.${subnet}.0 | 24
234 | | | ... | gateway=172.16.${subnet}.2
235 | | | ... | interface=${${dut_str}_${prev_layer}_${id}_1}
237 | | | ... | ${nodes['${dut}']} | 172.27.${subnet}.0 | 24
238 | | | ... | gateway=172.26.${subnet}.2
239 | | | ... | interface=${${dut_str}_${prev_layer}_${id}_2}
240 | | | Set VXLAN Bypass
241 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
242 | | | Set VXLAN Bypass
243 | | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
244 | | | Set Test Variable
245 | | | ... | ${${dut_str}_ip4vxlan_${id}_1} | ${ip4vxlan_1}
246 | | | Set Test Variable
247 | | | ... | ${${dut_str}_ip4vxlan_${id}_2} | ${ip4vxlan_2}
249 | Initialize layer ip4vxlan
251 | | ... | VXLAN interfaces and variables to be created on all DUT's interfaces.
253 | | ... | *Arguments:*
254 | | ... | - count - Number of vxlan interfaces. Type: integer
256 | | ... | \| Initialize layer ip4vxlan \| 1 \|
258 | | [Arguments] | ${count}=${1}
260 | | :FOR | ${dut} | IN | @{duts}
261 | | | Initialize layer ip4vxlan on node | ${dut} | count=${count}
262 | | Set Test Variable | ${prev_layer} | ip4vxlan