CSIT-651 Add keywords and template for memif
[csit.git] / resources / libraries / robot / shared / 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}.Create container | 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 | | 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}
71
72 | Create '${nr}' LXC containers on '${dut}' node
73 | | [Documentation] | Create and start multiple lxc containers on DUT node.
74 | | ...
75 | | ... | *Example:*
76 | | ...
77 | | ... | \| Create 5 LXC containers on DUT1 node \|
78 | | ...
79 | | :FOR | ${number} | IN RANGE | 1 | ${nr}+1
80 | | | Create LXC container on DUT node | ${nodes['${dut}']}
81 | | | ... | ${dut}_${lxc_base_name}_${number}
82
83 | Create '${nr}' LXC containers on all DUT nodes
84 | | [Documentation] | Create and start multiple LXC containers on all DUT nodes.
85 | | ...
86 | | ... | *Example:*
87 | | ...
88 | | ... | \| Create 5 LXC containers on all DUT nodes \|
89 | | ...
90 | | ${duts}= | Get Matches | ${nodes} | DUT*
91 | | :FOR | ${dut} | IN | @{duts}
92 | | | Create '${nr}' LXC containers on '${dut}' node
93
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.
97 | | ...
98 | | ... | *Example:*
99 | | ...
100 | | ... | \| Create 5 LXC containers on DUT1 node with 2 cpus \|
101 | | ...
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}
109
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.
113 | | ...
114 | | ... | *Example:*
115 | | ...
116 | | ... | \| Create 5 LXC containers on all DUT nodes with 2 cpus \|
117 | | ...
118 | | ${duts}= | Get Matches | ${nodes} | DUT*
119 | | :FOR | ${dut} | IN | @{duts}
120 | | | Create '${nr}' LXC containers on '${dut}' node with '${count}' cpus
121
122 | Destroy LXC container on DUT node
123 | | [Documentation] | Stop and destroy LXC container on DUT node.
124 | | ...
125 | | ... | *Arguments:*
126 | | ...
127 | | ... | - dut_node - DUT node. Type: dictionary
128 | | ... | - lxc_name - Name of LXC container. Type: dictionary
129 | | ...
130 | | ... | *Example:*
131 | | ...
132 | | ... | \| Destroy LXC container on DUT node \| ${nodes['DUT1']} \
133 | | ... | \| DUT1_slave_1 \|
134 | | ...
135 | | [Arguments] | ${dut_node} | ${lxc_name}
136 | | ...
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
141
142 | Destroy '${nr}' LXC containers on '${dut}' node
143 | | [Documentation] | Stop and destroy multiple LXC containers on DUT node.
144 | | ...
145 | | ... | *Example:*
146 | | ...
147 | | ... | \| Destroy 5 LXC containers on DUT1 node \|
148 | | ...
149 | | :FOR | ${number} | IN RANGE | 1 | ${nr}+1
150 | | | Destroy LXC container on DUT node | ${nodes['${dut}']}
151 | | | ... | ${dut}_${lxc_base_name}_${number}
152
153 | Destroy '${nr}' LXC containers on all DUT nodes
154 | | [Documentation] | Stop and destroy multiple LXC containers on all DUT nodes.
155 | | ...
156 | | ... | *Example:*
157 | | ...
158 | | ... | \| Destroy 5 LXC containers on all DUT nodes \|
159 | | ...
160 | | ${duts}= | Get Matches | ${nodes} | DUT*
161 | | :FOR | ${dut} | IN | @{duts}
162 | | | Destroy '${nr}' LXC containers on '${dut}' node
163
164 | Install VPP on LXC container on DUT node
165 | | [Documentation] | Install vpp on LXC container on DUT node.
166 | | ...
167 | | ... | *Arguments:*
168 | | ...
169 | | ... | - dut_node - DUT node. Type: dictionary
170 | | ... | - lxc_name - Name of LXC container. Type: dictionary
171 | | ...
172 | | ... | *Example:*
173 | | ...
174 | | ... | \| Install VPP on LXC container on DUT node \| ${nodes['DUT1']} \
175 | | ... | \| DUT1_slave_1 \|
176 | | ...
177 | | [Arguments] | ${dut_node} | ${lxc_name}
178 | | ...
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
183
184 | Install VPP on '${nr}' LXC containers on '${dut}' node
185 | | [Documentation] | Install VPP on multiple LXC containers on DUT node.
186 | | ...
187 | | ... | *Example:*
188 | | ...
189 | | ... | \| Install VPP on 5 LXC containers on DUT1 node \|
190 | | ...
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}
194
195 | Install VPP on '${nr}' LXC containers on all DUT nodes
196 | | [Documentation] | Install VPP on multiple LXC containers on all DUT nodes.
197 | | ...
198 | | ... | *Example:*
199 | | ...
200 | | ... | \| Install VPP on 5 LXC containers on all DUT nodes \|
201 | | ...
202 | | ${duts}= | Get Matches | ${nodes} | DUT*
203 | | :FOR | ${dut} | IN | @{duts}
204 | | | Install VPP on '${nr}' LXC containers on '${dut}' node
205
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.
209 | | ...
210 | | ... | *Arguments:*
211 | | ...
212 | | ... | - dut_node - DUT node. Type: dictionary
213 | | ... | - lxc_name - Name of LXC container. Type: dictionary
214 | | ...
215 | | ... | *Example:*
216 | | ...
217 | | ... | \| Create startup configuration of VPP on LXC container on DUT node \
218 | | ... | \| ${nodes['DUT1']} \| DUT1_slave_1 \|
219 | | ...
220 | | [Arguments] | ${dut_node} | ${lxc_name}
221 | | ...
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}
231
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.
235 | | ...
236 | | ... | *Example:*
237 | | ...
238 | | ... | \| Create startup configuration of VPP on 1 LXC containers on DUT1 \
239 | | ... | node \|
240 | | ...
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}
244
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.
248 | | ...
249 | | ... | *Example:*
250 | | ...
251 | | ... | \| Create startup configuration of VPP on 1 LXC containers on all \
252 | | ... | DUT nodes \|
253 | | ...
254 | | ${duts}= | Get Matches | ${nodes} | DUT*
255 | | :FOR | ${dut} | IN | @{duts}
256 | | | Create startup configuration of VPP on '${nr}' LXC containers on '${dut}' node