VPP_Device - add baseline tests - part IIb)
[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 | | ... | - chains: Total number of chains (Optional). Type: integer, default
29 | | ... | value: ${1}
30 | | ... | - nodeness: Total number of nodes per chain (Optional). Type: integer,
31 | | ... | default value: ${1}
32 | | ... | - chain_id: Chain ID (Optional). Type: integer, default value: ${1}
33 | | ... | - node_id: Node ID (Optional). Type: integer, default value: ${1}
34 | | ... | - set_nf_cpus: Set False if CPUs allocatation for network function per
35 | | ... | SUT/DUT not required. Type: boolean, default value: ${True}
36 | | ...
37 | | ... | *Example:*
38 | | ...
39 | | ... | \| Construct container on all DUTs \| 1 \| 1 \| 1 \| 1 \| ${True} \|
40 | | ...
41 | | [Arguments] | ${chains}=${1} | ${nodeness}=${1} | ${chain_id}=${1}
42 | | ... | ${node_id}=${1} | ${set_nf_cpus}=${True}
43 | | ...
44 | | ${duts}= | Get Matches | ${nodes} | DUT*
45 | | :FOR | ${dut} | IN | @{duts}
46 | | | ${env}= | Create List | DEBIAN_FRONTEND=noninteractive
47 | | | ${tmp}= | Get Variable Value | ${tmp_volume} | /tmp
48 | | | ${mnt}= | Create List | ${tmp}:/mnt/host | /dev/vfio:/dev/vfio
49 | | | ${nf_cpus}= | Run Keyword If | ${set_nf_cpus}
50 | | | ... | Create network function CPU list | ${dut}
51 | | | ... | chains=${chains} | nodeness=${nodeness} | chain_id=${chain_id}
52 | | | ... | node_id=${node_id} | auto_scale=${True}
53 | | | ... | ELSE | Set Variable | ${None}
54 | | | ${uuid_str}= | Run Keyword If | '${tmp}' == '/tmp'
55 | | | ... | Set Variable | ${EMPTY}
56 | | | ... | ELSE | Remove String | ${tmp} | ${dut}_VOL
57 | | | &{cont_args}= | Create Dictionary
58 | | | ... | name=${dut}_${container_group}${chain_id}${node_id}${uuid_str}
59 | | | ... | node=${nodes['${dut}']} | mnt=${mnt} | env=${env}
60 | | | Run Keyword If | ${set_nf_cpus}
61 | | | ... | Set To Dictionary | ${cont_args} | cpuset_cpus=${nf_cpus}
62 | | | Run Keyword | ${container_group}.Construct container | &{cont_args}
63
64 | Construct chain of containers on all DUTs
65 | | [Documentation] | Construct 1 chain of 1..N CNFs on all DUT nodes.
66 | | ...
67 | | ... | *Arguments:*
68 | | ... | - chains: Total number of chains. Type: integer
69 | | ... | - nodeness: Total number of nodes per chain. Type: integer
70 | | ... | - chain_id: Chain ID. Type: integer
71 | | ... | - set_nf_cpus: Set False if CPUs allocatation for network function per
72 | | ... | SUT/DUT not required. Type: boolean, default value: ${True}
73 | | ...
74 | | ... | *Example:*
75 | | ...
76 | | ... | \| Construct chain of containers on all DUTs \| 1 \| 1 \| 1 \
77 | | ... | \| ${True} \|
78 | | ...
79 | | [Arguments] | ${chains} | ${nodeness} | ${chain_id} | ${set_nf_cpus}=${True}
80 | | ...
81 | | :FOR | ${node_id} | IN RANGE | 1 | ${nodeness}+1
82 | | | Construct container on all DUTs | chains=${chains} | nodeness=${nodeness}
83 | | | ... | chain_id=${chain_id} | node_id=${node_id}
84 | | | ... | set_nf_cpus=${set_nf_cpus}
85
86 | Construct chains of containers on all DUTs
87 | | [Documentation] | Construct 1..N chains of 1..N CNFs on all DUT nodes.
88 | | ...
89 | | ... | *Arguments:*
90 | | ... | - chains: Total number of chains (Optional). Type: integer, default
91 | | ... | value: ${1}
92 | | ... | - nodeness: Total number of nodes per chain (Optional). Type: integer,
93 | | ... | default value: ${1}
94 | | ... | - set_nf_cpus: Set False if CPUs allocatation for network function per
95 | | ... | SUT/DUT not required. Type: boolean, default value: ${True}
96 | | ...
97 | | ... | *Example:*
98 | | ...
99 | | ... | \| Construct chains of containers on all DUTs \| 1 \| 1 \|
100 | | ...
101 | | [Arguments] | ${chains}=${1} | ${nodeness}=${1} | ${set_nf_cpus}=${True}
102 | | ...
103 | | :FOR | ${chain_id} | IN RANGE | 1 | ${chains}+1
104 | | | Construct chain of containers on all DUTs | chains=${chains}
105 | | | ... | nodeness=${nodeness} | chain_id=${chain_id}
106 | | | ... | set_nf_cpus=${set_nf_cpus}
107
108 | Acquire all '${group}' containers
109 | | [Documentation] | Acquire all container(s) in specific container group on
110 | | ... | all DUT nodes.
111 | | ...
112 | | Run Keyword | ${group}.Acquire all containers
113
114 | Create all '${group}' containers
115 | | [Documentation] | Create/deploy all container(s) in specific container group
116 | | ... | on all DUT nodes.
117 | | ...
118 | | Run Keyword | ${group}.Create all containers
119
120 | Install VPP in all '${group}' containers
121 | | [Documentation] | Install VPP on all container(s) in specific container
122 | | ... | group on all DUT nodes.
123 | | ...
124 | | Run Keyword | ${group}.Install VPP In All Containers
125
126 | Restart VPP in all '${group}' containers
127 | | [Documentation] | Restart VPP on all container(s) in specific container
128 | | ... | group on all DUT nodes.
129 | | ...
130 | | Run Keyword | ${group}.Restart VPP In All Containers
131
132 | Configure VPP in all '${group}' containers
133 | | [Documentation] | Configure VPP on all container(s) in specific container
134 | | ... | group on all DUT nodes.
135 | | ...
136 | | ${dut1_if2} = | Get Variable Value | \${dut1_if2} | ${None}
137 | | ${dut2_if2} = | Get Variable Value | \${dut2_if2} | ${None}
138 | | Run Keyword If | '${container_chain_topology}' == 'cross_horiz'
139 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
140 | | ... | dut1_if=${dut1_if2} | dut2_if=${dut2_if2}
141 | | ... | ELSE
142 | | ... | ${group}.Configure VPP In All Containers | ${container_chain_topology}
143
144 | Stop all '${group}' containers
145 | | [Documentation] | Stop all container(s) in specific container group on all
146 | | ... | DUT nodes.
147 | | ...
148 | | Run Keyword | ${group}.Stop all containers
149
150 | Destroy all '${group}' containers
151 | | [Documentation] | Destroy all container(s) in specific container group on
152 | | ... | all DUT nodes.
153 | | ...
154 | | Run Keyword | ${group}.Destroy all containers