FIX: IPsec TNL test should load plugins
[csit.git] / resources / libraries / robot / vm / qemu.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 *** Settings ***
14 | Library | resources.libraries.python.IPUtil
15
16 *** Keywords ***
17 | Configure QEMU vhost and run it
18 | | [Documentation]
19 | | ... | Setup Qemu with 4 vhost-user interfaces and 4 namespaces.
20 | | ... | Each call will be different object instance.
21 | | ...
22 | | ... | *Arguments:*
23 | | ... | - dut_node - Node where to setup qemu. Type: dict
24 | | ... | - sock1 - Socket path for first Vhost-User interface. Type: string
25 | | ... | - sock2 - Socket path for second Vhost-User interface. Type: string
26 | | ... | - sock3 - Socket path for third Vhost-User interface. Type: string
27 | | ... | - sock4 - Socket path for forth Vhost-User interface. Type: string
28 | | ... | - ip1 - IP address for namespace 1. Type: string
29 | | ... | - ip2 - IP address for namespace 2. Type: string
30 | | ... | - ip3 - IP address for namespace 3. Type: string
31 | | ... | - ip4 - IP address for namespace 4. Type: string
32 | | ... | - prefix_length - IP prefix length. Type: int
33 | | ... | - qemu_name - Qemu instance name by which the object will be accessed.
34 | | ... |               Type: string
35 | | ... | - mac_ID - MAC address ID used to differentiate qemu instances and
36 | | ... | namespaces assigned to them. Type: string
37 | | ...
38 | | ... | *Example:*
39 | | ...
40 | | ... | \| Setup QEMU Vhost And Run\| {nodes['DUT1']} \| /tmp/sock1 \
41 | | ... | \| /tmp/sock2 \| /tmp/sock3 \| /tmp/sock4 \| 16.0.0.1 \| 16.0.0.2 \
42 | | ... | \| 16.0.0.3 \| 16.0.0.4 \| 24 \| qemu_instance_1 \| 06 \|
43 | | ...
44 | | [Arguments] | ${dut_node} | ${sock1} | ${sock2} | ${sock3} | ${sock4}
45 | | ... | ${ip1} | ${ip2} | ${ip3} | ${ip4} | ${prefix_length}
46 | | ... | ${qemu_name}=vm_node | ${mac_ID}=${None}
47 | | ...
48 | | Import Library | resources.libraries.python.QemuUtils \
49 | | ... | node=${dut_node} | WITH NAME | ${qemu_name}
50 | | Run keyword | ${qemu_name}.Qemu Add Vhost User If | ${sock1}
51 | | Run keyword | ${qemu_name}.Qemu Add Vhost User If | ${sock2}
52 | | Run keyword | ${qemu_name}.Qemu Add Vhost User If | ${sock3}
53 | | Run keyword | ${qemu_name}.Qemu Add Vhost User If | ${sock4}
54 | | ${vm}= | Run keyword | ${qemu_name}.Qemu Start
55 | | ${vhost1}= | Get Vhost User If Name By Sock | ${vm} | ${sock1}
56 | | ${vhost2}= | Get Vhost User If Name By Sock | ${vm} | ${sock2}
57 | | ${vhost3}= | Get Vhost User If Name By Sock | ${vm} | ${sock3}
58 | | ${vhost4}= | Get Vhost User If Name By Sock | ${vm} | ${sock4}
59 | | Set Interface State | ${vm} | ${vhost1} | up | if_type=name
60 | | Set Interface State | ${vm} | ${vhost2} | up | if_type=name
61 | | Set Interface State | ${vm} | ${vhost3} | up | if_type=name
62 | | Set Interface State | ${vm} | ${vhost4} | up | if_type=name
63 | | Setup Network Namespace
64 | | ... | ${vm} | nmspace1 | ${vhost1} | ${ip1} | ${prefix_length}
65 | | Setup Network Namespace
66 | | ... | ${vm} | nmspace2 | ${vhost2} | ${ip2} | ${prefix_length}
67 | | Setup Network Namespace
68 | | ... | ${vm} | nmspace3 | ${vhost3} | ${ip3} | ${prefix_length}
69 | | Setup Network Namespace
70 | | ... | ${vm} | nmspace4 | ${vhost4} | ${ip4} | ${prefix_length}
71 | | Set Test Variable | ${${qemu_name}} | ${vm}
72
73 | Tear down QEMU
74 | | [Documentation]
75 | | ... | Stop specific qemu instance running on DUT.
76 | | ...
77 | | ... | *Arguments:*
78 | | ... | - qemu_name - Qemu instance by name. Type: string
79 | | ...
80 | | ... | *Example:*
81 | | ...
82 | | ... | \| Tear down QEMU \| qemu_node_1 \|
83 | | ...
84 | | [Arguments] | ${qemu_name}=vm_node
85 | | ...
86 | | Run Keyword | ${qemu_name}.Qemu Kill