CSIT-1156 Create container memif tests for 2-node topology
[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/vfio:/dev/vfio
32 | | | ... | /dev/bus:/dev/bus
33 | | | ${cpu_node}= | Get interfaces numa node | ${nodes['${dut}']}
34 | | | ... | ${dut1_if1} | ${dut1_if2}
35 | | | Run Keyword | ${group}.Construct containers
36 | | | ... | name=${dut}_${group} | node=${nodes['${dut}']} | mnt=${mnt}
37 | | | ... | image=${container_image} | cpu_count=${container_cpus}
38 | | | ... | cpu_skip=${skip_cpus} | cpuset_mems=${cpu_node}
39 | | | ... | cpu_shared=${False} | env=${env} | count=${container_count}
40 | | | ... | install_dkms=${container_install_dkms}
41 | | Append To List | ${container_groups} | ${group}
42
43 | Construct ETCD containers on all DUTs
44 | | [Documentation] | Construct Docker ETCD container on all DUTs.
45 | | ...
46 | | ${group}= | Set Variable | ETCD
47 | | ${command}= | Set Variable
48 | | ... | /usr/local/bin/etcd -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379
49 | | ${image}= | Set Variable | quay.io/coreos/etcd:v3.2.5
50 | | ${publish}= | Create List | 2379:2379
51 | | Import Library | resources.libraries.python.ContainerUtils.ContainerManager
52 | | ... | engine=Docker | WITH NAME | ${group}
53 | | ${duts}= | Get Matches | ${nodes} | DUT*
54 | | :FOR | ${dut} | IN | @{duts}
55 | | | ${cpu_node}= | Get interfaces numa node | ${nodes['${dut}']}
56 | | | ... | ${dut1_if1} | ${dut1_if2}
57 | | | Run Keyword | ${group}.Construct container
58 | | | ... | name=${dut}_${group} | node=${nodes['${dut}']}
59 | | | ... | image=${container_image} | cpu_count=${1} | cpu_skip=${0}
60 | | | ... | cpuset_mems=${cpu_node} | cpu_shared=${True}
61 | | | ... | publish=${publish} | command=${command}
62 | | Append To List | ${container_groups} | ${group}
63
64 | Construct Kafka containers on all DUTs
65 | | [Documentation] | Construct Docker Kafka container on all DUTs.
66 | | ...
67 | | ${group}= | Set Variable | Kafka
68 | | ${image}= | Set Variable | spotify/kafka
69 | | ${publish}= | Create List | 2181:2181 | 9092:9092
70 | | Import Library | resources.libraries.python.ContainerUtils.ContainerManager
71 | | ... | engine=Docker | WITH NAME | ${group}
72 | | ${duts}= | Get Matches | ${nodes} | DUT*
73 | | :FOR | ${dut} | IN | @{duts}
74 | | | ${env}= | Create List | ADVERTISED_HOST=172.17.0.1 | ADVERTISED_PORT=9092
75 | | | ${cpu_node}= | Get interfaces numa node | ${nodes['${dut}']}
76 | | | ... | ${dut1_if1} | ${dut1_if2}
77 | | | Run Keyword | ${group}.Construct container
78 | | | ... | name=${dut}_${group} | node=${nodes['${dut}']} | image=${image}
79 | | | ... | cpu_count=${1} | cpu_skip=${0} | cpuset_mems=${cpu_node}
80 | | | ... | cpu_shared=${True} | publish=${publish} | 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 | | ${dut2_if2} = | Get Variable Value | \${dut2_if2} | ${EMPTY}
112 | | Run Keyword | ${group}.Configure VPP In All Containers
113 | | ... | chain_topology=${container_chain_topology}
114 | | ... | dut1_if=${dut1_if2} | dut2_if=${dut2_if2}
115
116 | Stop all '${group}' containers
117 | | [Documentation] | Stop all container(s) in specific container group on all
118 | | ... | DUT nodes.
119 | | ...
120 | | Run Keyword | ${group}.Stop all containers
121
122 | Destroy all '${group}' containers
123 | | [Documentation] | Destroy all container(s) in specific container group on
124 | | ... | all DUT nodes.
125 | | ...
126 | | Run Keyword | ${group}.Destroy all containers