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