1 # Copyright (c) 2017 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 | Documentation | Keywords related to linux container (LXC)
16 | Library | resources.libraries.python.LXCUtils
17 | Library | resources.libraries.python.CpuUtils
18 | Library | resources.libraries.python.topology.Topology
21 | Create LXC container on DUT node
22 | | [Documentation] | Setup lxc container on DUT node.
24 | | ... | *Arguments:*
26 | | ... | - dut_node - DUT node. Type: dictionary
27 | | ... | - lxc_name - Name of LXC container. Type: dictionary
31 | | ... | \| Create LXC container on DUT node \| ${nodes['DUT1']} \
32 | | ... | \| DUT1_slave_1 \|
34 | | [Arguments] | ${dut_node} | ${lxc_name}
36 | | Import Library | resources.libraries.python.LXCUtils
37 | | ... | container_name=${lxc_name} | WITH NAME | ${lxc_name}
38 | | Run keyword | ${lxc_name}.Set node | ${dut_node}
39 | | Run keyword | ${lxc_name}.Create container | force_create=${TRUE}
40 | | Run keyword | ${lxc_name}.Mount host dir in container
42 | Create LXC container on DUT node with cpuset
43 | | [Documentation] | Create LXC container on DUT node with cpuset.
45 | | ... | *Arguments:*
47 | | ... | - dut_node - DUT node. Type: dictionary
48 | | ... | - lxc_name - Name of LXC container. Type: dictionary
49 | | ... | - skip - number of cpus which will be skipped. Type: integer
50 | | ... | - count - number of cpus which will be allocated for lxc. Type:
55 | | ... | \| Create LXC container on DUT node with cpuset \
56 | | ... | \| ${nodes['DUT1']} \| DUT1_slave_1 \| 6 \| 1 \|
58 | | [Arguments] | ${dut_node} | ${lxc_name} | ${skip}=${6} | ${count}=${1}
60 | | Import Library | resources.libraries.python.LXCUtils
61 | | ... | container_name=${lxc_name} | WITH NAME | ${lxc_name}
62 | | ${dut_numa}= | Get interfaces numa node | ${dut_node}
63 | | ... | ${dut1_if1} | ${dut1_if2}
64 | | ${lxc_cpus}= | CPU list per node str | ${dut_node} | ${dut_numa}
65 | | ... | skip_cnt=${skip} | cpu_cnt=${count} | smt_used=${False}
66 | | Set Suite Variable | ${lxc_cpus}
67 | | Run keyword | ${lxc_name}.Set node | ${dut_node}
68 | | Run keyword | ${lxc_name}.Create container | force_create=${TRUE}
69 | | Run keyword | ${lxc_name}.Mount host dir in container
70 | | Run keyword | ${lxc_name}.Container cpuset cpus | 0,${lxc_cpus}
72 | Create '${nr}' LXC containers on '${dut}' node
73 | | [Documentation] | Create and start multiple lxc containers on DUT node.
77 | | ... | \| Create 5 LXC containers on DUT1 node \|
79 | | :FOR | ${number} | IN RANGE | 1 | ${nr}+1
80 | | | Create LXC container on DUT node | ${nodes['${dut}']}
81 | | | ... | ${dut}_${lxc_base_name}_${number}
83 | Create '${nr}' LXC containers on all DUT nodes
84 | | [Documentation] | Create and start multiple LXC containers on all DUT nodes.
88 | | ... | \| Create 5 LXC containers on all DUT nodes \|
90 | | ${duts}= | Get Matches | ${nodes} | DUT*
91 | | :FOR | ${dut} | IN | @{duts}
92 | | | Create '${nr}' LXC containers on '${dut}' node
94 | Create '${nr}' LXC containers on '${dut}' node with '${count}' cpus
95 | | [Documentation] | Create and start multiple LXC containers on DUT node.
96 | | ... | Set the cpuset.cpus cgroup profile for pin of cpus.
100 | | ... | \| Create 5 LXC containers on DUT1 node with 2 cpus \|
102 | | ${skip_cpus}= | Evaluate | ${vpp_cpus}+${system_cpus}
103 | | ${count_int}= | Convert To Integer | ${count}
104 | | ${duts}= | Get Matches | ${nodes} | DUT*
105 | | :FOR | ${number} | IN RANGE | 1 | ${nr}+1
106 | | | ${skip}= | Evaluate | ${skip_cpus} + (${nr} - 1) * ${count}
107 | | | Create LXC container on DUT node with cpuset | ${nodes['${dut}']}
108 | | | ... | ${dut}_${lxc_base_name}_${number} | ${skip} | ${count_int}
110 | Create '${nr}' LXC containers on all DUT nodes with '${count}' cpus
111 | | [Documentation] | Create and start multiple LXC containers on all DUT nodes.
112 | | ... | Set the cpuset.cpus cgroup profile for pin of cpus.
116 | | ... | \| Create 5 LXC containers on all DUT nodes with 2 cpus \|
118 | | ${duts}= | Get Matches | ${nodes} | DUT*
119 | | :FOR | ${dut} | IN | @{duts}
120 | | | Create '${nr}' LXC containers on '${dut}' node with '${count}' cpus
122 | Destroy LXC container on DUT node
123 | | [Documentation] | Stop and destroy LXC container on DUT node.
125 | | ... | *Arguments:*
127 | | ... | - dut_node - DUT node. Type: dictionary
128 | | ... | - lxc_name - Name of LXC container. Type: dictionary
132 | | ... | \| Destroy LXC container on DUT node \| ${nodes['DUT1']} \
133 | | ... | \| DUT1_slave_1 \|
135 | | [Arguments] | ${dut_node} | ${lxc_name}
137 | | Import Library | resources.libraries.python.LXCUtils
138 | | ... | container_name=${lxc_name} | WITH NAME | ${lxc_name}
139 | | Run keyword | ${lxc_name}.Set node | ${dut_node}
140 | | Run keyword | ${lxc_name}.Destroy container
142 | Destroy '${nr}' LXC containers on '${dut}' node
143 | | [Documentation] | Stop and destroy multiple LXC containers on DUT node.
147 | | ... | \| Destroy 5 LXC containers on DUT1 node \|
149 | | :FOR | ${number} | IN RANGE | 1 | ${nr}+1
150 | | | Destroy LXC container on DUT node | ${nodes['${dut}']}
151 | | | ... | ${dut}_${lxc_base_name}_${number}
153 | Destroy '${nr}' LXC containers on all DUT nodes
154 | | [Documentation] | Stop and destroy multiple LXC containers on all DUT nodes.
158 | | ... | \| Destroy 5 LXC containers on all DUT nodes \|
160 | | ${duts}= | Get Matches | ${nodes} | DUT*
161 | | :FOR | ${dut} | IN | @{duts}
162 | | | Destroy '${nr}' LXC containers on '${dut}' node
164 | Install VPP on LXC container on DUT node
165 | | [Documentation] | Install vpp on LXC container on DUT node.
167 | | ... | *Arguments:*
169 | | ... | - dut_node - DUT node. Type: dictionary
170 | | ... | - lxc_name - Name of LXC container. Type: dictionary
174 | | ... | \| Install VPP on LXC container on DUT node \| ${nodes['DUT1']} \
175 | | ... | \| DUT1_slave_1 \|
177 | | [Arguments] | ${dut_node} | ${lxc_name}
179 | | Import Library | resources.libraries.python.LXCUtils
180 | | ... | container_name=${lxc_name} | WITH NAME | ${lxc_name}
181 | | Run keyword | ${lxc_name}.Set node | ${dut_node}
182 | | Run keyword | ${lxc_name}.Install VPP in container
184 | Install VPP on '${nr}' LXC containers on '${dut}' node
185 | | [Documentation] | Install VPP on multiple LXC containers on DUT node.
189 | | ... | \| Install VPP on 5 LXC containers on DUT1 node \|
191 | | :FOR | ${number} | IN RANGE | 1 | ${nr}+1
192 | | | Install VPP on LXC container on DUT node | ${nodes['${dut}']}
193 | | | ... | ${dut}_${lxc_base_name}_${number}
195 | Install VPP on '${nr}' LXC containers on all DUT nodes
196 | | [Documentation] | Install VPP on multiple LXC containers on all DUT nodes.
200 | | ... | \| Install VPP on 5 LXC containers on all DUT nodes \|
202 | | ${duts}= | Get Matches | ${nodes} | DUT*
203 | | :FOR | ${dut} | IN | @{duts}
204 | | | Install VPP on '${nr}' LXC containers on '${dut}' node
206 | Create startup configuration of VPP on LXC container on DUT node
207 | | [Documentation] | Create base startup configuration of VPP on LXC container
208 | | ... | on DUT node.
210 | | ... | *Arguments:*
212 | | ... | - dut_node - DUT node. Type: dictionary
213 | | ... | - lxc_name - Name of LXC container. Type: dictionary
217 | | ... | \| Create startup configuration of VPP on LXC container on DUT node \
218 | | ... | \| ${nodes['DUT1']} \| DUT1_slave_1 \|
220 | | [Arguments] | ${dut_node} | ${lxc_name}
222 | | Import Library | resources.libraries.python.VppConfigGenerator
223 | | ... | WITH NAME | ${lxc_name}_conf
224 | | Run keyword | ${lxc_name}_conf.Set node | ${dut_node}
225 | | Run keyword | ${lxc_name}_conf.Add unix CLI listen
226 | | Run keyword | ${lxc_name}_conf.Add unix nodaemon
227 | | Run keyword | ${lxc_name}_conf.Add unix exec | "/tmp/running.exec"
228 | | Run keyword | ${lxc_name}_conf.Add CPU main core | "0"
229 | | Run keyword | ${lxc_name}_conf.Add CPU corelist workers | ${lxc_cpus}
230 | | Run Keyword | ${lxc_name}_conf.Apply config LXC | ${lxc_name}
232 | Create startup configuration of VPP on '${nr}' LXC containers on '${dut}' node
233 | | [Documentation] | Create base startup configuration of VPP on multiple LXC
234 | | ... | container on DUT node.
238 | | ... | \| Create startup configuration of VPP on 1 LXC containers on DUT1 \
241 | | :FOR | ${number} | IN RANGE | 1 | ${nr}+1
242 | | | Create startup configuration of VPP on LXC container on DUT node
243 | | | ... | ${nodes['${dut}']} | ${dut}_${lxc_base_name}_${number}
245 | Create startup configuration of VPP on '${nr}' LXC containers on all DUT nodes
246 | | [Documentation] | Create base startup configuration of VPP on multiple LXC
247 | | ... | container on all DUT nodes.
251 | | ... | \| Create startup configuration of VPP on 1 LXC containers on all \
252 | | ... | DUT nodes \|
254 | | ${duts}= | Get Matches | ${nodes} | DUT*
255 | | :FOR | ${dut} | IN | @{duts}
256 | | | Create startup configuration of VPP on '${nr}' LXC containers on '${dut}' node