FIX: IPUtil after vpp api changes
[csit.git] / resources / libraries / robot / shared / container.robot
1 # Copyright (c) 2019 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 containers
16 | ...
17 | Library | resources.libraries.python.CpuUtils
18 | Library | resources.libraries.python.topology.Topology
19
20 *** Keywords ***
21 | Construct container on all DUTs
22 | | [Documentation] | Construct 1 CNF of specific technology on all DUT nodes.
23 | | ...
24 | | ... | *Arguments:*
25 | | ... | - nf_chains: Total number of chains (Optional). Type: integer, default
26 | | ... | value: ${1}
27 | | ... | - nf_nodes: Total number of nodes per chain (Optional). Type: integer,
28 | | ... | default value: ${1}
29 | | ... | - nf_chain: Chain ID (Optional). Type: integer, default value: ${1}
30 | | ... | - nf_node: Node ID (Optional). Type: integer, default value: ${1}
31 | | ... | - auto_scale - If True, use same amount of Dataplane threads for
32 | | ... |   network function as DUT, otherwise use single physical core for
33 | | ... |   every network function. Type: boolean
34 | | ... | - nested: Set True if starting nested containers.
35 | | ... | Type: boolean, default value: ${False}
36 | | ...
37 | | ... | *Example:*
38 | | ...
39 | | ... | \| Construct container on all DUTs \| 1 \| 1 \| 1 \| 1 \| ${True} \|
40 | | ...
41 | | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1} | ${nf_chain}=${1}
42 | | ... | ${nf_node}=${1} | ${auto_scale}=${True} | ${nested}=${False}
43 | | ...
44 | | ${nf_dtcr_status} | ${value}= | Run Keyword And Ignore Error
45 | | ... | Variable Should Exist | ${nf_dtcr}
46 | | ${nf_dtcr}= | Run Keyword If | '${nf_dtcr_status}' == 'PASS'
47 | | ... | Set Variable | ${nf_dtcr} | ELSE | Set Variable | ${1}
48 | | ${nf_dtc}= | Run Keyword Unless | ${nested}
49 | | ... | Set Variable If | ${auto_scale} | ${cpu_count_int}
50 | | ... | ${nf_dtc}
51 | | ${duts}= | Get Matches | ${nodes} | DUT*
52 | | :FOR | ${dut} | IN | @{duts}
53 | | | ${nf_id}= | Evaluate | (${nf_chain} - ${1}) * ${nf_nodes} + ${nf_node}
54 | | | ${env}= | Create List | DEBIAN_FRONTEND=noninteractive
55 | | | ${uuid}= | Get Variable Value | ${dcr_uuid} | ${Empty}
56 | | | ${root}= | Get Variable Value | ${dcr_root} | ${Empty}
57 | | | ${mnt}= | Create List
58 | | | ... | ${root}/tmp/:/mnt/host/
59 | | | ... | ${root}/dev/vfio/:/dev/vfio/
60 | | | ... | ${root}/usr/bin/vpp:/usr/bin/vpp
61 | | | ... | ${root}/usr/bin/vppctl:/usr/bin/vppctl
62 | | | ... | ${root}/usr/lib/x86_64-linux-gnu/:/usr/lib/x86_64-linux-gnu/
63 | | | ... | ${root}/usr/share/vpp/:/usr/share/vpp/
64 | | | ${nf_cpus}= | Set Variable | ${None}
65 | | | ${nf_cpus}= | Run Keyword Unless | ${nested}
66 | | | ... | Get Affinity NF | ${nodes} | ${dut}
67 | | | ... | nf_chains=${nf_chains} | nf_nodes=${nf_nodes}
68 | | | ... | nf_chain=${nf_chain} | nf_node=${nf_node}
69 | | | ... | vs_dtc=${cpu_count_int} | nf_dtc=${nf_dtc} | nf_dtcr=${nf_dtcr}
70 | | | &{cont_args}= | Create Dictionary
71 | | | ... | name=${dut}_${container_group}${nf_id}${uuid}
72 | | | ... | node=${nodes['${dut}']} | mnt=${mnt} | env=${env}
73 | | | Run Keyword Unless | ${nested}
74 | | | ... | Set To Dictionary | ${cont_args} | cpuset_cpus=${nf_cpus}
75 | | | Run Keyword | ${container_group}.Construct container | &{cont_args}
76
77 | Construct chain of containers on all DUTs
78 | | [Documentation] | Construct 1 chain of 1..N CNFs on all DUT nodes.
79 | | ...
80 | | ... | *Arguments:*
81 | | ... | - nf_chains: Total number of chains. Type: integer
82 | | ... | - nf_nodes: Total number of nodes per chain. Type: integer
83 | | ... | - nf_chain: Chain ID. Type: integer
84 | | ... | - auto_scale - If True, use same amount of Dataplane threads for
85 | | ... |   network function as DUT, otherwise use single physical core for
86 | | ... |   every network function. Type: boolean
87 | | ... | - nested: Set True if starting nested containers.
88 | | ... | Type: boolean, default value: ${False}
89 | | ...
90 | | ... | *Example:*
91 | | ...
92 | | ... | \| Construct chain of containers on all DUTs \| 1 \| 1 \| 1 \
93 | | ... | \| ${True} \|
94 | | ...
95 | | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1} | ${nf_chain}=${1}
96 | | ... | ${auto_scale}=${True} | ${nested}=${False}
97 | | ...
98 | | :FOR | ${nf_node} | IN RANGE | 1 | ${nf_nodes}+1
99 | | | Construct container on all DUTs | nf_chains=${nf_chains}
100 | | | ... | nf_nodes=${nf_nodes} | nf_chain=${nf_chain} | nf_node=${nf_node}
101 | | | ... | auto_scale=${auto_scale} | nested=${nested}
102
103 | Construct chains of containers on all DUTs
104 | | [Documentation] | Construct 1..N chains of 1..N CNFs on all DUT nodes.
105 | | ...
106 | | ... | *Arguments:*
107 | | ... | - nf_chains: Total number of chains (Optional). Type: integer, default
108 | | ... | value: ${1}
109 | | ... | - nf_nodes: Total number of nodes per chain (Optional). Type: integer,
110 | | ... | default value: ${1}
111 | | ... | - auto_scale - If True, use same amount of Dataplane threads for
112 | | ... |   network function as DUT, otherwise use single physical core for
113 | | ... |   every network function. Type: boolean
114 | | ... | - nested: Set True if starting nested containers.
115 | | ... | Type: boolean, default value: ${False}
116 | | ...
117 | | ... | *Example:*
118 | | ...
119 | | ... | \| Construct chains of containers on all DUTs \| 1 \| 1 \|
120 | | ...
121 | | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1} | ${auto_scale}=${True}
122 | | ... | ${nested}=${False}
123 | | ...
124 | | :FOR | ${nf_chain} | IN RANGE | 1 | ${nf_chains}+1
125 | | | Construct chain of containers on all DUTs | nf_chains=${nf_chains}
126 | | | ... | nf_nodes=${nf_nodes} | nf_chain=${nf_chain}
127 | | | ... | auto_scale=${auto_scale} | nested=${nested}
128
129 | Acquire all '${group}' containers
130 | | [Documentation] | Acquire all container(s) in specific container group on
131 | | ... | all DUT nodes.
132 | | ...
133 | | Run Keyword | ${group}.Acquire all containers
134
135 | Create all '${group}' containers
136 | | [Documentation] | Create/deploy all container(s) in specific container group
137 | | ... | on all DUT nodes.
138 | | ...
139 | | Run Keyword | ${group}.Create all containers
140
141 | Start VPP in all '${group}' containers
142 | | [Documentation] | Start VPP on all container(s) in specific container
143 | | ... | group on all DUT nodes.
144 | | ...
145 | | Run Keyword | ${group}.Start VPP In All Containers
146
147 | Restart VPP in all '${group}' containers
148 | | [Documentation] | Restart VPP on all container(s) in specific container
149 | | ... | group on all DUT nodes.
150 | | ...
151 | | Run Keyword | ${group}.Restart VPP In All Containers
152
153 | Configure VPP in all '${group}' containers
154 | | [Documentation] | Configure VPP on all container(s) in specific container
155 | | ... | group on all DUT nodes.
156 | | ...
157 | | ${dut1_if2} = | Get Variable Value | \${dut1_if2} | ${None}
158 | | ${dut2_if2} = | Get Variable Value | \${dut2_if2} | ${None}
159 | | Run Keyword If | '${container_chain_topology}' == 'chain_ip4'
160 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
161 | | ... | tg_if1_mac=${tg_if1_mac} | tg_if2_mac=${tg_if2_mac}
162 | | ... | nodes=${nf_nodes}
163 | | ... | ELSE IF | '${container_chain_topology}' == 'pipeline_ip4'
164 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
165 | | ... | tg_if1_mac=${tg_if1_mac} | tg_if2_mac=${tg_if2_mac}
166 | | ... | nodes=${nf_nodes}
167 | | ... | ELSE IF | '${container_chain_topology}' == 'cross_horiz'
168 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
169 | | ... | dut1_if=${dut1_if2} | dut2_if=${dut2_if2}
170 | | ... | ELSE
171 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
172
173 | Stop all '${group}' containers
174 | | [Documentation] | Stop all container(s) in specific container group on all
175 | | ... | DUT nodes.
176 | | ...
177 | | Run Keyword | ${group}.Stop all containers
178
179 | Destroy all '${group}' containers
180 | | [Documentation] | Destroy all container(s) in specific container group on
181 | | ... | all DUT nodes.
182 | | ...
183 | | Run Keyword | ${group}.Destroy all containers
184
185 | Start containers for performance test
186 | | [Documentation]
187 | | ... | Start containers for performance test.
188 | | ...
189 | | ... | *Arguments:*
190 | | ... | - nf_chains: Total number of chains. Type: integer
191 | | ... | - nf_nodes: Total number of nodes per chain. Type: integer
192 | | ... | - auto_scale - If True, use same amount of Dataplane threads for
193 | | ... |   network function as DUT, otherwise use single physical core for
194 | | ... |   every network function. Type: boolean
195 | | ...
196 | | ... | *Example:*
197 | | ...
198 | | ... | \| Start containers for performance test \| 1 \| 1 \|
199 | | ...
200 | | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1} | ${auto_scale}=${True}
201 | | ...
202 | | Set Test Variable | @{container_groups} | @{EMPTY}
203 | | Set Test Variable | ${container_group} | CNF
204 | | Set Test Variable | ${nf_nodes}
205 | | Import Library | resources.libraries.python.ContainerUtils.ContainerManager
206 | | ... | engine=${container_engine} | WITH NAME | ${container_group}
207 | | Construct chains of containers on all DUTs | ${nf_chains} | ${nf_nodes}
208 | | ... | auto_scale=${auto_scale}
209 | | Acquire all '${container_group}' containers
210 | | Create all '${container_group}' containers
211 | | Configure VPP in all '${container_group}' containers
212 | | Stop VPP service on all DUTs | ${nodes}
213 | | Start VPP in all '${container_group}' containers
214 | | Restart VPP service on all DUTs | ${nodes}
215 | | Verify VPP on all DUTs | ${nodes}
216 | | Save VPP PIDs
217 | | Append To List | ${container_groups} | ${container_group}
218
219 | Start containers for device test
220 | | [Documentation]
221 | | ... | Start containers for device test.
222 | | ...
223 | | ... | *Arguments:*
224 | | ... | - nf_chains: Total number of chains (Optional). Type: integer, default
225 | | ... | value: ${1}
226 | | ... | - nf_nodes: Total number of nodes per chain (Optional). Type: integer,
227 | | ... | default value: ${1}
228 | | ...
229 | | ... | _NOTE:_ This KW sets following test case variables:
230 | | ... | - dcr_uuid - Parent container UUID.
231 | | ... | - dcr_root - Parent container overlay.
232 | | ...
233 | | ... | *Example:*
234 | | ...
235 | | ... | \| Set up functional test with containers \| 1 \| 1 \|
236 | | ...
237 | | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1}
238 | | ...
239 | | Set Test Variable | @{container_groups} | @{EMPTY}
240 | | Set Test Variable | ${container_group} | CNF
241 | | Import Library | resources.libraries.python.ContainerUtils.ContainerManager
242 | | ... | engine=${container_engine} | WITH NAME | ${container_group}
243 | | ...
244 | | ${dcr_uuid}= | Get Environment Variable | CSIT_DUT1_UUID
245 | | ${dcr_root}= | Run Keyword | Get Docker Mergeddir | ${nodes['DUT1']}
246 | | ... | ${dcr_uuid}
247 | | Set Test Variable | ${dcr_uuid}
248 | | Set Test Variable | ${dcr_root}
249 | | ...
250 | | Construct chains of containers on all DUTs | ${nf_chains} | ${nf_nodes}
251 | | ... | nested=${True}
252 | | Acquire all '${container_group}' containers
253 | | Create all '${container_group}' containers
254 | | Configure VPP in all '${container_group}' containers
255 | | Start VPP in all '${container_group}' containers
256 | | Append To List | ${container_groups} | ${container_group}