2 Documentation Test suite to check North-South connectivity in L3 using a router and an external network
3 Suite Setup Devstack Suite Setup source_pwd=yes
4 Suite Teardown Close All Connections
5 Test Teardown Get Test Teardown Debugs
7 Library OperatingSystem
8 Library RequestsLibrary
9 Resource ../../../libraries/DevstackUtils.robot
10 Resource ../../../libraries/OpenStackOperations.robot
11 Resource ../../../libraries/Utils.robot
14 @{NETWORKS_NAME} l3_net
15 @{SUBNETS_NAME} l3_subnet
16 @{VM_INSTANCES_FLOATING} VmInstanceFloating1 VmInstanceFloating2
17 @{VM_INSTANCES_SNAT} VmInstanceSnat3 VmInstanceSnat4
18 @{SUBNETS_RANGE} 90.0.0.0/24
19 ${external_gateway} 10.10.10.250
20 ${external_subnet} 10.10.10.0/24
21 ${external_physical_network} physnet1
22 ${external_net_name} external-net
23 ${external_subnet_name} external-subnet
26 Create All Controller Sessions
27 [Documentation] Create sessions for all three controllers
28 ClusterManagement.ClusterManagement Setup
30 Create Private Network
31 [Documentation] Create Network with neutron request.
32 : FOR ${NetworkElement} IN @{NETWORKS_NAME}
33 \ OpenStackOperations.Create Network ${NetworkElement}
35 Create Subnet For Private Network
36 [Documentation] Create Sub Nets for the Networks with neutron request.
37 OpenStackOperations.Create SubNet @{NETWORKS_NAME}[0] @{SUBNETS_NAME}[0] @{SUBNETS_RANGE}[0]
40 [Documentation] Create VM instances using flavor and image names for a network.
41 OpenStackOperations.Create Vm Instances @{NETWORKS_NAME}[0] ${VM_INSTANCES_FLOATING} sg=csit
42 OpenStackOperations.Create Vm Instances @{NETWORKS_NAME}[0] ${VM_INSTANCES_SNAT} sg=csit
44 Check Vm Instances Have Ip Address
45 [Documentation] Test case to verify that all created VMs are ready and have received their ip addresses.
46 ... We are polling first and longest on the last VM created assuming that if it's received it's address
47 ... already the other instances should have theirs already or at least shortly thereafter.
48 # first, ensure all VMs are in ACTIVE state. if not, we can just fail the test case and not waste time polling
50 : FOR ${vm} IN @{VM_INSTANCES_FLOATING} @{VM_INSTANCES_SNAT}
51 \ Wait Until Keyword Succeeds 15s 5s Verify VM Is ACTIVE ${vm}
52 ${FLOATING_VM_COUNT} Get Length ${VM_INSTANCES_FLOATING}
53 ${SNAT_VM_COUNT} Get Length ${VM_INSTANCES_SNAT}
54 ${LOOP_COUNT} Evaluate ${FLOATING_VM_COUNT}+${SNAT_VM_COUNT}
55 : FOR ${index} IN RANGE 1 ${LOOP_COUNT}
56 \ ${FLOATING_VM_IPS} ${FLOATING_DHCP_IP} Wait Until Keyword Succeeds 180s 10s Verify VMs Received DHCP Lease
57 \ ... @{VM_INSTANCES_FLOATING}
58 \ ${SNAT_VM_IPS} ${SNAT_DHCP_IP} Wait Until Keyword Succeeds 180s 10s Verify VMs Received DHCP Lease
59 \ ... @{VM_INSTANCES_SNAT}
60 \ ${FLOATING_VM_LIST_LENGTH}= Get Length ${FLOATING_VM_IPS}
61 \ ${SNAT_VM_LIST_LENGTH}= Get Length ${SNAT_VM_IPS}
62 \ Exit For Loop If ${FLOATING_VM_LIST_LENGTH}==${FLOATING_VM_COUNT} and ${SNAT_VM_LIST_LENGTH}==${SNAT_VM_COUNT}
63 Append To List ${FLOATING_VM_IPS} ${FLOATING_DHCP_IP}
64 Set Suite Variable ${FLOATING_VM_IPS}
65 Append To List ${SNAT_VM_IPS} ${SNAT_DHCP_IP}
66 Set Suite Variable ${SNAT_VM_IPS}
67 [Teardown] Run Keywords Show Debugs ${VM_INSTANCES_FLOATING} ${VM_INSTANCES_SNAT}
68 ... AND Get Test Teardown Debugs
70 Create External Network And Subnet
71 Create Network ${external_net_name} --router:external --provider:network_type=flat --provider:physical_network=${external_physical_network}
72 Create Subnet ${external_net_name} ${external_subnet_name} ${external_subnet} --gateway ${external_gateway}
75 [Documentation] Create Router and Add Interface to the subnets.
76 OpenStackOperations.Create Router router1
78 Add Interfaces To Router
79 [Documentation] Add Interfaces
80 : FOR ${interface} IN @{SUBNETS_NAME}
81 \ OpenStackOperations.Add Router Interface router1 ${interface}
83 Add Router Gateway To Router
84 [Documentation] Add Router Gateway
85 OpenStackOperations.Add Router Gateway router1 ${external_net_name}
87 Verify Created Routers
88 [Documentation] Check created routers using northbound rest calls
89 ${data} Utils.Get Data From URI 1 ${NEUTRON_ROUTERS_API}
91 Should Contain ${data} router1
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} @{VM_INSTANCES_FLOATING}
96 Set Suite Variable ${VM_FLOATING_IPS}
97 [Teardown] Run Keywords Show Debugs ${VM_INSTANCES_FLOATING}
98 ... AND Get Test Teardown Debugs
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}
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]
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]
112 Prepare SNAT - Install Netcat On Controller
113 Install Netcat On Controller
115 SNAT - TCP connection to External Gateway From SNAT VM Instance1
116 [Documentation] Login to the VM instance and test TCP connection to the controller via SNAT
117 Test Netcat Operations From Vm Instance @{NETWORKS_NAME}[0] @{SNAT_VM_IPS}[0] ${external_gateway}
119 SNAT - UDP connection to External Gateway From SNAT VM Instance1
120 [Documentation] Login to the VM instance and test UDP connection to the controller via SNAT
121 Test Netcat Operations From Vm Instance @{NETWORKS_NAME}[0] @{SNAT_VM_IPS}[0] ${external_gateway} -u
123 SNAT - TCP connection to External Gateway From SNAT VM Instance2
124 [Documentation] Login to the VM instance and test TCP connection to the controller via SNAT
125 Test Netcat Operations From Vm Instance @{NETWORKS_NAME}[0] @{SNAT_VM_IPS}[1] ${external_gateway}
127 SNAT - UDP connection to External Gateway From SNAT VM Instance2
128 [Documentation] Login to the VM instance and test UDP connection to the controller via SNAT
129 Test Netcat Operations From Vm Instance @{NETWORKS_NAME}[0] @{SNAT_VM_IPS}[1] ${external_gateway} -u
132 [Documentation] Delete Vm instances using instance names.
133 : FOR ${VmElement} IN @{VM_INSTANCES_FLOATING}
134 \ OpenStackOperations.Delete Vm Instance ${VmElement}
135 : FOR ${VmElement} IN @{VM_INSTANCES_SNAT}
136 \ OpenStackOperations.Delete Vm Instance ${VmElement}
138 Delete Router Interfaces
139 [Documentation] Remove Interface to the subnets.
140 : FOR ${interface} IN @{SUBNETS_NAME}
141 \ OpenStackOperations.Remove Interface router1 ${interface}
144 [Documentation] Delete Router and Interface to the subnets.
145 OpenStackOperations.Delete Router router1
147 Verify Deleted Routers
148 [Documentation] Check deleted routers using northbound rest calls
149 ${data} Utils.Get Data From URI 1 ${NEUTRON_ROUTERS_API}
151 Should Not Contain ${data} router1
154 [Documentation] Delete Sub Nets for the Networks with neutron request.
155 OpenStackOperations.Delete SubNet @{SUBNETS_NAME}[0]
158 [Documentation] Delete Networks with neutron request.
159 : FOR ${NetworkElement} IN @{NETWORKS_NAME}
160 \ OpenStackOperations.Delete Network ${NetworkElement}
161 OpenStackOperations.Delete Network ${external_net_name}