39b8cfa5e9d3da57158c64323e411d647a7faf06
[integration/test.git] / csit / suites / openstack / connectivity / 02_l3_tests.robot
1 *** Settings ***
2 Documentation     Test suite to check connectivity in L3 using routers.
3 Suite Setup       BuiltIn.Run Keywords    SetupUtils.Setup_Utils_For_Setup_And_Teardown
4 ...               AND    DevstackUtils.Devstack Suite Setup
5 Suite Teardown    Close All Connections
6 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
7 Test Teardown     Get Test Teardown Debugs
8 Library           SSHLibrary
9 Library           OperatingSystem
10 Library           RequestsLibrary
11 Resource          ../../../libraries/DevstackUtils.robot
12 Resource          ../../../libraries/DataModels.robot
13 Resource          ../../../libraries/OpenStackOperations.robot
14 Resource          ../../../libraries/SetupUtils.robot
15 Resource          ../../../libraries/Utils.robot
16 Resource          ../../../variables/netvirt/Variables.robot
17
18 *** Variables ***
19 ${SECURITY_GROUP}    sg-connectivity
20 @{NETWORKS_NAME}    network_1    network_2    network_3
21 @{SUBNETS_NAME}    subnet_1    subnet_2    subnet_3
22 @{NET_1_VM_INSTANCES}    l3_instance_net_1_1    l3_instance_net_1_2    l3_instance_net_1_3
23 @{NET_2_VM_INSTANCES}    l3_instance_net_2_1    l3_instance_net_2_2    l3_instance_net_2_3
24 @{NET_3_VM_INSTANCES}    l3_instance_net_3_1    l3_instance_net_3_2    l3_instance_net_3_3
25 @{SUBNETS_RANGE}    50.0.0.0/24    60.0.0.0/24    70.0.0.0/24
26 ${network1_vlan_id}    1236
27
28 *** Test Cases ***
29 Create VLAN Network (network_1)
30     [Documentation]    Create Network with neutron request.
31     # in the case that the controller under test is using legacy netvirt features, vlan segmentation is not supported,
32     # and we cannot create a vlan network. If those features are installed we will instead stick with vxlan.
33     : FOR    ${feature_name}    IN    @{legacy_feature_list}
34     \    ${feature_check_status}=    Run Keyword And Return Status    Verify Feature Is Installed    ${feature_name}
35     \    Exit For Loop If    '${feature_check_status}' == 'True'
36     Run Keyword If    '${feature_check_status}' == 'True'    Create Network    @{NETWORKS_NAME}[0]
37     ...    ELSE    Create Network    @{NETWORKS_NAME}[0]    --provider-network-type vlan --provider-physical-network ${PUBLIC_PHYSICAL_NETWORK} --provider-segment ${network1_vlan_id}
38
39 Create VXLAN Network (network_2)
40     [Documentation]    Create Network with neutron request.
41     Create Network    @{NETWORKS_NAME}[1]
42
43 Create VXLAN Network (network_3)
44     [Documentation]    Create Network with neutron request.
45     Create Network    @{NETWORKS_NAME}[2]
46
47 Create Subnets For network_1
48     [Documentation]    Create Sub Nets for the Networks with neutron request.
49     Create SubNet    @{NETWORKS_NAME}[0]    @{SUBNETS_NAME}[0]    @{SUBNETS_RANGE}[0]
50
51 Create Subnets For network_2
52     [Documentation]    Create Sub Nets for the Networks with neutron request.
53     Create SubNet    @{NETWORKS_NAME}[1]    @{SUBNETS_NAME}[1]    @{SUBNETS_RANGE}[1]
54
55 Create Subnets For network_3
56     [Documentation]    Create Sub Nets for the Networks with neutron request.
57     Create SubNet    @{NETWORKS_NAME}[2]    @{SUBNETS_NAME}[2]    @{SUBNETS_RANGE}[2]
58
59 Create Vm Instances For network_1
60     [Documentation]    Create Four Vm instances using flavor and image names for a network.
61     Create Vm Instances    network_1    ${NET_1_VM_INSTANCES}    sg=${SECURITY_GROUP}
62
63 Create Vm Instances For network_2
64     [Documentation]    Create Four Vm instances using flavor and image names for a network.
65     Create Vm Instances    network_2    ${NET_2_VM_INSTANCES}    sg=${SECURITY_GROUP}
66
67 Create Vm Instances For network_3
68     [Documentation]    Create Four Vm instances using flavor and image names for a network.
69     Create Vm Instances    network_3    ${NET_3_VM_INSTANCES}    sg=${SECURITY_GROUP}
70
71 Check Vm Instances Have Ip Address
72     [Documentation]    Test case to verify that all created VMs are ready and have received their ip addresses.
73     ...    We are polling first and longest on the last VM created assuming that if it's received it's address
74     ...    already the other instances should have theirs already or at least shortly thereafter.
75     # first, ensure all VMs are in ACTIVE state.    if not, we can just fail the test case and not waste time polling
76     # for dhcp addresses
77     : FOR    ${vm}    IN    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}    @{NET_3_VM_INSTANCES}
78     \    Poll VM Is ACTIVE    ${vm}
79     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
80     ...    true    @{NET_1_VM_INSTANCES}
81     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
82     ...    true    @{NET_2_VM_INSTANCES}
83     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
84     ...    true    @{NET_3_VM_INSTANCES}
85     ${NET3_L3_VM_IPS}    ${NET3_DHCP_IP}    Collect VM IP Addresses    false    @{NET_3_VM_INSTANCES}
86     ${NET2_L3_VM_IPS}    ${NET2_DHCP_IP}    Collect VM IP Addresses    false    @{NET_2_VM_INSTANCES}
87     ${NET1_L3_VM_IPS}    ${NET1_DHCP_IP}    Collect VM IP Addresses    false    @{NET_1_VM_INSTANCES}
88     ${VM_INSTANCES}=    Collections.Combine Lists    ${NET_1_VM_INSTANCES}    ${NET_2_VM_INSTANCES}    ${NET_3_VM_INSTANCES}
89     ${VM_IPS}=    Collections.Combine Lists    ${NET1_L3_VM_IPS}    ${NET2_L3_VM_IPS}    ${NET3_L3_VM_IPS}
90     ${LOOP_COUNT}    Get Length    ${VM_INSTANCES}
91     : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
92     \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
93     \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    openstack console log show @{VM_INSTANCES}[${index}]    30s
94     Set Suite Variable    ${NET1_L3_VM_IPS}
95     Set Suite Variable    ${NET1_DHCP_IP}
96     Set Suite Variable    ${NET2_L3_VM_IPS}
97     Set Suite Variable    ${NET2_DHCP_IP}
98     Set Suite Variable    ${NET3_L3_VM_IPS}
99     Set Suite Variable    ${NET3_DHCP_IP}
100     Should Not Contain    ${NET1_L3_VM_IPS}    None
101     Should Not Contain    ${NET2_L3_VM_IPS}    None
102     Should Not Contain    ${NET1_DHCP_IP}    None
103     Should Not Contain    ${NET2_DHCP_IP}    None
104     Should Not Contain    ${NET3_DHCP_IP}    None
105     [Teardown]    Run Keywords    Show Debugs    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}    @{NET_3_VM_INSTANCES}
106     ...    AND    Get Test Teardown Debugs
107
108 Create Routers
109     [Documentation]    Create Router
110     Create Router    router_1
111
112 Add Interfaces To Router
113     [Documentation]    Add Interfaces
114     : FOR    ${interface}    IN    @{SUBNETS_NAME}
115     \    Add Router Interface    router_1    ${interface}
116
117 Ping Vm Instance1 In network_2 From network_1(vxlan to vlan)
118     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
119     Ping Vm From DHCP Namespace    network_1    @{NET2_L3_VM_IPS}[0]
120
121 Ping Vm Instance2 In network_2 From network_1(vxlan to vlan)
122     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
123     Ping Vm From DHCP Namespace    network_1    @{NET2_L3_VM_IPS}[1]
124
125 Ping Vm Instance3 In network_2 From network_1(vxlan to vlan)
126     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
127     Ping Vm From DHCP Namespace    network_1    @{NET2_L3_VM_IPS}[2]
128
129 Ping Vm Instance1 In network_1 From network_2(vlan to vxlan)
130     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
131     Ping Vm From DHCP Namespace    network_2    @{NET1_L3_VM_IPS}[0]
132
133 Ping Vm Instance2 In network_1 From network_2(vlan to vxlan)
134     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
135     Ping Vm From DHCP Namespace    network_2    @{NET1_L3_VM_IPS}[1]
136
137 Ping Vm Instance3 In network_1 From network_2(vlan to vxlan)
138     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
139     Ping Vm From DHCP Namespace    network_2    @{NET1_L3_VM_IPS}[2]
140
141 Ping Vm Instance1 In network_3 From network_2(vxlan to vxlan)
142     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
143     Ping Vm From DHCP Namespace    network_2    @{NET3_L3_VM_IPS}[0]
144
145 Ping Vm Instance2 In network_3 From network_2(vxlan to vxlan)
146     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
147     Ping Vm From DHCP Namespace    network_2    @{NET3_L3_VM_IPS}[1]
148
149 Ping Vm Instance3 In network_3 From network_2(vxlan to vxlan)
150     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
151     Ping Vm From DHCP Namespace    network_2    @{NET3_L3_VM_IPS}[2]
152
153 Connectivity Tests From Vm Instance1 In network_1
154     [Documentation]    Login to the VM instance and test operations
155     ${dst_list}=    Create List    @{NET1_L3_VM_IPS}    @{NET2_L3_VM_IPS}
156     Log    ${dst_list}
157     Test Operations From Vm Instance    network_1    @{NET1_L3_VM_IPS}[0]    ${dst_list}
158
159 Connectivity Tests From Vm Instance2 In network_1
160     [Documentation]    Login to the vm instance and test operations
161     ${dst_list}=    Create List    @{NET1_L3_VM_IPS}    @{NET2_L3_VM_IPS}
162     Log    ${dst_list}
163     Test Operations From Vm Instance    network_1    @{NET1_L3_VM_IPS}[1]    ${dst_list}
164
165 Connectivity Tests From Vm Instance3 In network_1
166     [Documentation]    Login to the vm instance and test operations
167     ${dst_list}=    Create List    @{NET1_L3_VM_IPS}    @{NET2_L3_VM_IPS}
168     Log    ${dst_list}
169     Test Operations From Vm Instance    network_1    @{NET1_L3_VM_IPS}[2]    ${dst_list}
170
171 Connectivity Tests From Vm Instance1 In network_2
172     [Documentation]    Login to the vm instance and test operations
173     ${dst_list}=    Create List    @{NET1_L3_VM_IPS}    @{NET2_L3_VM_IPS}
174     Log    ${dst_list}
175     Test Operations From Vm Instance    network_2    @{NET2_L3_VM_IPS}[0]    ${dst_list}
176
177 Connectivity Tests From Vm Instance2 In network_2
178     [Documentation]    Logging to the vm instance using generated key pair.
179     ${dst_list}=    Create List    @{NET1_L3_VM_IPS}    @{NET2_L3_VM_IPS}
180     Log    ${dst_list}
181     Test Operations From Vm Instance    network_2    @{NET2_L3_VM_IPS}[1]    ${dst_list}
182
183 Connectivity Tests From Vm Instance3 In network_2
184     [Documentation]    Logging to the vm instance using generated key pair.
185     ${dst_list}=    Create List    @{NET1_L3_VM_IPS}    @{NET2_L3_VM_IPS}
186     Log    ${dst_list}
187     Test Operations From Vm Instance    network_2    @{NET2_L3_VM_IPS}[2]    ${dst_list}
188
189 Delete Vm Instances In network_1
190     [Documentation]    Delete Vm instances using instance names in network_1.
191     : FOR    ${VmElement}    IN    @{NET_1_VM_INSTANCES}
192     \    Delete Vm Instance    ${VmElement}
193
194 Delete Vm Instances In network_2
195     [Documentation]    Delete Vm instances using instance names in network_2.
196     : FOR    ${VmElement}    IN    @{NET_2_VM_INSTANCES}
197     \    Delete Vm Instance    ${VmElement}
198
199 Delete Vm Instances In network_3
200     [Documentation]    Delete Vm instances using instance names in network_3.
201     : FOR    ${VmElement}    IN    @{NET_3_VM_INSTANCES}
202     \    Delete Vm Instance    ${VmElement}
203     [Teardown]    Run Keywords    Show Debugs    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}    @{NET_3_VM_INSTANCES}
204     ...    AND    Get Test Teardown Debugs
205
206 Delete Router Interfaces
207     [Documentation]    Remove Interface to the subnets.
208     : FOR    ${interface}    IN    @{SUBNETS_NAME}
209     \    Remove Interface    router_1    ${interface}
210
211 Delete Routers
212     [Documentation]    Delete Router and Interface to the subnets.
213     Delete Router    router_1
214
215 Delete Sub Networks In network_1
216     [Documentation]    Delete Sub Nets for the Networks with neutron request.
217     Delete SubNet    subnet_1
218
219 Delete Sub Networks In network_2
220     [Documentation]    Delete Sub Nets for the Networks with neutron request.
221     Delete SubNet    subnet_2
222
223 Delete Sub Networks In network_3
224     [Documentation]    Delete Sub Nets for the Networks with neutron request.
225     Delete SubNet    subnet_3
226
227 Delete Networks
228     [Documentation]    Delete Networks with neutron request.
229     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
230     \    Delete Network    ${NetworkElement}
231
232 Verify Flows Cleanup
233     [Documentation]    Verify that flows have been cleaned up properly after removing all neutron configurations
234     Verify Flows Are Cleaned Up On All OpenStack Nodes