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.
15 | Library | resources.libraries.python.L2Util
16 | Library | resources.libraries.python.InterfaceUtil
17 | Library | resources.libraries.python.NodePath
18 | Library | resources.libraries.python.VhostUser
19 | Library | resources.libraries.python.QemuUtils
20 | Resource | resources/libraries/robot/interfaces.robot
21 | Resource | resources/libraries/robot/l2_traffic.robot
24 | Path for 2-node BD testing is set
25 | | [Documentation] | Compute path for bridge domain testing on two given nodes
26 | | ... | and set corresponding test case variables.
28 | | ... | *Arguments:*
29 | | ... | - ${tg_node} - TG node. Type: dictionary
30 | | ... | - ${dut_node} - DUT node. Type: dictionary
33 | | ... | - No value returned
35 | | ... | _NOTE:_ This KW sets following test case variables:
36 | | ... | - ${tg_node} - TG node.
37 | | ... | - ${tg_to_dut_if1} - 1st TG interface towards DUT.
38 | | ... | - ${tg_to_dut_if2} - 2nd TG interface towards DUT.
39 | | ... | - ${dut_node} - DUT node.
40 | | ... | - ${dut_to_tg_if1} - 1st DUT interface towards TG.
41 | | ... | - ${dut_to_tg_if2} - 2nd DUT interface towards TG.
45 | | ... | \| Given Path for 2-node BD testing is set \| ${nodes['TG']} \
46 | | ... | \| ${nodes['DUT1']} \|
47 | | [Arguments] | ${tg_node} | ${dut_node}
48 | | Append Nodes | ${tg_node} | ${dut_node} | ${tg_node}
49 | | Compute Path | always_same_link=${FALSE}
50 | | ${tg_to_dut_if1} | ${tmp}= | First Interface
51 | | ${tg_to_dut_if2} | ${tmp}= | Last Interface
52 | | ${dut_to_tg_if1} | ${tmp}= | First Ingress Interface
53 | | ${dut_to_tg_if2} | ${tmp}= | Last Egress Interface
54 | | Set Test Variable | ${tg_to_dut_if1}
55 | | Set Test Variable | ${tg_to_dut_if2}
56 | | Set Test Variable | ${dut_to_tg_if1}
57 | | Set Test Variable | ${dut_to_tg_if2}
58 | | Set Test Variable | ${tg_node}
59 | | Set Test Variable | ${dut_node}
61 | Vpp l2bd forwarding setup
62 | | [Documentation] | Setup BD between 2 interfaces on VPP node and if learning
63 | | ... | is off set static L2FIB entry on second interface
64 | | [Arguments] | ${node} | ${if1} | ${if2} | ${learn}=${TRUE} | ${mac}=${EMPTY}
65 | | Set Interface State | ${node} | ${if1} | up
66 | | Set Interface State | ${node} | ${if2} | up
67 | | Vpp Add L2 Bridge Domain | ${node} | ${1} | ${if1} | ${if2} | ${learn}
68 | | Run Keyword If | ${learn} == ${FALSE}
69 | | ... | Vpp Add L2fib Entry | ${node} | ${mac} | ${if2} | ${1}
70 | | All Vpp Interfaces Ready Wait | ${nodes}
72 | Path for 3-node BD testing is set
73 | | [Documentation] | Compute path for bridge domain testing on three given
74 | | ... | nodes and set corresponding test case variables.
76 | | ... | *Arguments:*
77 | | ... | - ${tg_node} - TG node. Type: dictionary
78 | | ... | - ${dut1_node} - DUT1 node. Type: dictionary
79 | | ... | - ${dut2_node} - DUT2 node. Type: dictionary
82 | | ... | - No value returned
84 | | ... | _NOTE:_ This KW sets following test case variables:
85 | | ... | - ${tg_node} - TG node.
86 | | ... | - ${tg_to_dut1} - TG interface towards DUT1.
87 | | ... | - ${tg_to_dut2} - TG interface towards DUT2.
88 | | ... | - ${dut1_node} - DUT1 node.
89 | | ... | - ${dut1_to_tg} - DUT1 interface towards TG.
90 | | ... | - ${dut1_to_dut2} - DUT1 interface towards DUT2.
91 | | ... | - ${dut2_node} - DUT2 node.
92 | | ... | - ${dut2_to_tg} - DUT2 interface towards TG.
93 | | ... | - ${dut2_to_dut1} - DUT2 interface towards DUT1.
97 | | ... | \| Given Path for 3-node BD testing is set \| ${nodes['TG']} \
98 | | ... | \| ${nodes['DUT1']} \| ${nodes['DUT2']} \|
99 | | [Arguments] | ${tg_node} | ${dut1_node} | ${dut2_node}
100 | | Append Nodes | ${tg_node} | ${dut1_node} | ${dut2_node} | ${tg_node}
102 | | ${tg_to_dut1} | ${tmp}= | Next Interface
103 | | ${dut1_to_tg} | ${tmp}= | Next Interface
104 | | ${dut1_to_dut2} | ${tmp}= | Next Interface
105 | | ${dut2_to_dut1} | ${tmp}= | Next Interface
106 | | ${dut2_to_tg} | ${tmp}= | Next Interface
107 | | ${tg_to_dut2} | ${tmp}= | Next Interface
108 | | Set Test Variable | ${tg_to_dut1}
109 | | Set Test Variable | ${dut1_to_tg}
110 | | Set Test Variable | ${tg_to_dut2}
111 | | Set Test Variable | ${dut2_to_tg}
112 | | Set Test Variable | ${dut1_to_dut2}
113 | | Set Test Variable | ${dut2_to_dut1}
114 | | Set Test Variable | ${tg_node}
115 | | Set Test Variable | ${dut1_node}
116 | | Set Test Variable | ${dut2_node}
118 | Bridge domain on DUT node is created
119 | | [Documentation] | Create bridge domain on given VPP node with defined
120 | | ... | learning status.
122 | | ... | *Arguments:*
123 | | ... | - ${dut_node} - DUT node. Type: dictionary
124 | | ... | - ${bd_id} - Bridge domain ID. Type: integer
125 | | ... | - ${learn} - Enable/disable MAC learn. Type: boolean, \
126 | | ... | default value: ${TRUE}
129 | | ... | - No value returned
133 | | ... | \| Bridge domain on DUT node is created \| ${nodes['DUT1']} \| 2 \|
134 | | ... | \| Bridge domain on DUT node is created \| ${nodes['DUT1']} \| 5 \
135 | | ... | \| learn=${FALSE} \|
136 | | [Arguments] | ${dut_node} | ${bd_id} | ${learn}=${TRUE}
137 | | ${learn} = | Set Variable If | ${learn} == ${TRUE} | ${1} | ${0}
138 | | Create L2 BD | ${dut_node} | ${bd_id} | learn=${learn}
140 | Interface is added to bridge domain
141 | | [Documentation] | Set given interface admin state to up and add this
142 | | ... | interface to required L2 bridge domain on defined
145 | | ... | *Arguments:*
146 | | ... | - ${dut_node} - DUT node. Type: dictionary
147 | | ... | - ${dut_if} - DUT node interface name. Type: string
148 | | ... | - ${bd_id} - Bridge domain ID. Type: integer
151 | | ... | - No value returned
155 | | ... | \| Interface is added to bridge domain \| ${nodes['DUT2']} \
156 | | ... | \| GigabitEthernet0/8/0 \| 3 \|
157 | | [Arguments] | ${dut_node} | ${dut_if} | ${bd_id}
158 | | Set Interface State | ${dut_node} | ${dut_if} | up
159 | | Add Interface To L2 BD | ${dut_node} | ${dut_if} | ${bd_id}
161 | Destination port is added to L2FIB on DUT node
162 | | [Documentation] | Create a static L2FIB entry for required destination port
163 | | ... | on defined interface and bridge domain ID
164 | | ... | of the given VPP node.
166 | | ... | *Arguments:*
167 | | ... | - ${dest_node} - Destination node. Type: dictionary
168 | | ... | - ${dest_node_if} - Destination node interface name. Type: string
169 | | ... | - ${vpp_node} - DUT node to add L2FIB entry on. Type: dictionary
170 | | ... | - ${vpp_node_if} - DUT node interface name. Type: string
171 | | ... | - ${bd_id} - Bridge domain ID. Type: integer
174 | | ... | - No value returned
178 | | ... | \| Destination port is added to L2FIB on DUT node \| ${nodes['TG']} \
179 | | ... | \| eth1 \| ${nodes['DUT2']} \| GigabitEthernet0/8/0 \| 3 \|
180 | | [Arguments] | ${dest_node} | ${dest_node_if} | ${vpp_node}
181 | | ... | ${vpp_node_if} | ${bd_id}
182 | | ${mac}= | Get Interface Mac | ${dest_node} | ${dest_node_if}
183 | | Vpp Add L2fib Entry | ${vpp_node} | ${mac} | ${vpp_node_if} | ${bd_id}
185 | VM for Vhost L2BD forwarding is setup
186 | | [Documentation] | Setup QEMU and start VM with two vhost interfaces.
188 | | ... | *Arguments:*
189 | | ... | - ${node} - DUT node to start VM on. Type: dictionary
190 | | ... | - ${sock1} - Socket path for first Vhost-User interface. Type: string
191 | | ... | - ${sock2} - Socket path for second Vhost-User interface. Type: string
193 | | ... | _NOTE:_ This KW sets following test case variable:
194 | | ... | -${vm_node} - VM node info. Type: dictionary
198 | | ... | \| VM for Vhost L2BD forwarding is setup \| ${nodes['DUT1']} \
199 | | ... | \| /tmp/sock1 \| /tmp/sock2
200 | | [Arguments] | ${node} | ${sock1} | ${sock2}
201 | | Set Test Variable | ${vm_node} | ${None}
202 | | Qemu Set Node | ${node}
203 | | Qemu Add Vhost User If | ${sock1}
204 | | Qemu Add Vhost User If | ${sock2}
205 | | ${vm}= | Qemu Start
206 | | ${br}= | Set Variable | br0
207 | | ${vhost1}= | Get Vhost User If Name By Sock | ${vm} | ${sock1}
208 | | ${vhost2}= | Get Vhost User If Name By Sock | ${vm} | ${sock2}
209 | | Linux Add Bridge | ${vm} | ${br} | ${vhost1} | ${vhost2}
210 | | Set Interface State | ${vm} | ${vhost1} | up
211 | | Set Interface State | ${vm} | ${vhost2} | up
212 | | Set Interface State | ${vm} | ${br} | up
213 | | Set Test Variable | ${vm_node} | ${vm}
215 | VPP Vhost interfaces for L2BD forwarding are setup
216 | | [Documentation] | Create two Vhost-User interfaces on defined VPP node.
218 | | ... | *Arguments:*
219 | | ... | - ${node} - DUT node. Type: dictionary
220 | | ... | - ${sock1} - Socket path for first Vhost-User interface. Type: string
221 | | ... | - ${sock2} - Socket path for second Vhost-User interface. Type: string
223 | | ... | _NOTE:_ This KW sets following test case variable:
224 | | ... | - ${vhost_if1} - First Vhost-User interface.
225 | | ... | - ${vhost_if2} - Second Vhost-User interface.
229 | | ... | \| VPP Vhost interfaces for L2BD forwarding are setup \
230 | | ... | \| ${nodes['DUT1']} \| /tmp/sock1 \| /tmp/sock2
231 | | [Arguments] | ${node} | ${sock1} | ${sock2}
232 | | ${vhost_if1}= | Vpp Create Vhost User Interface | ${node} | ${sock1}
233 | | ${vhost_if2}= | Vpp Create Vhost User Interface | ${node} | ${sock2}
234 | | Set Test Variable | ${vhost_if1}
235 | | Set Test Variable | ${vhost_if2}