CSIT-1416 Remove installation of vpp from containers
[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 | | ${duts}= | Get Matches | ${nodes} | DUT*
45 | | :FOR | ${dut} | IN | @{duts}
46 | | | ${nf_id}= | Evaluate | (${nf_chain} - ${1}) * ${nf_nodes} + ${nf_node}
47 | | | ${env}= | Create List | DEBIAN_FRONTEND=noninteractive
48 | | | ${uuid}= | Get Variable Value | ${dcr_uuid} | ${Empty}
49 | | | ${root}= | Get Variable Value | ${dcr_root} | ${Empty}
50 | | | ${mnt}= | Create List
51 | | | ... | ${root}/tmp/:/mnt/host/
52 | | | ... | ${root}/dev/vfio/:/dev/vfio/
53 | | | ... | ${root}/usr/bin/vpp:/usr/bin/vpp
54 | | | ... | ${root}/usr/bin/vppctl:/usr/bin/vppctl
55 | | | ... | ${root}/usr/lib/x86_64-linux-gnu/:/usr/lib/x86_64-linux-gnu/
56 | | | ... | ${root}/usr/share/vpp/:/usr/share/vpp/
57 | | | ${nf_cpus}= | Set Variable | ${None}
58 | | | ${nf_cpus}= | Run Keyword Unless | ${nested}
59 | | | ... | Create network function CPU list | ${dut}
60 | | | ... | chains=${nf_chains} | nodeness=${nf_nodes} | chain_id=${nf_chain}
61 | | | ... | node_id=${nf_node} | auto_scale=${auto_scale}
62 | | | &{cont_args}= | Create Dictionary
63 | | | ... | name=${dut}_${container_group}${nf_id}${uuid}
64 | | | ... | node=${nodes['${dut}']} | mnt=${mnt} | env=${env}
65 | | | Run Keyword Unless | ${nested}
66 | | | ... | Set To Dictionary | ${cont_args} | cpuset_cpus=${nf_cpus}
67 | | | Run Keyword | ${container_group}.Construct container | &{cont_args}
68
69 | Construct chain of containers on all DUTs
70 | | [Documentation] | Construct 1 chain of 1..N CNFs on all DUT nodes.
71 | | ...
72 | | ... | *Arguments:*
73 | | ... | - nf_chains: Total number of chains. Type: integer
74 | | ... | - nf_nodes: Total number of nodes per chain. Type: integer
75 | | ... | - nf_chain: Chain ID. Type: integer
76 | | ... | - auto_scale - If True, use same amount of Dataplane threads for
77 | | ... |   network function as DUT, otherwise use single physical core for
78 | | ... |   every network function. Type: boolean
79 | | ... | - nested: Set True if starting nested containers.
80 | | ... | Type: boolean, default value: ${False}
81 | | ...
82 | | ... | *Example:*
83 | | ...
84 | | ... | \| Construct chain of containers on all DUTs \| 1 \| 1 \| 1 \
85 | | ... | \| ${True} \|
86 | | ...
87 | | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1} | ${nf_chain}=${1}
88 | | ... | ${auto_scale}=${True} | ${nested}=${False}
89 | | ...
90 | | :FOR | ${nf_node} | IN RANGE | 1 | ${nf_nodes}+1
91 | | | Construct container on all DUTs | nf_chains=${nf_chains}
92 | | | ... | nf_nodes=${nf_nodes} | nf_chain=${nf_chain} | nf_node=${nf_node}
93 | | | ... | auto_scale=${auto_scale} | nested=${nested}
94
95 | Construct chains of containers on all DUTs
96 | | [Documentation] | Construct 1..N chains of 1..N CNFs on all DUT nodes.
97 | | ...
98 | | ... | *Arguments:*
99 | | ... | - nf_chains: Total number of chains (Optional). Type: integer, default
100 | | ... | value: ${1}
101 | | ... | - nf_nodes: Total number of nodes per chain (Optional). Type: integer,
102 | | ... | default value: ${1}
103 | | ... | - auto_scale - If True, use same amount of Dataplane threads for
104 | | ... |   network function as DUT, otherwise use single physical core for
105 | | ... |   every network function. Type: boolean
106 | | ... | - nested: Set True if starting nested containers.
107 | | ... | Type: boolean, default value: ${False}
108 | | ...
109 | | ... | *Example:*
110 | | ...
111 | | ... | \| Construct chains of containers on all DUTs \| 1 \| 1 \|
112 | | ...
113 | | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1} | ${auto_scale}=${True}
114 | | ... | ${nested}=${False}
115 | | ...
116 | | :FOR | ${nf_chain} | IN RANGE | 1 | ${nf_chains}+1
117 | | | Construct chain of containers on all DUTs | nf_chains=${nf_chains}
118 | | | ... | nf_nodes=${nf_nodes} | nf_chain=${nf_chain}
119 | | | ... | auto_scale=${auto_scale} | nested=${nested}
120
121 | Acquire all '${group}' containers
122 | | [Documentation] | Acquire all container(s) in specific container group on
123 | | ... | all DUT nodes.
124 | | ...
125 | | Run Keyword | ${group}.Acquire all containers
126
127 | Create all '${group}' containers
128 | | [Documentation] | Create/deploy all container(s) in specific container group
129 | | ... | on all DUT nodes.
130 | | ...
131 | | Run Keyword | ${group}.Create all containers
132
133 | Start VPP in all '${group}' containers
134 | | [Documentation] | Start VPP on all container(s) in specific container
135 | | ... | group on all DUT nodes.
136 | | ...
137 | | Run Keyword | ${group}.Start VPP In All Containers
138
139 | Restart VPP in all '${group}' containers
140 | | [Documentation] | Restart VPP on all container(s) in specific container
141 | | ... | group on all DUT nodes.
142 | | ...
143 | | Run Keyword | ${group}.Restart VPP In All Containers
144
145 | Configure VPP in all '${group}' containers
146 | | [Documentation] | Configure VPP on all container(s) in specific container
147 | | ... | group on all DUT nodes.
148 | | ...
149 | | ${dut1_if2} = | Get Variable Value | \${dut1_if2} | ${None}
150 | | ${dut2_if2} = | Get Variable Value | \${dut2_if2} | ${None}
151 | | Run Keyword If | '${container_chain_topology}' == 'chain_ip4'
152 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
153 | | ... | tg_if1_mac=${tg_if1_mac} | tg_if2_mac=${tg_if2_mac}
154 | | ... | nodes=${nf_nodes}
155 | | ... | ELSE IF | '${container_chain_topology}' == 'pipeline_ip4'
156 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
157 | | ... | tg_if1_mac=${tg_if1_mac} | tg_if2_mac=${tg_if2_mac}
158 | | ... | nodes=${nf_nodes}
159 | | ... | ELSE IF | '${container_chain_topology}' == 'cross_horiz'
160 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
161 | | ... | dut1_if=${dut1_if2} | dut2_if=${dut2_if2}
162 | | ... | ELSE
163 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
164
165 | Stop all '${group}' containers
166 | | [Documentation] | Stop all container(s) in specific container group on all
167 | | ... | DUT nodes.
168 | | ...
169 | | Run Keyword | ${group}.Stop all containers
170
171 | Destroy all '${group}' containers
172 | | [Documentation] | Destroy all container(s) in specific container group on
173 | | ... | all DUT nodes.
174 | | ...
175 | | Run Keyword | ${group}.Destroy all containers