e4748dbf605026482c7c43448edc14c3497754d4
[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 container on all DUTs
21 | | [Documentation] | Construct 1 CNF of specific technology on all DUT nodes.
22 | | ...
23 | | ... | *Arguments:*
24 | | ... | - chains: Total number of chains. Type: integer
25 | | ... | - nodeness: Total number of nodes per chain. Type: integer
26 | | ... | - chain_id: Chain ID. Type: integer
27 | | ... | - node_id: Node ID. Type: integer
28 | | ...
29 | | ... | *Example:*
30 | | ...
31 | | ... | \| Construct container on all DUTs \| 1 \| 1 \| 1 \| 1 \|
32 | | ...
33 | | [Arguments] | ${chains}=${1} | ${nodeness}=${1} | ${chain_id}=${1}
34 | | ... | ${node_id}=${1}
35 | | ...
36 | | ${group}= | Set Variable | CNF
37 | | Import Library | resources.libraries.python.ContainerUtils.ContainerManager
38 | | ... | engine=${container_engine} | WITH NAME | ${group}
39 | | ${duts}= | Get Matches | ${nodes} | DUT*
40 | | :FOR | ${dut} | IN | @{duts}
41 | | | ${env}= | Create List | DEBIAN_FRONTEND=noninteractive
42 | | | ${mnt}= | Create List | /tmp:/mnt/host | /dev/vfio:/dev/vfio
43 | | | ${nf_cpus}= | Create network function CPU list | ${dut}
44 | | | ... | chains=${chains} | nodeness=${nodeness} | chain_id=${chain_id}
45 | | | ... | node_id=${node_id} | auto_scale=${True}
46 | | | Run Keyword | ${group}.Construct container
47 | | | ... | name=${dut}_${group}${chain_id}${node_id} | node=${nodes['${dut}']}
48 | | | ... | mnt=${mnt} | env=${env} | cpuset_cpus=${nf_cpus}
49 | | Append To List | ${container_groups} | ${group}
50
51 | Construct chain of containers on all DUTs
52 | | [Documentation] | Construct 1 chain of 1..N CNFs on all DUT nodes.
53 | | ...
54 | | ... | *Arguments:*
55 | | ... | - chains: Total number of chains. Type: integer
56 | | ... | - nodeness: Total number of nodes per chain. Type: integer
57 | | ... | - chain_id: Chain ID. Type: integer
58 | | ...
59 | | ... | *Example:*
60 | | ...
61 | | ... | \| Construct chain of containers on all DUTs \| 1 \| 1 \| 1 \|
62 | | ...
63 | | [Arguments] | ${chains} | ${nodeness} | ${chain_id}
64 | | ...
65 | | :FOR | ${node_id} | IN RANGE | 1 | ${nodeness}+1
66 | | | Construct container on all DUTs | chains=${chains} | nodeness=${nodeness}
67 | | | ... | chain_id=${chain_id} | node_id=${node_id}
68
69 | Construct chains of containers on all DUTs
70 | | [Documentation] | Construct 1..N chains of 1..N CNFs on all DUT nodes.
71 | | ...
72 | | ... | *Arguments:*
73 | | ... | - chains: Total number of chains. Type: integer
74 | | ... | - nodeness: Total number of nodes per chain. Type: integer
75 | | ...
76 | | ... | *Example:*
77 | | ...
78 | | ... | \| Construct chains of containers on all DUTs \| 1 \| 1 \|
79 | | ...
80 | | [Arguments] | ${chains}=${1} | ${nodeness}=${1}
81 | | ...
82 | | :FOR | ${chain_id} | IN RANGE | 1 | ${chains}+1
83 | | | Construct chain of containers on all DUTs | chains=${chains}
84 | | | ... | nodeness=${nodeness} | chain_id=${chain_id}
85
86 | Acquire all '${group}' containers
87 | | [Documentation] | Acquire all container(s) in specific container group on
88 | | ... | all DUT nodes.
89 | | ...
90 | | Run Keyword | ${group}.Acquire all containers
91
92 | Create all '${group}' containers
93 | | [Documentation] | Create/deploy all container(s) in specific container group
94 | | ... | on all DUT nodes.
95 | | ...
96 | | Run Keyword | ${group}.Create all containers
97
98 | Install VPP in all '${group}' containers
99 | | [Documentation] | Install VPP on all container(s) in specific container
100 | | ... | group on all DUT nodes.
101 | | ...
102 | | Run Keyword | ${group}.Install VPP In All Containers
103
104 | Restart VPP in all '${group}' containers
105 | | [Documentation] | Restart VPP on all container(s) in specific container
106 | | ... | group on all DUT nodes.
107 | | ...
108 | | Run Keyword | ${group}.Restart VPP In All Containers
109
110 | Configure VPP in all '${group}' containers
111 | | [Documentation] | Configure VPP on all container(s) in specific container
112 | | ... | group on all DUT nodes.
113 | | ...
114 | | ${dut2_if2} = | Get Variable Value | \${dut2_if2} | ${EMPTY}
115 | | Run Keyword | ${group}.Configure VPP In All Containers
116 | | ... | chain_topology=${container_chain_topology}
117 | | ... | dut1_if=${dut1_if2} | dut2_if=${dut2_if2}
118
119 | Stop all '${group}' containers
120 | | [Documentation] | Stop all container(s) in specific container group on all
121 | | ... | DUT nodes.
122 | | ...
123 | | Run Keyword | ${group}.Stop all containers
124
125 | Destroy all '${group}' containers
126 | | [Documentation] | Destroy all container(s) in specific container group on
127 | | ... | all DUT nodes.
128 | | ...
129 | | Run Keyword | ${group}.Destroy all containers