Add OpenStack grenade
[integration/test.git] / csit / suites / openstack / connectivity / external_network.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    OpenStackOperations.OpenStack Suite Teardown
6 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
7 Test Teardown     OpenStackOperations.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}    l3_ext_sg
19 @{NETWORKS}       l3_ext_net
20 @{SUBNETS}        l3_ext_sub
21 ${ROUTER}         l3_ext_router
22 @{FIP_VMS}        fip_vm_1    fip_vm_2
23 @{SNAT_VMS}       snat_vm_1    snat_vm_2
24 @{SUBNET_CIDRS}    41.0.0.0/24
25 # Parameter values below are based on releng/builder - changing them requires updates in releng/builder as well
26 ${EXTERNAL_GATEWAY}    10.10.10.250
27 ${EXTERNAL_PNF}    10.10.10.253
28 ${EXTERNAL_SUBNET}    10.10.10.0/24
29 ${EXTERNAL_SUBNET_ALLOCATION_POOL}    start=10.10.10.2,end=10.10.10.249
30 ${EXTERNAL_INTERNET_ADDR}    10.9.9.9
31 ${EXTERNAL_NET_NAME}    external-net
32 ${EXTERNAL_SUBNET_NAME}    external-subnet
33
34 *** Test Cases ***
35 Create All Controller Sessions
36     [Documentation]    Create sessions for all three controllers
37     ClusterManagement.ClusterManagement Setup
38
39 Create Private Network
40     [Documentation]    Create Network with neutron request.
41     : FOR    ${network}    IN    @{NETWORKS}
42     \    OpenStackOperations.Create Network    ${network}
43
44 Create Subnet For Private Network
45     [Documentation]    Create Sub Net for the Network with neutron request.
46     OpenStackOperations.Create SubNet    @{NETWORKS}[0]    @{SUBNETS}[0]    @{SUBNET_CIDRS}[0]
47
48 Add Ssh Allow Rule
49     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
50     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
51
52 Create Vm Instances
53     [Documentation]    Create VM instances using flavor and image names for a network.
54     OpenStackOperations.Create Vm Instances    @{NETWORKS}[0]    ${FIP_VMS}    sg=${SECURITY_GROUP}
55     OpenStackOperations.Create Vm Instances    @{NETWORKS}[0]    ${SNAT_VMS}    sg=${SECURITY_GROUP}
56
57 Check Vm Instances Have Ip Address
58     @{FIP_VM_IPS}    ${FLOATING_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{FIP_VMS}
59     @{SNAT_VM_IPS}    ${SNAT_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{SNAT_VMS}
60     BuiltIn.Set Suite Variable    @{FIP_VM_IPS}
61     BuiltIn.Set Suite Variable    @{SNAT_VM_IPS}
62     BuiltIn.Should Not Contain    ${FIP_VM_IPS}    None
63     BuiltIn.Should Not Contain    ${SNAT_VM_IPS}    None
64     BuiltIn.Should Not Contain    ${FLOATING_DHCP_IP}    None
65     BuiltIn.Should Not Contain    ${SNAT_DHCP_IP}    None
66     [Teardown]    BuiltIn.Run Keywords    OpenStackOperations.Show Debugs    @{FIP_VMS}    @{SNAT_VMS}
67     ...    AND    OpenStackOperations.Get Test Teardown Debugs
68
69 Create External Network And Subnet
70     OpenStackOperations.Create Network    ${EXTERNAL_NET_NAME}    --provider-network-type flat --provider-physical-network ${PUBLIC_PHYSICAL_NETWORK}
71     OpenStackOperations.Update Network    ${EXTERNAL_NET_NAME}    --external
72     OpenStackOperations.Create Subnet    ${EXTERNAL_NET_NAME}    ${EXTERNAL_SUBNET_NAME}    ${EXTERNAL_SUBNET}    --gateway ${EXTERNAL_GATEWAY} --allocation-pool ${EXTERNAL_SUBNET_ALLOCATION_POOL}
73
74 Create Router
75     [Documentation]    Create Router and Add Interface to the subnets.
76     OpenStackOperations.Create Router    ${ROUTER}
77
78 Add Interfaces To Router
79     [Documentation]    Add Interfaces
80     : FOR    ${interface}    IN    @{SUBNETS}
81     \    OpenStackOperations.Add Router Interface    ${ROUTER}    ${interface}
82
83 Add Router Gateway To Router
84     [Documentation]    OpenStackOperations.Add Router Gateway
85     OpenStackOperations.Add Router Gateway    ${ROUTER}    ${EXTERNAL_NET_NAME}
86
87 Verify Created Router
88     [Documentation]    Check created routers using northbound rest calls
89     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
90     BuiltIn.Log    ${data}
91     Should Contain    ${data}    ${ROUTER}
92
93 Create And Associate Floating IPs for VMs
94     [Documentation]    Create and associate a floating IP for the VM
95     ${VM_FLOATING_IPS} =    OpenStackOperations.Create And Associate Floating IPs    ${EXTERNAL_NET_NAME}    @{FIP_VMS}
96     BuiltIn.Set Suite Variable    ${VM_FLOATING_IPS}
97     [Teardown]    BuiltIn.Run Keywords    OpenStackOperations.Show Debugs    @{FIP_VMS}
98     ...    AND    OpenStackOperations.Get Test Teardown Debugs
99
100 Ping External Gateway From Control Node
101     [Documentation]    Check reachability of external gateway by pinging it from the control node.
102     OpenStackOperations.Ping Vm From Control Node    ${EXTERNAL_GATEWAY}    additional_args=-I ${EXTERNAL_INTERNET_ADDR}
103
104 Ping Vm Instance1 Floating IP From Control Node
105     [Documentation]    Check reachability of VM instance through floating IP by pinging them.
106     OpenStackOperations.Ping Vm From Control Node    @{VM_FLOATING_IPS}[0]    additional_args=-I ${EXTERNAL_INTERNET_ADDR}
107
108 Ping Vm Instance2 Floating IP From Control Node
109     [Documentation]    Check reachability of VM instance through floating IP by pinging them.
110     OpenStackOperations.Ping Vm From Control Node    @{VM_FLOATING_IPS}[1]    additional_args=-I ${EXTERNAL_INTERNET_ADDR}
111
112 Ping Vm Instance2 Floating IP From Vm Instance1 With Floating IP (Hairpinning)
113     [Documentation]    Check reachability of VM instance floating IP from another VM instance with FIP (with ttl=1 to make sure no router hops)
114     ${dst_ip}=    BuiltIn.Create List    @{VM_FLOATING_IPS}[1]
115     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{FIP_VM_IPS}[0]    ${dst_ip}    ttl=1
116
117 Ping External Network PNF from Vm Instance 1
118     [Documentation]    Check reachability of External Network PNF from VM instance (with ttl=1 to make sure no router hops)
119     ${dst_ip}=    BuiltIn.Create List    ${EXTERNAL_PNF}
120     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{FIP_VM_IPS}[0]    ${dst_ip}    ttl=1
121
122 SNAT - TCP connection to External Gateway From SNAT VM Instance1
123     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
124     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[0]    @{SNAT_VM_IPS}[0]    ${EXTERNAL_GATEWAY}
125
126 SNAT - UDP connection to External Gateway From SNAT VM Instance1
127     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
128     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[0]    @{SNAT_VM_IPS}[0]    ${EXTERNAL_GATEWAY}    -u
129
130 SNAT - TCP connection to External Gateway From SNAT VM Instance2
131     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
132     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[0]    @{SNAT_VM_IPS}[1]    ${EXTERNAL_GATEWAY}
133
134 SNAT - UDP connection to External Gateway From SNAT VM Instance2
135     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
136     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[0]    @{SNAT_VM_IPS}[1]    ${EXTERNAL_GATEWAY}    -u
137
138 Delete Vm Instances
139     [Documentation]    Delete Vm instances using instance names.
140     : FOR    ${vm}    IN    @{FIP_VMS}
141     \    OpenStackOperations.Delete Vm Instance    ${vm}
142     : FOR    ${vm}    IN    @{SNAT_VMS}
143     \    OpenStackOperations.Delete Vm Instance    ${vm}
144
145 Delete Router Interfaces
146     [Documentation]    Remove Interface to the subnets.
147     : FOR    ${interface}    IN    @{SUBNETS}
148     \    OpenStackOperations.Remove Interface    ${ROUTER}    ${interface}
149
150 Delete Routers
151     [Documentation]    Delete Router and Interface to the subnets.
152     OpenStackOperations.Delete Router    ${ROUTER}
153
154 Verify Deleted Router
155     [Documentation]    Check deleted router using northbound rest call
156     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
157     BuiltIn.Log    ${data}
158     BuiltIn.Should Not Contain    ${data}    ${ROUTER}
159
160 Delete Sub Network
161     [Documentation]    Delete Sub Net for the Network with neutron request.
162     OpenStackOperations.Delete SubNet    @{SUBNETS}[0]
163
164 Delete Networks
165     [Documentation]    Delete Networks with neutron request.
166     : FOR    ${network}    IN    @{NETWORKS}
167     \    OpenStackOperations.Delete Network    ${network}
168     OpenStackOperations.Delete Network    ${EXTERNAL_NET_NAME}
169
170 Delete Security Group
171     [Documentation]    Delete security groups with neutron request
172     OpenStackOperations.Delete SecurityGroup    ${SECURITY_GROUP}
173
174 Verify Flows Cleanup
175     [Documentation]    Verify that flows have been cleaned up properly after removing all neutron configurations
176     DataModels.Verify Flows Are Cleaned Up On All OpenStack Nodes