b4dd1d117dce8a7e9c05042c5f25fc8357d613a3
[csit.git] / resources / libraries / robot / lxc.robot
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:
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 | 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
19
20 *** Keywords ***
21 | Create LXC container on DUT node
22 | | [Documentation] | Setup lxc container on DUT node.
23 | | ...
24 | | ... | *Arguments:*
25 | | ...
26 | | ... | - dut_node - DUT node. Type: dictionary
27 | | ... | - lxc_name - Name of LXC container. Type: dictionary
28 | | ...
29 | | ... | *Example:*
30 | | ...
31 | | ... | \| Create LXC container on DUT node \| ${nodes['DUT1']} \
32 | | ... | \| DUT1_slave_1 \|
33 | | ...
34 | | [Arguments] | ${dut_node} | ${lxc_name}
35 | | ...
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}.Container create | force_create=${TRUE}
40 | | Run keyword | ${lxc_name}.Mount host dir in container
41
42 | Create LXC container on DUT node with cpuset
43 | | [Documentation] | Create LXC container on DUT node with cpuset.
44 | | ...
45 | | ... | *Arguments:*
46 | | ...
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:
51 | | ... | integer
52 | | ...
53 | | ... | *Example:*
54 | | ...
55 | | ... | \| Create LXC container on DUT node with cpuset \
56 | | ... | \| ${nodes['DUT1']} \| DUT1_slave_1 \| 6 \| 1 \|
57 | | ...
58 | | [Arguments] | ${dut_node} | ${lxc_name} | ${skip}=${6} | ${count}=${1}
59 | | ...
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 | | Run keyword | ${lxc_name}.Set node | ${dut_node}
67 | | Run keyword | ${lxc_name}.Container create | force_create=${TRUE}
68 | | Run keyword | ${lxc_name}.Mount host dir in container
69 | | Run keyword | ${lxc_name}.Container cpuset cpus | ${lxc_cpus}
70
71 | Create '${nr}' LXC containers on '${dut}' node
72 | | [Documentation] | Create and start multiple lxc containers on DUT node.
73 | | ...
74 | | ... | *Example:*
75 | | ...
76 | | ... | \| Create 5 LXC containers on DUT1 node \|
77 | | ...
78 | | :FOR | ${number} | IN RANGE | 1 | ${nr}+1
79 | | | Create LXC container on DUT node | ${nodes['${dut}']}
80 | | | ... | ${dut}_${lxc_base_name}_${number}
81
82 | Create '${nr}' LXC containers on all DUT nodes
83 | | [Documentation] | Create and start multiple LXC containers on all DUT nodes.
84 | | ...
85 | | ... | *Example:*
86 | | ...
87 | | ... | \| Create 5 LXC containers on all DUT nodes \|
88 | | ...
89 | | ${duts}= | Get Matches | ${nodes} | DUT*
90 | | :FOR | ${dut} | IN | @{duts}
91 | | | Create '${nr}' LXC containers on '${dut}' node
92
93 | Create '${nr}' LXC containers on '${dut}' node with '${count}' cpus
94 | | [Documentation] | Create and start multiple LXC containers on DUT node.
95 | | ... | Set the cpuset.cpus cgroup profile for pin of cpus.
96 | | ...
97 | | ... | *Example:*
98 | | ...
99 | | ... | \| Create 5 LXC containers on DUT1 node with 2 cpus \|
100 | | ...
101 | | ${skip_cpus}= | Evaluate | ${vpp_cpus}+${system_cpus}
102 | | ${count_int}= | Convert To Integer | ${count}
103 | | ${duts}= | Get Matches | ${nodes} | DUT*
104 | | :FOR | ${number} | IN RANGE | 1 | ${nr}+1
105 | | | ${skip}= | Evaluate | ${skip_cpus} + (${nr} - 1) * ${count}
106 | | | Create LXC container on DUT node with cpuset | ${nodes['${dut}']}
107 | | | ... | ${dut}_${lxc_base_name}_${number} | ${skip} | ${count_int}
108
109 | Create '${nr}' LXC containers on all DUT nodes with '${count}' cpus
110 | | [Documentation] | Create and start multiple LXC containers on all DUT nodes.
111 | | ... | Set the cpuset.cpus cgroup profile for pin of cpus.
112 | | ...
113 | | ... | *Example:*
114 | | ...
115 | | ... | \| Create 5 LXC containers on all DUT nodes with 2 cpus \|
116 | | ...
117 | | ${duts}= | Get Matches | ${nodes} | DUT*
118 | | :FOR | ${dut} | IN | @{duts}
119 | | | Create '${nr}' LXC containers on '${dut}' node with '${count}' cpus
120
121 | Destroy LXC container on DUT node
122 | | [Documentation] | Stop and destroy LXC container on DUT node.
123 | | ...
124 | | ... | *Arguments:*
125 | | ...
126 | | ... | - dut_node - DUT node. Type: dictionary
127 | | ... | - lxc_name - Name of LXC container. Type: dictionary
128 | | ...
129 | | ... | *Example:*
130 | | ...
131 | | ... | \| Destroy LXC container on DUT node \| ${nodes['DUT1']} \
132 | | ... | \| DUT1_slave_1 \|
133 | | ...
134 | | [Arguments] | ${dut_node} | ${lxc_name}
135 | | ...
136 | | Import Library | resources.libraries.python.LXCUtils
137 | | ... | container_name=${lxc_name} | WITH NAME | ${lxc_name}
138 | | Run keyword | ${lxc_name}.Set node | ${dut_node}
139 | | Run keyword | ${lxc_name}.Container destroy
140
141 | Destroy '${nr}' LXC containers on '${dut}' node
142 | | [Documentation] | Stop and destroy multiple LXC containers on DUT node.
143 | | ...
144 | | ... | *Example:*
145 | | ...
146 | | ... | \| Destroy 5 LXC containers on DUT1 node \|
147 | | ...
148 | | :FOR | ${number} | IN RANGE | 1 | ${nr}+1
149 | | | Destroy LXC container on DUT node | ${nodes['${dut}']}
150 | | | ... | ${dut}_${lxc_base_name}_${number}
151
152 | Destroy '${nr}' LXC containers on all DUT nodes
153 | | [Documentation] | Stop and destroy multiple LXC containers on all DUT nodes.
154 | | ...
155 | | ... | *Example:*
156 | | ...
157 | | ... | \| Destroy 5 LXC containers on all DUT nodes \|
158 | | ...
159 | | ${duts}= | Get Matches | ${nodes} | DUT*
160 | | :FOR | ${dut} | IN | @{duts}
161 | | | Destroy '${nr}' LXC containers on '${dut}' node
162
163 | Install VPP on LXC container on DUT node
164 | | [Documentation] | Install vpp on LXC container on DUT node.
165 | | ...
166 | | ... | *Arguments:*
167 | | ...
168 | | ... | - dut_node - DUT node. Type: dictionary
169 | | ... | - lxc_name - Name of LXC container. Type: dictionary
170 | | ...
171 | | ... | *Example:*
172 | | ...
173 | | ... | \| Install VPP on LXC container on DUT node \| ${nodes['DUT1']} \
174 | | ... | \| DUT1_slave_1 \|
175 | | ...
176 | | [Arguments] | ${dut_node} | ${lxc_name}
177 | | ...
178 | | Import Library | resources.libraries.python.LXCUtils
179 | | ... | container_name=${lxc_name} | WITH NAME | ${lxc_name}
180 | | Run keyword | ${lxc_name}.Set node | ${dut_node}
181 | | Run keyword | ${lxc_name}.Install VPP in container
182
183 | Install VPP on '${nr}' LXC containers on '${dut}' node
184 | | [Documentation] | Install VPP on multiple LXC containers on DUT node.
185 | | ...
186 | | ... | *Example:*
187 | | ...
188 | | ... | \| Install VPP on 5 LXC containers on DUT1 node \|
189 | | ...
190 | | :FOR | ${number} | IN RANGE | 1 | ${nr}+1
191 | | | Install VPP on LXC container on DUT node | ${nodes['${dut}']}
192 | | | ... | ${dut}_${lxc_base_name}_${number}
193
194 | Install VPP on '${nr}' LXC containers on all DUT nodes
195 | | [Documentation] | Install VPP on multiple LXC containers on all DUT nodes.
196 | | ...
197 | | ... | *Example:*
198 | | ...
199 | | ... | \| Install VPP on 5 LXC containers on all DUT nodes \|
200 | | ...
201 | | ${duts}= | Get Matches | ${nodes} | DUT*
202 | | :FOR | ${dut} | IN | @{duts}
203 | | | Install VPP on '${nr}' LXC containers on '${dut}' node
204
205 | Create startup configuration of VPP on LXC container on DUT node
206 | | [Documentation] | Create base startup configuration of VPP on LXC container
207 | | ... | on DUT node.
208 | | ...
209 | | ... | *Arguments:*
210 | | ...
211 | | ... | - dut_node - DUT node. Type: dictionary
212 | | ... | - lxc_name - Name of LXC container. Type: dictionary
213 | | ...
214 | | ... | *Example:*
215 | | ...
216 | | ... | \| Create startup configuration of VPP on LXC container on DUT node \
217 | | ... | \| ${nodes['DUT1']} \| DUT1_slave_1 \|
218 | | ...
219 | | [Arguments] | ${dut_node} | ${lxc_name}
220 | | ...
221 | | Import Library | resources.libraries.python.VppConfigGenerator
222 | | ... | WITH NAME | ${lxc_name}_conf
223 | | Run keyword | ${lxc_name}_conf.Set node | ${dut_node}
224 | | Run keyword | ${lxc_name}_conf.Add unix CLI listen
225 | | Run keyword | ${lxc_name}_conf.Add unix nodaemon
226 | | Run keyword | ${lxc_name}_conf.Add plugin disable | "dpdk_plugin.so"
227 | | Run Keyword | ${lxc_name}_conf.Apply config LXC | ${lxc_name}
228
229 | Create startup configuration of VPP on '${nr}' LXC containers on '${dut}' node
230 | | [Documentation] | Create base startup configuration of VPP on multiple LXC
231 | | ... | container on DUT node.
232 | | ...
233 | | ... | *Example:*
234 | | ...
235 | | ... | \| Create startup configuration of VPP on 1 LXC containers on DUT1 \
236 | | ... | node \|
237 | | ...
238 | | :FOR | ${number} | IN RANGE | 1 | ${nr}+1
239 | | | Create startup configuration of VPP on LXC container on DUT node
240 | | | ... | ${nodes['${dut}']} | ${dut}_${lxc_base_name}_${number}
241
242 | Create startup configuration of VPP on '${nr}' LXC containers on all DUT nodes
243 | | [Documentation] | Create base startup configuration of VPP on multiple LXC
244 | | ... | container on all DUT nodes.
245 | | ...
246 | | ... | *Example:*
247 | | ...
248 | | ... | \| Create startup configuration of VPP on 1 LXC containers on all \
249 | | ... | DUT nodes \|
250 | | ...
251 | | ${duts}= | Get Matches | ${nodes} | DUT*
252 | | :FOR | ${dut} | IN | @{duts}
253 | | | Create startup configuration of VPP on '${nr}' LXC containers on '${dut}' node