CSIT-1539 Aligning FUNC/PERF keywords - Phase III
[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 | | ... | - pinning: Set True if CPU pinning should be done on starting
35 | | ... |   containers. 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} | ${pinning}=${True}
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 If | ${pinning}
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 | | | ${dut1_uuid_length} = | Get Length | ${dut1_uuid}
56 | | | ${root}= | Run Keyword If | ${dut1_uuid_length}
57 | | | ... | Get Docker Mergeddir | ${nodes['DUT1']} | ${dut1_uuid}
58 | | | ... | ELSE | Set Variable | ${EMPTY}
59 | | | ${mnt}= | Create List
60 | | | ... | ${root}/tmp/:/mnt/host/
61 | | | ... | ${root}/dev/vfio/:/dev/vfio/
62 | | | ... | ${root}/usr/bin/vpp:/usr/bin/vpp
63 | | | ... | ${root}/usr/bin/vppctl:/usr/bin/vppctl
64 | | | ... | ${root}/usr/lib/x86_64-linux-gnu/:/usr/lib/x86_64-linux-gnu/
65 | | | ... | ${root}/usr/share/vpp/:/usr/share/vpp/
66 | | | ${nf_cpus}= | Set Variable | ${None}
67 | | | ${nf_cpus}= | Run Keyword If | ${pinning}
68 | | | ... | Get Affinity NF | ${nodes} | ${dut}
69 | | | ... | nf_chains=${nf_chains} | nf_nodes=${nf_nodes}
70 | | | ... | nf_chain=${nf_chain} | nf_node=${nf_node}
71 | | | ... | vs_dtc=${cpu_count_int} | nf_dtc=${nf_dtc} | nf_dtcr=${nf_dtcr}
72 | | | &{cont_args}= | Create Dictionary
73 | | | ... | name=${dut}_${container_group}${nf_id}${dut1_uuid}
74 | | | ... | node=${nodes['${dut}']} | mnt=${mnt} | env=${env}
75 | | | Run Keyword If | ${pinning}
76 | | | ... | Set To Dictionary | ${cont_args} | cpuset_cpus=${nf_cpus}
77 | | | Run Keyword | ${container_group}.Construct container | &{cont_args}
78
79 | Construct chain of containers on all DUTs
80 | | [Documentation] | Construct 1 chain of 1..N CNFs on all DUT nodes.
81 | | ...
82 | | ... | *Arguments:*
83 | | ... | - nf_chains: Total number of chains. Type: integer
84 | | ... | - nf_nodes: Total number of nodes per chain. Type: integer
85 | | ... | - nf_chain: Chain ID. Type: integer
86 | | ... | - auto_scale - If True, use same amount of Dataplane threads for
87 | | ... |   network function as DUT, otherwise use single physical core for
88 | | ... |   every network function. Type: boolean
89 | | ... | - pinning: Set True if CPU pinning should be done on starting
90 | | ... |   containers. Type: boolean, default value: ${False}
91 | | ...
92 | | ... | *Example:*
93 | | ...
94 | | ... | \| Construct chain of containers on all DUTs \| 1 \| 1 \| 1 \
95 | | ... | \| ${True} \|
96 | | ...
97 | | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1} | ${nf_chain}=${1}
98 | | ... | ${auto_scale}=${True} | ${pinning}=${True}
99 | | ...
100 | | :FOR | ${nf_node} | IN RANGE | 1 | ${nf_nodes}+1
101 | | | Construct container on all DUTs | nf_chains=${nf_chains}
102 | | | ... | nf_nodes=${nf_nodes} | nf_chain=${nf_chain} | nf_node=${nf_node}
103 | | | ... | auto_scale=${auto_scale} | pinning=${pinning}
104
105 | Construct chains of containers on all DUTs
106 | | [Documentation] | Construct 1..N chains of 1..N CNFs on all DUT nodes.
107 | | ...
108 | | ... | *Arguments:*
109 | | ... | - nf_chains: Total number of chains (Optional). Type: integer, default
110 | | ... |   value: ${1}
111 | | ... | - nf_nodes: Total number of nodes per chain (Optional). Type: integer,
112 | | ... |   default value: ${1}
113 | | ... | - auto_scale - If True, use same amount of Dataplane threads for
114 | | ... |   network function as DUT, otherwise use single physical core for
115 | | ... |   every network function. Type: boolean
116 | | ... | - pinning: Set True if CPU pinning should be done on starting
117 | | ... |   containers. Type: boolean, default value: ${True}
118 | | ...
119 | | ... | *Example:*
120 | | ...
121 | | ... | \| Construct chains of containers on all DUTs \| 1 \| 1 \|
122 | | ...
123 | | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1} | ${auto_scale}=${True}
124 | | ... | ${pinning}=${True}
125 | | ...
126 | | :FOR | ${nf_chain} | IN RANGE | 1 | ${nf_chains}+1
127 | | | Construct chain of containers on all DUTs | nf_chains=${nf_chains}
128 | | | ... | nf_nodes=${nf_nodes} | nf_chain=${nf_chain}
129 | | | ... | auto_scale=${auto_scale} | pinning=${pinning}
130
131 | Acquire all '${group}' containers
132 | | [Documentation] | Acquire all container(s) in specific container group on
133 | | ... | all DUT nodes.
134 | | ...
135 | | Run Keyword | ${group}.Acquire all containers
136
137 | Create all '${group}' containers
138 | | [Documentation] | Create/deploy all container(s) in specific container group
139 | | ... | on all DUT nodes.
140 | | ...
141 | | Run Keyword | ${group}.Create all containers
142
143 | Start VPP in all '${group}' containers
144 | | [Documentation] | Start VPP on all container(s) in specific container
145 | | ... | group on all DUT nodes.
146 | | ...
147 | | Run Keyword | ${group}.Start VPP In All Containers
148
149 | Restart VPP in all '${group}' containers
150 | | [Documentation] | Restart VPP on all container(s) in specific container
151 | | ... | group on all DUT nodes.
152 | | ...
153 | | Run Keyword | ${group}.Restart VPP In All Containers
154
155 | Configure VPP in all '${group}' containers
156 | | [Documentation] | Configure VPP on all container(s) in specific container
157 | | ... | group on all DUT nodes.
158 | | ...
159 | | ${dut1_if2} = | Get Variable Value | \${dut1_if2} | ${None}
160 | | ${dut2_if2} = | Get Variable Value | \${dut2_if2} | ${None}
161 | | Run Keyword If | '${container_chain_topology}' == 'chain_ip4'
162 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
163 | | ... | tg_if1_mac=${tg_if1_mac} | tg_if2_mac=${tg_if2_mac}
164 | | ... | nodes=${nf_nodes}
165 | | ... | ELSE IF | '${container_chain_topology}' == 'pipeline_ip4'
166 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
167 | | ... | tg_if1_mac=${tg_if1_mac} | tg_if2_mac=${tg_if2_mac}
168 | | ... | nodes=${nf_nodes}
169 | | ... | ELSE IF | '${container_chain_topology}' == 'cross_horiz'
170 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
171 | | ... | dut1_if=${dut1_if2} | dut2_if=${dut2_if2}
172 | | ... | ELSE
173 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
174
175 | Stop all '${group}' containers
176 | | [Documentation] | Stop all container(s) in specific container group on all
177 | | ... | DUT nodes.
178 | | ...
179 | | Run Keyword | ${group}.Stop all containers
180
181 | Destroy all '${group}' containers
182 | | [Documentation] | Destroy all container(s) in specific container group on
183 | | ... | all DUT nodes.
184 | | ...
185 | | Run Keyword | ${group}.Destroy all containers
186
187 | Start containers for test
188 | | [Documentation]
189 | | ... | Start containers for test.
190 | | ...
191 | | ... | *Arguments:*
192 | | ... | - nf_chains: Total number of chains. Type: integer
193 | | ... | - nf_nodes: Total number of nodes per chain. Type: integer
194 | | ... | - auto_scale - If True, use same amount of Dataplane threads for
195 | | ... |   network function as DUT, otherwise use single physical core for
196 | | ... |   every network function. Type: boolean
197 | | ... | - pinning: Set True if CPU pinning should be done on starting
198 | | ... |   containers. Type: boolean, default value: ${False}
199 | | ...
200 | | ... | *Example:*
201 | | ...
202 | | ... | \| Start containers for test \| 1 \| 1 \|
203 | | ...
204 | | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1} | ${auto_scale}=${True}
205 | | ... | ${pinning}=${True}
206 | | ...
207 | | Set Test Variable | @{container_groups} | @{EMPTY}
208 | | Set Test Variable | ${container_group} | CNF
209 | | Set Test Variable | ${nf_nodes}
210 | | Import Library | resources.libraries.python.ContainerUtils.ContainerManager
211 | | ... | engine=${container_engine} | WITH NAME | ${container_group}
212 | | Construct chains of containers on all DUTs | ${nf_chains} | ${nf_nodes}
213 | | ... | auto_scale=${auto_scale} | pinning=${pinning}
214 | | Acquire all '${container_group}' containers
215 | | Create all '${container_group}' containers
216 | | Configure VPP in all '${container_group}' containers
217 | | Start VPP in all '${container_group}' containers
218 | | Append To List | ${container_groups} | ${container_group}