CSIT-1403 Implement multichain configuration for l2bd with memif/ip4.
[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 | Collections
18 | Library | String
19 | ...
20 | Library | resources.libraries.python.CpuUtils
21 | Library | resources.libraries.python.topology.Topology
22
23 *** Keywords ***
24 | Construct container on all DUTs
25 | | [Documentation] | Construct 1 CNF of specific technology on all DUT nodes.
26 | | ...
27 | | ... | *Arguments:*
28 | | ... | - nf_chains: Total number of chains (Optional). Type: integer, default
29 | | ... | value: ${1}
30 | | ... | - nf_nodes: Total number of nodes per chain (Optional). Type: integer,
31 | | ... | default value: ${1}
32 | | ... | - nf_chain: Chain ID (Optional). Type: integer, default value: ${1}
33 | | ... | - nf_node: Node ID (Optional). Type: integer, default value: ${1}
34 | | ... | - auto_scale - If True, use same amount of Dataplane threads for
35 | | ... |   network function as DUT, otherwise use single physical core for
36 | | ... |   every network function. Type: boolean
37 | | ... | - set_nf_cpus: Set False if CPUs allocatation for network function per
38 | | ... | SUT/DUT not required. Type: boolean, default value: ${True}
39 | | ...
40 | | ... | *Example:*
41 | | ...
42 | | ... | \| Construct container on all DUTs \| 1 \| 1 \| 1 \| 1 \| ${True} \|
43 | | ...
44 | | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1} | ${nf_chain}=${1}
45 | | ... | ${nf_node}=${1} | ${auto_scale}=${True} | ${set_nf_cpus}=${True}
46 | | ...
47 | | ${duts}= | Get Matches | ${nodes} | DUT*
48 | | :FOR | ${dut} | IN | @{duts}
49 | | | ${nf_id}= | Evaluate | (${nf_chain} - ${1}) * ${nf_nodes} + ${nf_node}
50 | | | ${env}= | Create List | DEBIAN_FRONTEND=noninteractive
51 | | | ${tmp}= | Get Variable Value | ${tmp_volume} | /tmp
52 | | | ${mnt}= | Create List | ${tmp}:/mnt/host | /dev/vfio:/dev/vfio
53 | | | ${nf_cpus}= | Run Keyword If | ${set_nf_cpus}
54 | | | ... | Create network function CPU list | ${dut}
55 | | | ... | chains=${nf_chains} | nodeness=${nf_nodes} | chain_id=${nf_chain}
56 | | | ... | node_id=${nf_node} | auto_scale=${auto_scale}
57 | | | ... | ELSE | Set Variable | ${None}
58 | | | ${uuid_str}= | Run Keyword If | '${tmp}' == '/tmp'
59 | | | ... | Set Variable | ${EMPTY}
60 | | | ... | ELSE | Remove String | ${tmp} | ${dut}_VOL
61 | | | &{cont_args}= | Create Dictionary
62 | | | ... | name=${dut}_${container_group}${nf_id}${uuid_str}
63 | | | ... | node=${nodes['${dut}']} | mnt=${mnt} | env=${env}
64 | | | Run Keyword If | ${set_nf_cpus}
65 | | | ... | Set To Dictionary | ${cont_args} | cpuset_cpus=${nf_cpus}
66 | | | Run Keyword | ${container_group}.Construct container | &{cont_args}
67
68 | Construct chain of containers on all DUTs
69 | | [Documentation] | Construct 1 chain of 1..N CNFs on all DUT nodes.
70 | | ...
71 | | ... | *Arguments:*
72 | | ... | - nf_chains: Total number of chains. Type: integer
73 | | ... | - nf_nodes: Total number of nodes per chain. Type: integer
74 | | ... | - nf_chain: Chain ID. Type: integer
75 | | ... | - auto_scale - If True, use same amount of Dataplane threads for
76 | | ... |   network function as DUT, otherwise use single physical core for
77 | | ... |   every network function. Type: boolean
78 | | ... | - set_nf_cpus: Set False if CPUs allocatation for network function per
79 | | ... | SUT/DUT not required. Type: boolean, default value: ${True}
80 | | ...
81 | | ... | *Example:*
82 | | ...
83 | | ... | \| Construct chain of containers on all DUTs \| 1 \| 1 \| 1 \
84 | | ... | \| ${True} \|
85 | | ...
86 | | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1} | ${nf_chain}=${1}
87 | | ... | ${auto_scale}=${True} | ${set_nf_cpus}=${True}
88 | | ...
89 | | :FOR | ${nf_node} | IN RANGE | 1 | ${nf_nodes}+1
90 | | | Construct container on all DUTs | nf_chains=${nf_chains}
91 | | | ... | nf_nodes=${nf_nodes} | nf_chain=${nf_chain} | nf_node=${nf_node}
92 | | | ... | auto_scale=${auto_scale} | set_nf_cpus=${set_nf_cpus}
93
94 | Construct chains of containers on all DUTs
95 | | [Documentation] | Construct 1..N chains of 1..N CNFs on all DUT nodes.
96 | | ...
97 | | ... | *Arguments:*
98 | | ... | - nf_chains: Total number of chains (Optional). Type: integer, default
99 | | ... | value: ${1}
100 | | ... | - nf_nodes: Total number of nodes per chain (Optional). Type: integer,
101 | | ... | default value: ${1}
102 | | ... | - auto_scale - If True, use same amount of Dataplane threads for
103 | | ... |   network function as DUT, otherwise use single physical core for
104 | | ... |   every network function. Type: boolean
105 | | ... | - set_nf_cpus: Set False if CPUs allocatation for network function per
106 | | ... | SUT/DUT not required. Type: boolean, default value: ${True}
107 | | ...
108 | | ... | *Example:*
109 | | ...
110 | | ... | \| Construct chains of containers on all DUTs \| 1 \| 1 \|
111 | | ...
112 | | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1} | ${auto_scale}=${True}
113 | | ... | ${set_nf_cpus}=${True}
114 | | ...
115 | | :FOR | ${nf_chain} | IN RANGE | 1 | ${nf_chains}+1
116 | | | Construct chain of containers on all DUTs | nf_chains=${nf_chains}
117 | | | ... | nf_nodes=${nf_nodes} | nf_chain=${nf_chain}
118 | | | ... | auto_scale=${auto_scale} | set_nf_cpus=${set_nf_cpus}
119
120 | Acquire all '${group}' containers
121 | | [Documentation] | Acquire all container(s) in specific container group on
122 | | ... | all DUT nodes.
123 | | ...
124 | | Run Keyword | ${group}.Acquire all containers
125
126 | Create all '${group}' containers
127 | | [Documentation] | Create/deploy all container(s) in specific container group
128 | | ... | on all DUT nodes.
129 | | ...
130 | | Run Keyword | ${group}.Create all containers
131
132 | Install VPP in all '${group}' containers
133 | | [Documentation] | Install VPP on all container(s) in specific container
134 | | ... | group on all DUT nodes.
135 | | ...
136 | | Run Keyword | ${group}.Install VPP In All Containers
137
138 | Restart VPP in all '${group}' containers
139 | | [Documentation] | Restart VPP on all container(s) in specific container
140 | | ... | group on all DUT nodes.
141 | | ...
142 | | Run Keyword | ${group}.Restart VPP In All Containers
143
144 | Configure VPP in all '${group}' containers
145 | | [Documentation] | Configure VPP on all container(s) in specific container
146 | | ... | group on all DUT nodes.
147 | | ...
148 | | ${dut1_if2} = | Get Variable Value | \${dut1_if2} | ${None}
149 | | ${dut2_if2} = | Get Variable Value | \${dut2_if2} | ${None}
150 | | Run Keyword If | '${container_chain_topology}' == 'chain_ip4'
151 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
152 | | ... | tg_if1_mac=${tg_if1_mac} | tg_if2_mac=${tg_if2_mac}
153 | | ... | nodes=${nf_nodes}
154 | | ... | ELSE IF | '${container_chain_topology}' == 'cross_horiz'
155 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
156 | | ... | dut1_if=${dut1_if2} | dut2_if=${dut2_if2}
157 | | ... | ELSE
158 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
159
160 | Stop all '${group}' containers
161 | | [Documentation] | Stop all container(s) in specific container group on all
162 | | ... | DUT nodes.
163 | | ...
164 | | Run Keyword | ${group}.Stop all containers
165
166 | Destroy all '${group}' containers
167 | | [Documentation] | Destroy all container(s) in specific container group on
168 | | ... | all DUT nodes.
169 | | ...
170 | | Run Keyword | ${group}.Destroy all containers