201cadcb739e92cc4465aab684ca6afc38ee6df4
[csit.git] / resources / libraries / robot / shared / container.robot
1 # Copyright (c) 2017 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 | Library | resources.libraries.python.CpuUtils
17 | Library | resources.libraries.python.topology.Topology
18
19 *** Keywords ***
20 | Construct VNF containers on all DUTs
21 | | [Documentation] | Construct 1..N VNF container(s) of specific technology on
22 | | ... |  all DUT nodes.
23 | | ...
24 | | ${group}= | Set Variable | VNF
25 | | ${skip_cpus}= | Evaluate | ${vpp_cpus}+${system_cpus}
26 | | Import Library | resources.libraries.python.ContainerUtils.ContainerManager
27 | | ... | engine=${container_engine} | WITH NAME | ${group}
28 | | ${duts}= | Get Matches | ${nodes} | DUT*
29 | | :FOR | ${dut} | IN | @{duts}
30 | | | ${env}= | Create List | DEBIAN_FRONTEND=noninteractive
31 | | | ${mnt}= | Create List | /tmp:/mnt/host | /dev:/dev
32 | | | ${cpu_node}= | Get interfaces numa node | ${nodes['${dut}']}
33 | | | ... | ${dut1_if1} | ${dut1_if2}
34 | | | Run Keyword | ${group}.Construct containers
35 | | | ... | name=${dut}_${group} | node=${nodes['${dut}']} | mnt=${mnt}
36 | | | ... | image=${container_image} | cpu_count=${container_cpus}
37 | | | ... | cpu_skip=${skip_cpus} | smt_used=${False} | cpuset_mems=${cpu_node}
38 | | | ... | cpu_shared=${False} | env=${env} | count=${container_count}
39 | | | ... | install_dkms=${container_install_dkms}
40 | | Append To List | ${container_groups} | ${group}
41
42 | Construct ETCD containers on all DUTs
43 | | [Documentation] | Construct Docker ETCD container on all DUTs.
44 | | ...
45 | | ${group}= | Set Variable | ETCD
46 | | ${command}= | Set Variable
47 | | ... | /usr/local/bin/etcd -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379
48 | | ${image}= | Set Variable | quay.io/coreos/etcd:v3.2.5
49 | | ${publish}= | Create List | 2379:2379
50 | | Import Library | resources.libraries.python.ContainerUtils.ContainerManager
51 | | ... | engine=Docker | WITH NAME | ${group}
52 | | ${duts}= | Get Matches | ${nodes} | DUT*
53 | | :FOR | ${dut} | IN | @{duts}
54 | | | ${cpu_node}= | Get interfaces numa node | ${nodes['${dut}']}
55 | | | ... | ${dut1_if1} | ${dut1_if2}
56 | | | Run Keyword | ${group}.Construct container
57 | | | ... | name=${dut}_${group} | node=${nodes['${dut}']}
58 | | | ... | image=${container_image} | cpu_count=${1} | cpu_skip=${0}
59 | | | ... | smt_used=${False} | cpuset_mems=${cpu_node} | cpu_shared=${True}
60 | | | ... | publish=${publish} | command=${command}
61 | | Append To List | ${container_groups} | ${group}
62
63 | Construct Kafka containers on all DUTs
64 | | [Documentation] | Construct Docker Kafka container on all DUTs.
65 | | ...
66 | | ${group}= | Set Variable | Kafka
67 | | ${image}= | Set Variable | spotify/kafka
68 | | ${publish}= | Create List | 2181:2181 | 9092:9092
69 | | Import Library | resources.libraries.python.ContainerUtils.ContainerManager
70 | | ... | engine=Docker | WITH NAME | ${group}
71 | | ${duts}= | Get Matches | ${nodes} | DUT*
72 | | :FOR | ${dut} | IN | @{duts}
73 | | | ${env}= | Create List | ADVERTISED_HOST=172.17.0.1 | ADVERTISED_PORT=9092
74 | | | ${cpu_node}= | Get interfaces numa node | ${nodes['${dut}']}
75 | | | ... | ${dut1_if1} | ${dut1_if2}
76 | | | Run Keyword | ${group}.Construct container
77 | | | ... | name=${dut}_${group} | node=${nodes['${dut}']} | image=${image}
78 | | | ... | cpu_count=${1} | cpu_skip=${0} | cpuset_mems=${cpu_node}
79 | | | ... | smt_used=${False} | cpu_shared=${True} | publish=${publish}
80 | | | ... | env=${env}
81 | | Append To List | ${container_groups} | ${group}
82
83 | Acquire all '${group}' containers
84 | | [Documentation] | Acquire all container(s) in specific container group on
85 | | ... | all DUT nodes.
86 | | ...
87 | | Run Keyword | ${group}.Acquire all containers
88
89 | Create all '${group}' containers
90 | | [Documentation] | Create/deploy all container(s) in specific container group
91 | | ... | on all DUT nodes.
92 | | ...
93 | | Run Keyword | ${group}.Create all containers
94
95 | Install VPP in all '${group}' containers
96 | | [Documentation] | Install VPP on all container(s) in specific container
97 | | ... | group on all DUT nodes.
98 | | ...
99 | | Run Keyword | ${group}.Install VPP In All Containers
100
101 | Restart VPP in all '${group}' containers
102 | | [Documentation] | Restart VPP on all container(s) in specific container
103 | | ... | group on all DUT nodes.
104 | | ...
105 | | Run Keyword | ${group}.Restart VPP In All Containers
106
107 | Configure VPP in all '${group}' containers
108 | | [Documentation] | Configure VPP on all container(s) in specific container
109 | | ... | group on all DUT nodes.
110 | | ...
111 | | Run Keyword | ${group}.Configure VPP In All Containers
112 | | ... | chain_topology=${container_chain_topology}
113 | | ... | dut1_if=${dut1_if2} | dut2_if=${dut2_if1}
114
115 | Stop all '${group}' containers
116 | | [Documentation] | Stop all container(s) in specific container group on all
117 | | ... | DUT nodes.
118 | | ...
119 | | Run Keyword | ${group}.Stop all containers
120
121 | Destroy all '${group}' containers
122 | | [Documentation] | Destroy all container(s) in specific container group on
123 | | ... | all DUT nodes.
124 | | ...
125 | | Run Keyword | ${group}.Destroy all containers