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