Add suite setup keywords
[integration/test.git] / csit / suites / openstack / connectivity / l3.robot
1 *** Settings ***
2 Documentation     Test suite to check connectivity in L3 using routers.
3 Suite Setup       Suite Setup
4 Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
5 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
6 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
7 Library           SSHLibrary
8 Library           OperatingSystem
9 Library           RequestsLibrary
10 Resource          ../../../libraries/DevstackUtils.robot
11 Resource          ../../../libraries/DataModels.robot
12 Resource          ../../../libraries/OpenStackOperations.robot
13 Resource          ../../../libraries/SetupUtils.robot
14 Resource          ../../../libraries/Utils.robot
15 Resource          ../../../variables/netvirt/Variables.robot
16
17 *** Variables ***
18 ${SECURITY_GROUP}    l3_sg
19 @{NETWORKS}       l3_net_1    l3_net_2    l3_net_3    l3_net_4    l3_net_5
20 @{SUBNETS_1}      l3_sub_1    l3_sub_2    l3_sub_3
21 @{SUBNETS_2}      l3_sub_4    l3_sub_5
22 @{ROUTER}         l3_router1    l3_router2
23 @{NET_1_VMS}      l3_net_1_vm_1    l3_net_1_vm_2    l3_net_1_vm_3
24 @{NET_2_VMS}      l3_net_2_vm_1    l3_net_2_vm_2    l3_net_2_vm_3
25 @{NET_3_VMS}      l3_net_3_vm_1    l3_net_3_vm_2    l3_net_3_vm_3
26 @{NET_4_VMS}      l3_net_4_vm_1
27 @{NET_5_VMS}      l3_net_5_vm_1
28 @{SUBNET_CIDRS}    31.0.0.0/24    32.0.0.0/24    33.0.0.0/24    34.0.0.0/24    35.0.0.0/24
29 @{NET_VLAN_ID}    1131    1132    1133
30
31 *** Test Cases ***
32 Ping Vm Instance1 In net_2 From net_1 (vxlan to vlan)
33     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
34     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[0]    @{NET_2_L3_VM_IPS}[0]
35
36 Ping Vm Instance2 In net_2 From net_1 (vxlan to vlan)
37     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
38     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[0]    @{NET_2_L3_VM_IPS}[1]
39
40 Ping Vm Instance3 In net_2 From net_1 (vxlan to vlan)
41     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
42     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[0]    @{NET_2_L3_VM_IPS}[2]
43
44 Ping Vm Instance1 In net_1 From net_2 (vlan to vxlan)
45     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
46     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[1]    @{NET_1_L3_VM_IPS}[0]
47
48 Ping Vm Instance2 In net_1 From net_2 (vlan to vxlan)
49     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
50     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[1]    @{NET_1_L3_VM_IPS}[1]
51
52 Ping Vm Instance3 In net_1 From net_2 (vlan to vxlan)
53     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
54     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[1]    @{NET_1_L3_VM_IPS}[2]
55
56 Ping Vm Instance1 In net_3 From net_2 (vxlan to vxlan)
57     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
58     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[1]    @{NET_3_L3_VM_IPS}[0]
59
60 Ping Vm Instance2 In net_3 From net_2 (vxlan to vxlan)
61     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
62     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[1]    @{NET_3_L3_VM_IPS}[1]
63
64 Ping Vm Instance3 In net_3 From net_2 (vxlan to vxlan)
65     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
66     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[1]    @{NET_3_L3_VM_IPS}[2]
67
68 Connectivity Tests From Vm Instance1 In net_1
69     [Documentation]    Login to the VM instance and test operations
70     ${dst_list} =    BuiltIn.Create List    @{NET_1_L3_VM_IPS}    @{NET_2_L3_VM_IPS}
71     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET_1_L3_VM_IPS}[0]    ${dst_list}
72
73 Connectivity Tests From Vm Instance2 In net_1
74     [Documentation]    Login to the vm instance and test operations
75     ${dst_list} =    BuiltIn.Create List    @{NET_1_L3_VM_IPS}    @{NET_2_L3_VM_IPS}
76     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET_1_L3_VM_IPS}[1]    ${dst_list}
77
78 Connectivity Tests From Vm Instance3 In net_1
79     [Documentation]    Login to the vm instance and test operations
80     ${dst_list} =    BuiltIn.Create List    @{NET_1_L3_VM_IPS}    @{NET_2_L3_VM_IPS}
81     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET_1_L3_VM_IPS}[2]    ${dst_list}
82
83 Connectivity Tests From Vm Instance1 In net_2
84     [Documentation]    Login to the vm instance and test operations
85     ${dst_list} =    BuiltIn.Create List    @{NET_1_L3_VM_IPS}    @{NET_2_L3_VM_IPS}
86     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET_2_L3_VM_IPS}[0]    ${dst_list}
87
88 Connectivity Tests From Vm Instance2 In net_2
89     [Documentation]    Logging to the vm instance using generated key pair.
90     ${dst_list} =    BuiltIn.Create List    @{NET_1_L3_VM_IPS}    @{NET_2_L3_VM_IPS}
91     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET_2_L3_VM_IPS}[1]    ${dst_list}
92
93 Connectivity Tests From Vm Instance3 In net_2
94     [Documentation]    Logging to the vm instance using generated key pair.
95     ${dst_list} =    BuiltIn.Create List    @{NET_1_L3_VM_IPS}    @{NET_2_L3_VM_IPS}
96     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET_2_L3_VM_IPS}[2]    ${dst_list}
97
98 Delete Vm Instances In net_1
99     [Documentation]    Delete Vm instances using instance names in net_1.
100     : FOR    ${vm}    IN    @{NET_1_VMS}
101     \    OpenStackOperations.Delete Vm Instance    ${vm}
102
103 Delete Vm Instances In net_2
104     [Documentation]    Delete Vm instances using instance names in net_2.
105     : FOR    ${vm}    IN    @{NET_2_VMS}
106     \    OpenStackOperations.Delete Vm Instance    ${vm}
107
108 Delete Vm Instances In net_3
109     [Documentation]    Delete Vm instances using instance names in net_3.
110     : FOR    ${vm}    IN    @{NET_3_VMS}
111     \    OpenStackOperations.Delete Vm Instance    ${vm}
112
113 Create Vm Instances For net_4
114     [Documentation]    Create VM instances using flavor and image names for a network.
115     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[3]    @{NET_4_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
116
117 Create Vm Instances For net_5
118     [Documentation]    Create VM instances using flavor and image names for a network.
119     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[4]    @{NET_5_VMS}[0]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
120
121 Create Router2
122     [Documentation]    Create Router
123     OpenStackOperations.Create Router    @{ROUTER}[1]
124
125 Add net_4 Interfaces To Router2
126     [Documentation]    Add Interfaces
127     OpenStackOperations.Add Router Interface    @{ROUTER}[1]    @{SUBNETS_2}[0]
128
129 Check Vm Instances on net_4 and net_5 Have Ip Address
130     @{NET_4_L3_VM_IPS}    ${NET_4_L3_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_4_VMS}
131     @{NET_5_L3_VM_IPS}    ${NET_5_L3_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_5_VMS}
132     BuiltIn.Set Suite Variable    @{NET_4_L3_VM_IPS}
133     BuiltIn.Set Suite Variable    @{NET_5_L3_VM_IPS}
134     BuiltIn.Should Not Contain    ${NET_4_L3_VM_IPS}    None
135     BuiltIn.Should Not Contain    ${NET_5_L3_VM_IPS}    None
136     BuiltIn.Should Not Contain    ${NET_4_L3_DHCP_IP}    None
137     BuiltIn.Should Not Contain    ${NET_5_L3_DHCP_IP}    None
138     [Teardown]    BuiltIn.Run Keywords    OpenStackOperations.Show Debugs    @{NET_4_VMS}    @{NET_5_VMS}
139     ...    AND    OpenStackOperations.Get Test Teardown Debugs
140
141 Add net_5 Interfaces To Router2
142     [Documentation]    Add Interfaces
143     OpenStackOperations.Add Router Interface    @{ROUTER}[1]    @{SUBNETS_2}[1]
144
145 Ping Vm Instance5 In net_5 From net_4 (vlan to vlan)
146     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
147     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[3]    @{NET_5_L3_VM_IPS}[0]
148
149 Ping Vm Instance5 In net_4 From net_5 (vlan to vlan)
150     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
151     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[4]    @{NET_4_L3_VM_IPS}[0]
152
153 Connectivity Tests From Vm Instance4 In net_5
154     [Documentation]    Check reachability of vm instance on a different network with one vlan vm in source and destination.
155     ${dst_list} =    BuiltIn.Create List    @{NET_4_L3_VM_IPS}
156     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[4]    @{NET_5_L3_VM_IPS}[0]    ${dst_list}
157
158 *** Keywords ***
159 Suite Setup
160     OpenStackOperations.OpenStack Suite Setup
161     OpenStackOperations.Create Network    @{NETWORKS}[0]    --provider-network-type vlan --provider-physical-network ${PUBLIC_PHYSICAL_NETWORK} --provider-segment @{NET_VLAN_ID}[0]
162     OpenStackOperations.Create SubNet    @{NETWORKS}[0]    @{SUBNETS_1}[0]    @{SUBNET_CIDRS}[0]
163     OpenStackOperations.Create Network    @{NETWORKS}[1]
164     OpenStackOperations.Create SubNet    @{NETWORKS}[1]    @{SUBNETS_1}[1]    @{SUBNET_CIDRS}[1]
165     OpenStackOperations.Create Network    @{NETWORKS}[2]
166     OpenStackOperations.Create SubNet    @{NETWORKS}[2]    @{SUBNETS_1}[2]    @{SUBNET_CIDRS}[2]
167     OpenStackOperations.Create Network    @{NETWORKS}[3]    --provider-network-type vlan --provider-physical-network ${PUBLIC_PHYSICAL_NETWORK} --provider-segment @{NET_VLAN_ID}[1]
168     OpenStackOperations.Create SubNet    @{NETWORKS}[3]    @{SUBNETS_2}[0]    @{SUBNET_CIDRS}[3]
169     OpenStackOperations.Create Network    @{NETWORKS}[4]    --provider-network-type vlan --provider-physical-network ${PUBLIC_PHYSICAL_NETWORK} --provider-segment @{NET_VLAN_ID}[2]
170     OpenStackOperations.Create SubNet    @{NETWORKS}[4]    @{SUBNETS_2}[1]    @{SUBNET_CIDRS}[4]
171     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
172     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[0]    @{NET_1_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
173     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[0]    @{NET_1_VMS}[1]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
174     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[0]    @{NET_1_VMS}[2]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
175     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[1]    @{NET_2_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
176     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[1]    @{NET_2_VMS}[1]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
177     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[1]    @{NET_2_VMS}[2]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
178     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[2]    @{NET_3_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
179     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[2]    @{NET_3_VMS}[1]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
180     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[2]    @{NET_3_VMS}[2]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
181     @{NET_1_L3_VM_IPS}    ${NET_1_L3_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
182     @{NET_2_L3_VM_IPS}    ${NET_2_L3_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
183     @{NET_3_L3_VM_IPS}    ${NET_3_L3_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_3_VMS}
184     BuiltIn.Set Suite Variable    @{NET_1_L3_VM_IPS}
185     BuiltIn.Set Suite Variable    @{NET_2_L3_VM_IPS}
186     BuiltIn.Set Suite Variable    @{NET_3_L3_VM_IPS}
187     BuiltIn.Should Not Contain    ${NET_1_L3_VM_IPS}    None
188     BuiltIn.Should Not Contain    ${NET_2_L3_VM_IPS}    None
189     BuiltIn.Should Not Contain    ${NET_3_L3_VM_IPS}    None
190     BuiltIn.Should Not Contain    ${NET_1_L3_DHCP_IP}    None
191     BuiltIn.Should Not Contain    ${NET_2_L3_DHCP_IP}    None
192     BuiltIn.Should Not Contain    ${NET_3_L3_DHCP_IP}    None
193     OpenStackOperations.Create Router    @{ROUTER}[0]
194     : FOR    ${interface}    IN    @{SUBNETS_1}
195     \    OpenStackOperations.Add Router Interface    @{ROUTER}[0]    ${interface}
196     OpenStackOperations.Show Debugs    @{NET_1_VMS}    @{NET_2_VMS}    @{NET_3_VMS}
197     OpenStackOperations.Get Suite Debugs