Fix sfc variable VP_IPS -> NET1_VM_IPS
[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    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 Add Ssh Allow Rule
48     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
49     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
50
51 Create Vm Instances
52     [Documentation]    Create VM instances using flavor and image names for a network.
53     OpenStackOperations.Create Vm Instances    @{NETWORKS_NAME}[0]    ${VM_INSTANCES_FLOATING}    sg=${SECURITY_GROUP}
54     OpenStackOperations.Create Vm Instances    @{NETWORKS_NAME}[0]    ${VM_INSTANCES_SNAT}    sg=${SECURITY_GROUP}
55
56 Check Vm Instances Have Ip Address
57     @{FLOATING_VM_IPS}    ${FLOATING_DHCP_IP} =    Get VM IPs    @{VM_INSTANCES_FLOATING}
58     @{SNAT_VM_IPS}    ${SNAT_DHCP_IP} =    Get VM IPs    @{VM_INSTANCES_SNAT}
59     Set Suite Variable    @{FLOATING_VM_IPS}
60     Set Suite Variable    @{SNAT_VM_IPS}
61     Should Not Contain    ${FLOATING_VM_IPS}    None
62     Should Not Contain    ${SNAT_VM_IPS}    None
63     Should Not Contain    ${FLOATING_DHCP_IP}    None
64     Should Not Contain    ${SNAT_DHCP_IP}    None
65     [Teardown]    Run Keywords    Show Debugs    @{VM_INSTANCES_FLOATING}    @{VM_INSTANCES_SNAT}
66     ...    AND    Get Test Teardown Debugs
67
68 Create External Network And Subnet
69     Create Network    ${external_net_name}    --provider-network-type flat --provider-physical-network ${PUBLIC_PHYSICAL_NETWORK}
70     Update Network    ${external_net_name}    --external
71     Create Subnet    ${external_net_name}    ${external_subnet_name}    ${external_subnet}    --gateway ${external_gateway} --allocation-pool ${external_subnet_allocation_pool}
72
73 Create Router
74     [Documentation]    Create Router and Add Interface to the subnets.
75     OpenStackOperations.Create Router    router1
76
77 Add Interfaces To Router
78     [Documentation]    Add Interfaces
79     : FOR    ${interface}    IN    @{SUBNETS_NAME}
80     \    OpenStackOperations.Add Router Interface    router1    ${interface}
81
82 Add Router Gateway To Router
83     [Documentation]    Add Router Gateway
84     OpenStackOperations.Add Router Gateway    router1    ${external_net_name}
85
86 Verify Created Routers
87     [Documentation]    Check created routers using northbound rest calls
88     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
89     Log    ${data}
90     Should Contain    ${data}    router1
91
92 Create And Associate Floating IPs for VMs
93     [Documentation]    Create and associate a floating IP for the VM
94     ${VM_FLOATING_IPS}    OpenStackOperations.Create And Associate Floating IPs    ${external_net_name}    @{VM_INSTANCES_FLOATING}
95     Set Suite Variable    ${VM_FLOATING_IPS}
96     [Teardown]    Run Keywords    Show Debugs    @{VM_INSTANCES_FLOATING}
97     ...    AND    Get Test Teardown Debugs
98
99 Ping External Gateway From Control Node
100     [Documentation]    Check reachability of external gateway by pinging it from the control node.
101     OpenStackOperations.Ping Vm From Control Node    ${external_gateway}    additional_args=-I ${external_internet_addr}
102
103 Ping Vm Instance1 Floating IP From Control Node
104     [Documentation]    Check reachability of VM instance through floating IP by pinging them.
105     OpenStackOperations.Ping Vm From Control Node    @{VM_FLOATING_IPS}[0]    additional_args=-I ${external_internet_addr}
106
107 Ping Vm Instance2 Floating IP From Control Node
108     [Documentation]    Check reachability of VM instance through floating IP by pinging them.
109     OpenStackOperations.Ping Vm From Control Node    @{VM_FLOATING_IPS}[1]    additional_args=-I ${external_internet_addr}
110
111 Ping Vm Instance2 Floating IP From Vm Instance1 With Floating IP (Hairpinning)
112     [Documentation]    Check reachability of VM instance floating IP from another VM instance with FIP (with ttl=1 to make sure no router hops)
113     ${dst_ip}=    Create List    @{VM_FLOATING_IPS}[1]
114     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{FLOATING_VM_IPS}[0]    ${dst_ip}    ttl=1
115
116 Ping External Network PNF from Vm Instance 1
117     [Documentation]    Check reachability of External Network PNF from VM instance (with ttl=1 to make sure no router hops)
118     ${dst_ip}=    Create List    ${external_pnf}
119     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{FLOATING_VM_IPS}[0]    ${dst_ip}    ttl=1
120
121 SNAT - TCP connection to External Gateway From SNAT VM Instance1
122     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
123     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[0]    ${external_gateway}
124
125 SNAT - UDP connection to External Gateway From SNAT VM Instance1
126     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
127     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[0]    ${external_gateway}    -u
128
129 SNAT - TCP connection to External Gateway From SNAT VM Instance2
130     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
131     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[1]    ${external_gateway}
132
133 SNAT - UDP connection to External Gateway From SNAT VM Instance2
134     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
135     Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[1]    ${external_gateway}    -u
136
137 Delete Vm Instances
138     [Documentation]    Delete Vm instances using instance names.
139     : FOR    ${VmElement}    IN    @{VM_INSTANCES_FLOATING}
140     \    OpenStackOperations.Delete Vm Instance    ${VmElement}
141     : FOR    ${VmElement}    IN    @{VM_INSTANCES_SNAT}
142     \    OpenStackOperations.Delete Vm Instance    ${VmElement}
143
144 Delete Router Interfaces
145     [Documentation]    Remove Interface to the subnets.
146     : FOR    ${interface}    IN    @{SUBNETS_NAME}
147     \    OpenStackOperations.Remove Interface    router1    ${interface}
148
149 Delete Routers
150     [Documentation]    Delete Router and Interface to the subnets.
151     OpenStackOperations.Delete Router    router1
152
153 Verify Deleted Routers
154     [Documentation]    Check deleted routers using northbound rest calls
155     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
156     Log    ${data}
157     Should Not Contain    ${data}    router1
158
159 Delete Sub Networks
160     [Documentation]    Delete Sub Nets for the Networks with neutron request.
161     OpenStackOperations.Delete SubNet    @{SUBNETS_NAME}[0]
162
163 Delete Networks
164     [Documentation]    Delete Networks with neutron request.
165     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
166     \    OpenStackOperations.Delete Network    ${NetworkElement}
167     OpenStackOperations.Delete Network    ${external_net_name}
168
169 Delete Security Group
170     [Documentation]    Delete security groups with neutron request
171     Delete SecurityGroup    ${SECURITY_GROUP}
172
173 Verify Flows Cleanup
174     [Documentation]    Verify that flows have been cleaned up properly after removing all neutron configurations
175     Verify Flows Are Cleaned Up On All OpenStack Nodes