99cf759e40523b2f00fe15de218141aa4082db99
[integration/test.git] / csit / suites / openstack / connectivity / 03_external_network_tests.robot
1 *** Settings ***
2 Documentation     Test suite to check North-South connectivity in L3 using a router and an external network
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
17 *** Variables ***
18 ${SECURITY_GROUP}    sg-connectivity
19 @{NETWORKS_NAME}    l3_net
20 @{SUBNETS_NAME}    l3_subnet
21 @{VM_INSTANCES_FLOATING}    VmInstanceFloating1    VmInstanceFloating2
22 @{VM_INSTANCES_SNAT}    VmInstanceSnat3    VmInstanceSnat4
23 @{SUBNETS_RANGE}    90.0.0.0/24
24 # Parameter values below are based on releng/builder - changing them requires updates in releng/builder as well
25 ${external_gateway}    10.10.10.250
26 ${external_pnf}    10.10.10.253
27 ${external_subnet}    10.10.10.0/24
28 ${external_subnet_allocation_pool}    start=10.10.10.2,end=10.10.10.249
29 ${external_internet_addr}    10.9.9.9
30 ${external_net_name}    external-net
31 ${external_subnet_name}    external-subnet
32
33 *** Test Cases ***
34 Create All Controller Sessions
35     [Documentation]    Create sessions for all three controllers
36     ClusterManagement.ClusterManagement Setup
37
38 Create Private Network
39     [Documentation]    Create Network with neutron request.
40     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
41     \    OpenStackOperations.Create Network    ${NetworkElement}
42
43 Create Subnet For Private Network
44     [Documentation]    Create Sub Nets for the Networks with neutron request.
45     OpenStackOperations.Create SubNet    @{NETWORKS_NAME}[0]    @{SUBNETS_NAME}[0]    @{SUBNETS_RANGE}[0]
46
47 Create Vm Instances
48     [Documentation]    Create VM instances using flavor and image names for a network.
49     OpenStackOperations.Create Vm Instances    @{NETWORKS_NAME}[0]    ${VM_INSTANCES_FLOATING}    sg=${SECURITY_GROUP}
50     OpenStackOperations.Create Vm Instances    @{NETWORKS_NAME}[0]    ${VM_INSTANCES_SNAT}    sg=${SECURITY_GROUP}
51
52 Check Vm Instances Have Ip Address
53     [Documentation]    Test case to verify that all created VMs are ready and have received their ip addresses.
54     ...    We are polling first and longest on the last VM created assuming that if it's received it's address
55     ...    already the other instances should have theirs already or at least shortly thereafter.
56     # first, ensure all VMs are in ACTIVE state.    if not, we can just fail the test case and not waste time polling
57     # for dhcp addresses
58     : FOR    ${vm}    IN    @{VM_INSTANCES_FLOATING}    @{VM_INSTANCES_SNAT}
59     \    Poll VM Is ACTIVE    ${vm}
60     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
61     ...    true    @{VM_INSTANCES_FLOATING}
62     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
63     ...    true    @{VM_INSTANCES_SNAT}
64     ${FLOATING_VM_IPS}    ${FLOATING_DHCP_IP}    Collect VM IP Addresses    false    @{VM_INSTANCES_FLOATING}
65     ${SNAT_VM_IPS}    ${SNAT_DHCP_IP}    Collect VM IP Addresses    false    @{VM_INSTANCES_SNAT}
66     ${VM_INSTANCES}=    Collections.Combine Lists    ${VM_INSTANCES_FLOATING}    ${VM_INSTANCES_SNAT}
67     ${VM_IPS}=    Collections.Combine Lists    ${FLOATING_VM_IPS}    ${SNAT_VM_IPS}
68     ${LOOP_COUNT}    Get Length    ${VM_INSTANCES}
69     : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
70     \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
71     \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    openstack console log show @{VM_INSTANCES}[${index}]    30s
72     Set Suite Variable    ${FLOATING_VM_IPS}
73     Set Suite Variable    ${SNAT_VM_IPS}
74     Should Not Contain    ${FLOATING_VM_IPS}    None
75     Should Not Contain    ${SNAT_VM_IPS}    None
76     Should Not Contain    @{FLOATING_DHCP_IP}[0]    None
77     Should Not Contain    @{SNAT_DHCP_IP}[0]    None
78     [Teardown]    Run Keywords    Show Debugs    @{VM_INSTANCES_FLOATING}    @{VM_INSTANCES_SNAT}
79     ...    AND    Get Test Teardown Debugs
80
81 Create External Network And Subnet
82     Create Network    ${external_net_name}    --provider-network-type flat --provider-physical-network ${PUBLIC_PHYSICAL_NETWORK}
83     Update Network    ${external_net_name}    --external
84     Create Subnet    ${external_net_name}    ${external_subnet_name}    ${external_subnet}    --gateway ${external_gateway} --allocation-pool ${external_subnet_allocation_pool}
85
86 Create Router
87     [Documentation]    Create Router and Add Interface to the subnets.
88     OpenStackOperations.Create Router    router1
89
90 Add Interfaces To Router
91     [Documentation]    Add Interfaces
92     : FOR    ${interface}    IN    @{SUBNETS_NAME}
93     \    OpenStackOperations.Add Router Interface    router1    ${interface}
94
95 Add Router Gateway To Router
96     [Documentation]    Add Router Gateway
97     OpenStackOperations.Add Router Gateway    router1    ${external_net_name}
98
99 Verify Created Routers
100     [Documentation]    Check created routers using northbound rest calls
101     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
102     Log    ${data}
103     Should Contain    ${data}    router1
104
105 Create And Associate Floating IPs for VMs
106     [Documentation]    Create and associate a floating IP for the VM
107     ${VM_FLOATING_IPS}    OpenStackOperations.Create And Associate Floating IPs    ${external_net_name}    @{VM_INSTANCES_FLOATING}
108     Set Suite Variable    ${VM_FLOATING_IPS}
109     [Teardown]    Run Keywords    Show Debugs    @{VM_INSTANCES_FLOATING}
110     ...    AND    Get Test Teardown Debugs
111
112 Ping External Gateway From Control Node
113     [Documentation]    Check reachability of external gateway by pinging it from the control node.
114     OpenStackOperations.Ping Vm From Control Node    ${external_gateway}    additional_args=-I ${external_internet_addr}
115
116 Ping Vm Instance1 Floating IP From Control Node
117     [Documentation]    Check reachability of VM instance through floating IP by pinging them.
118     OpenStackOperations.Ping Vm From Control Node    @{VM_FLOATING_IPS}[0]    additional_args=-I ${external_internet_addr}
119
120 Ping Vm Instance2 Floating IP From Control Node
121     [Documentation]    Check reachability of VM instance through floating IP by pinging them.
122     OpenStackOperations.Ping Vm From Control Node    @{VM_FLOATING_IPS}[1]    additional_args=-I ${external_internet_addr}
123
124 Ping Vm Instance2 Floating IP From Vm Instance1 With Floating IP (Hairpinning)
125     [Documentation]    Check reachability of VM instance floating IP from another VM instance with FIP (with ttl=1 to make sure no router hops)
126     ${dst_ip}=    Create List    @{VM_FLOATING_IPS}[1]
127     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{FLOATING_VM_IPS}[0]    ${dst_ip}    ttl=1
128
129 Ping External Network PNF from Vm Instance 1
130     [Documentation]    Check reachability of External Network PNF from VM instance (with ttl=1 to make sure no router hops)
131     ${dst_ip}=    Create List    ${external_pnf}
132     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{FLOATING_VM_IPS}[0]    ${dst_ip}    ttl=1
133
134 SNAT - TCP connection to External Gateway From SNAT VM Instance1
135     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
136     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[0]    ${external_gateway}
137
138 SNAT - UDP connection to External Gateway From SNAT VM Instance1
139     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
140     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[0]    ${external_gateway}    -u
141
142 SNAT - TCP connection to External Gateway From SNAT VM Instance2
143     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
144     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[1]    ${external_gateway}
145
146 SNAT - UDP connection to External Gateway From SNAT VM Instance2
147     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
148     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[1]    ${external_gateway}    -u
149
150 Delete Vm Instances
151     [Documentation]    Delete Vm instances using instance names.
152     : FOR    ${VmElement}    IN    @{VM_INSTANCES_FLOATING}
153     \    OpenStackOperations.Delete Vm Instance    ${VmElement}
154     : FOR    ${VmElement}    IN    @{VM_INSTANCES_SNAT}
155     \    OpenStackOperations.Delete Vm Instance    ${VmElement}
156
157 Delete Router Interfaces
158     [Documentation]    Remove Interface to the subnets.
159     : FOR    ${interface}    IN    @{SUBNETS_NAME}
160     \    OpenStackOperations.Remove Interface    router1    ${interface}
161
162 Delete Routers
163     [Documentation]    Delete Router and Interface to the subnets.
164     OpenStackOperations.Delete Router    router1
165
166 Verify Deleted Routers
167     [Documentation]    Check deleted routers using northbound rest calls
168     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
169     Log    ${data}
170     Should Not Contain    ${data}    router1
171
172 Delete Sub Networks
173     [Documentation]    Delete Sub Nets for the Networks with neutron request.
174     OpenStackOperations.Delete SubNet    @{SUBNETS_NAME}[0]
175
176 Delete Networks
177     [Documentation]    Delete Networks with neutron request.
178     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
179     \    OpenStackOperations.Delete Network    ${NetworkElement}
180     OpenStackOperations.Delete Network    ${external_net_name}
181
182 Verify Flows Cleanup
183     [Documentation]    Verify that flows have been cleaned up properly after removing all neutron configurations
184     Verify Flows Are Cleaned Up On All OpenStack Nodes