2 Documentation Test suite to verify SFC configuration and packet flows.
3 Suite Setup Suite Setup
4 Suite Teardown OpenStackOperations.OpenStack Suite Teardown
5 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
6 Test Teardown BuiltIn.Run Keywords OpenStackOperations.Get Test Teardown Debugs
7 ... AND OpenStackOperations.Get Test Teardown Debugs For SFC
9 Library OperatingSystem
10 Library RequestsLibrary
11 Resource ../../../libraries/DevstackUtils.robot
12 Resource ../../../libraries/LiveMigration.robot
13 Resource ../../../libraries/OpenStackOperations.robot
14 Resource ../../../libraries/SetupUtils.robot
15 Resource ../../../libraries/Utils.robot
16 Resource ../../../libraries/KarafKeywords.robot
19 ${SECURITY_GROUP} sg-sfc
21 @{SUBNETS} l2_subnet_1
22 @{NET_1_VMS} sf1 sourcevm destvm
23 @{NON_SF_VMS} sourcevm destvm
24 @{SUBNET_CIDRS} 30.0.0.0/24
25 @{PORTS} p1in p1out source_vm_port dest_vm_port
26 ${CURL_COMMAND} curl -v --connect-timeout 25
27 ${HTTP_SUCCESS} 200 OK
28 ${HTTP_FAILURE} connect() timed out!
29 ${WEBSERVER_80} while true; do echo -e "HTTP/1.0 200 OK\r\nContent-Length: 21\r\n\r\nWelcome to web-server80" | sudo nc -l -p 80 ; done
30 ${WEBSERVER_81} while true; do echo -e "HTTP/1.0 200 OK\r\nContent-Length: 21\r\n\r\nWelcome to web-server81" | sudo nc -l -p 81 ; done
31 ${WEBSERVER_82} while true; do echo -e "HTTP/1.0 200 OK\r\nContent-Length: 21\r\n\r\nWelcome to web-server82" | sudo nc -l -p 82 ; done
32 ${CLOUD_IMAGE} "https://cloud-images.ubuntu.com/releases/18.04/release/ubuntu-18.04-server-cloudimg-amd64.img"
33 ${CLOUD_IMAGE_NAME} ubuntu
34 ${CLOUD_FLAVOR_NAME} ubuntu
35 ${CLOUD_USER_NAME} ubuntu
36 ${VXLAN_TOOL_URL} "https://git.opendaylight.org/gerrit/gitweb?p=sfc.git;a=blob_plain;f=sfc-test/nsh-tools/vxlan_tool.py;h=1445292405bc17516d03e4a448ac2e0f65d38e79;hb=HEAD"
37 @{NETVIRT_DIAG_SERVICES} OPENFLOW IFM ITM DATASTORE ELAN
40 Create Flow Classifiers For Basic Test
41 [Documentation] Create SFC Flow Classifier for TCP traffic between source VM and destination VM
42 OpenStackOperations.Create SFC Flow Classifier FC_80 @{NET1_VM_IPS}[0] @{NET1_VM_IPS}[1] tcp source_vm_port args=--destination-port 80:80
43 OpenStackOperations.Create SFC Flow Classifier FC_81 @{NET1_VM_IPS}[0] @{NET1_VM_IPS}[1] tcp source_vm_port args=--destination-port 81:81
46 [Documentation] Create SFC Port Pairs
47 OpenStackOperations.Create SFC Port Pair SFPP1 p1in p1out
49 Create Port Pair Groups
50 [Documentation] Create SFC Port Pair Groups
51 OpenStackOperations.Create SFC Port Pair Group SFPPG1 SFPP1
53 Test Communication From Vm Instance1 In net_1 No SF
54 [Documentation] Login to the source VM instance, and send a HTTP GET using curl to the destination VM instance, If the SF handles the traffic, there will be delay causing the time for curl to be higher.
55 ${DEST_VM_LIST} BuiltIn.Create List @{NET1_VM_IPS}[1]
56 ${curl_resp} OpenStackOperations.Execute Command on VM Instance @{NETWORKS}[0] @{NET1_VM_IPS}[0] ${CURL_COMMAND} http://@{NET1_VM_IPS}[1]
57 BuiltIn.Should Contain ${curl_resp} ${HTTP_SUCCESS}
58 ${curl_resp} OpenStackOperations.Execute Command on VM Instance @{NETWORKS}[0] @{NET1_VM_IPS}[0] ${CURL_COMMAND} http://@{NET1_VM_IPS}[1]:81
59 BuiltIn.Should Contain ${curl_resp} ${HTTP_SUCCESS}
60 [Teardown] BuiltIn.Run Keywords OpenStackOperations.Get Test Teardown Debugs
61 ... AND OpenStackOperations.Get Test Teardown Debugs For SFC
62 ... AND OpenStackOperations.Exit From Vm Console
64 Create Port Chain For Src->Dest Port 80
65 [Documentation] Create SFC Port Chain using port group and classifier created previously
66 OpenStackOperations.Create SFC Port Chain SFPC1 args=--port-pair-group SFPPG1 --flow-classifier FC_80
68 Test Communication From Vm Instance1 In net_1 Port 80 via SF
69 [Documentation] Login to the source VM instance, and send a HTTP GET using curl to the destination VM instance, If the SF handles the traffic, there will be delay causing the time for curl to be higher.
70 Start Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP} args=--do forward --interface ens2 --output ens3 --verbose off
71 Wait Until Keyword Succeeds 3x 10s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} http://@{NET1_VM_IPS}[1] ${HTTP_SUCCESS}
72 Wait Until Keyword Succeeds 3x 10s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} http://@{NET1_VM_IPS}[1]:81 ${HTTP_SUCCESS}
73 Stop Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP}
74 Start Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP} args=--do forward --interface ens2 --output ens3 --verbose off --block 80
75 BuiltIn.Comment Port 80 communication should fail as the SF blocks the same
76 Wait Until Keyword Succeeds 3x 10s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} http://@{NET1_VM_IPS}[1] ${HTTP_FAILURE}
77 BuiltIn.Comment Test to confirm Port 81 is not blocked
78 Wait Until Keyword Succeeds 3x 10s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} http://@{NET1_VM_IPS}[1]:81 ${HTTP_SUCCESS}
79 Stop Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP}
80 Start Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP} args=--do forward --interface ens2 --output ens3 --verbose off --block 81
81 Wait Until Keyword Succeeds 3x 10s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} http://@{NET1_VM_IPS}[1] ${HTTP_SUCCESS}
82 Wait Until Keyword Succeeds 3x 10s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} http://@{NET1_VM_IPS}[1]:81 ${HTTP_SUCCESS}
83 Stop Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP}
84 [Teardown] BuiltIn.Run Keywords OpenStackOperations.Get Test Teardown Debugs
85 ... AND OpenStackOperations.Get Test Teardown Debugs For SFC
86 ... AND OpenStackOperations.Exit From Vm Console
88 Update Port Chain To Use Flow Classifier For Port 81
89 [Documentation] Update Port Chain to use FC_82 and FC_83 instead of FC_80 and FC_81
90 OpenStackOperations.Update SFC Port Chain With A New Flow Classifier SFPC1 FC_81
91 OpenStackOperations.Update SFC Port Chain Removing A Flow Classifier SFPC1 FC_80
93 Test Communication From Vm Instance1 In net_1 Port 81 via SF
94 [Documentation] Login to the source VM instance, and send a HTTP GET using curl to the destination VM instance, If the SF handles the traffic, there will be delay causing the time for curl to be higher.
95 Stop Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP}
96 Start Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP} args=--do forward --interface ens2 --output ens3 --verbose off
97 Wait Until Keyword Succeeds 3x 10s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} http://@{NET1_VM_IPS}[1] ${HTTP_SUCCESS}
98 Wait Until Keyword Succeeds 3x 10s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} http://@{NET1_VM_IPS}[1]:81 ${HTTP_SUCCESS}
100 Stop Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP}
101 Start Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP} args=--do forward --interface ens2 --output ens3 --verbose off --block 81
102 Wait Until Keyword Succeeds 3x 10s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} http://@{NET1_VM_IPS}[1] ${HTTP_SUCCESS}
103 Wait Until Keyword Succeeds 3x 10s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} http://@{NET1_VM_IPS}[1]:81 ${HTTP_FAILURE}
105 BuiltIn.Comment Port 81 communication should fail as the SF blocks the same
106 BuiltIn.Comment Test to confirm Port 80 does not continue to get routed through SF
107 Stop Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP}
108 Start Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP} args=--do forward --interface ens2 --output ens3 --verbose off --block 80
109 Wait Until Keyword Succeeds 3x 10s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} http://@{NET1_VM_IPS}[1] ${HTTP_SUCCESS}
110 Wait Until Keyword Succeeds 3x 10s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} http://@{NET1_VM_IPS}[1]:81 ${HTTP_SUCCESS}
112 Stop Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP}
113 [Teardown] BuiltIn.Run Keywords OpenStackOperations.Get Test Teardown Debugs
114 ... AND OpenStackOperations.Get Test Teardown Debugs For SFC
115 ... AND OpenStackOperations.Exit From Vm Console
117 Delete And Recreate Port Chain And Flow Classifiers For Symmetric Test
118 OpenStackOperations.Create SFC Flow Classifier FC_SYM @{NET1_VM_IPS}[0] @{NET1_VM_IPS}[1] tcp source_vm_port args=--destination-port 82:82 --source-port 2000 --logical-destination-port dest_vm_port
119 OpenStackOperations.Delete SFC Port Chain SFPC1
120 OpenStackOperations.Create SFC Port Chain SFPSYM args=--port-pair-group SFPPG1 --flow-classifier FC_SYM --chain-parameters symmetric=true
122 Test Communication From Vm Instance1 For Symmetric Chain
123 [Documentation] Login to the source VM instance, and send a HTTP GET using curl to the destination VM instance, If the SF handles the traffic, there will be delay causing the time for curl to be higher.
124 Stop Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP}
125 Start Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP} args=--do forward --interface ens2 --output ens3 --verbose off
126 Start Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP} args=--do forward --interface ens3 --output ens2 --verbose off
127 Wait Until Keyword Succeeds 8x 20s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} --local-port 2000 -m 60 http://@{NET1_VM_IPS}[1]:82 ${HTTP_SUCCESS}
129 BuiltIn.Comment Test to confirm the SRC->DEST Port 82 is routed through SF
130 Stop Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP}
131 Start Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP} args=--do forward --interface ens2 --output ens3 --verbose off --block 82
132 Start Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP} args=--do forward --interface ens3 --output ens2 --verbose off
133 Wait Until Keyword Succeeds 8x 20s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} --local-port 2000 -m 60 http://@{NET1_VM_IPS}[1]:82 ${HTTP_FAILURE}
135 BuiltIn.Comment Test to confirm DEST->SRC Port 2000 path SFC traversal
136 Stop Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP}
137 Start Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP} args=--do forward --interface ens2 --output ens3 --verbose off
138 Start Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP} args=--do forward --interface ens3 --output ens2 --verbose off --block 2000
139 Wait Until Keyword Succeeds 8x 20s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} --local-port 2000 -m 60 http://@{NET1_VM_IPS}[1]:82 ${HTTP_FAILURE}
141 BuiltIn.Comment Test to confirm the Normalcy restored
142 Stop Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP}
143 Start Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP} args=--do forward --interface ens2 --output ens3 --verbose off
144 Start Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP} args=--do forward --interface ens3 --output ens2 --verbose off
145 Wait Until Keyword Succeeds 8x 20s Access Http And Check Status @{NETWORKS}[0] ${CURL_COMMAND} --local-port 2000 -m 60 http://@{NET1_VM_IPS}[1]:82 ${HTTP_SUCCESS}
147 Stop Vxlan Tool in SF @{NETWORKS}[0] ${SF1_IP}
148 [Teardown] BuiltIn.Run Keywords OpenStackOperations.Get Test Teardown Debugs
149 ... AND OpenStackOperations.Get Test Teardown Debugs For SFC
150 ... AND OpenStackOperations.Exit From Vm Console
152 Delete Configurations
153 [Documentation] Delete all elements that were created in the test case section. These are done
154 ... in a local keyword so this can be called as part of the Suite Teardown. When called as part
155 ... of the Suite Teardown, all steps will be attempted. This prevents robot framework from bailing
156 ... on the rest of a test case if one step intermittently has trouble and fails. The goal is to attempt
157 ... to leave the test environment as clean as possible upon completion of this suite.
158 : FOR ${vm} IN @{NET_1_VMS}
159 \ OpenStackOperations.Delete Vm Instance ${vm}
160 OpenStackOperations.Delete SFC Port Chain SFPSYM
161 OpenStackOperations.Delete SFC Port Pair Group SFPPG1
162 OpenStackOperations.Delete SFC Port Pair SFPP1
163 OpenStackOperations.Delete SFC Flow Classifier FC_80
164 OpenStackOperations.Delete SFC Flow Classifier FC_81
165 OpenStackOperations.Delete SFC Flow Classifier FC_SYM
166 : FOR ${port} IN @{PORTS}
167 \ OpenStackOperations.Delete Port ${port}
168 OpenStackOperations.Delete SubNet l2_subnet_1
169 : FOR ${network} IN @{NETWORKS}
170 \ OpenStackOperations.Delete Network ${network}
171 OpenStackOperations.Delete SecurityGroup ${SECURITY_GROUP}
175 OpenStackOperations.OpenStack Suite Setup
176 Create Basic Networks
177 Create Ports For Testing
178 Create Instances For Testing
179 Check Vm Instances Have Ip Address And Ready For Test
180 Start Applications on VM Instances For Test
182 Create Basic Networks
183 BuiltIn.Comment Create Network For Testing
184 OpenStackOperations.Create Network @{NETWORKS}[0]
185 BuiltIn.Comment Create Subnet For Testing
186 OpenStackOperations.Create SubNet @{NETWORKS}[0] @{SUBNETS}[0] @{SUBNET_CIDRS}[0]
187 OpenStackOperations.Create Allow All SecurityGroup ${SECURITY_GROUP}
188 BuiltIn.Comment Create Neutron Ports with no port security for SFC Tests
189 OpenStackOperations.Get Suite Debugs
191 Create Ports For Testing
192 : FOR ${port} IN @{PORTS}
193 \ OpenStackOperations.Create Port @{NETWORKS}[0] ${port} sg=${SECURITY_GROUP}
194 OpenStackOperations.Update Port p1in additional_args=--no-security-group
195 OpenStackOperations.Update Port p1in additional_args=--disable-port-security
196 OpenStackOperations.Update Port p1out additional_args=--no-security-group
197 OpenStackOperations.Update Port p1out additional_args=--disable-port-security
198 CompareStream.Run_Keyword_If_Equals oxygen OpenStackOperations.Update Port source_vm_port additional_args=--no-security-group
199 CompareStream.Run_Keyword_If_Equals oxygen OpenStackOperations.Update Port source_vm_port additional_args=--disable-port-security
200 CompareStream.Run_Keyword_If_Equals oxygen OpenStackOperations.Update Port dest_vm_port additional_args=--no-security-group
201 CompareStream.Run_Keyword_If_Equals oxygen OpenStackOperations.Update Port dest_vm_port additional_args=--disable-port-security
202 OpenStackOperations.Get Suite Debugs
204 Create Instances For Testing
205 ${SF_COMP_HOST} = BuiltIn.Set Variable If 2 < ${NUM_OS_SYSTEM} ${OS_CMP2_HOSTNAME} ${OS_CMP1_HOSTNAME}
206 BuiltIn.Comment Create one ubuntu instance and two cirros instances
207 OpenStackOperations.Add New Image From Url ${CLOUD_IMAGE} ${CLOUD_IMAGE_NAME}
208 OpenStackOperations.Create Flavor ${CLOUD_FLAVOR_NAME} 2048 4
209 OpenStackOperations.Generate And Add Keypair sfctest odlsfctest
210 OpenStackOperations.Create Vm Instance With Ports And Key On Compute Node p1in p1out sf1 ${SF_COMP_HOST} image=${CLOUD_IMAGE_NAME} flavor=${CLOUD_FLAVOR_NAME}
211 ... sg=${SECURITY_GROUP} keyname=sfctest
212 OpenStackOperations.Create Vm Instance With Port On Compute Node source_vm_port sourcevm ${OS_CMP1_HOSTNAME} sg=${SECURITY_GROUP} flavor=cirros256
213 OpenStackOperations.Create Vm Instance With Port On Compute Node dest_vm_port destvm ${OS_CMP1_HOSTNAME} sg=${SECURITY_GROUP} flavor=cirros256
214 OpenStackOperations.Show Debugs @{NET_1_VMS}
215 OpenStackOperations.Get Suite Debugs
217 Check Vm Instances Have Ip Address And Ready For Test
218 OpenStackOperations.Poll VM Is ACTIVE sf1
219 OpenStackOperations.Poll VM Is ACTIVE sourcevm
220 OpenStackOperations.Poll VM Is ACTIVE destvm
221 ${sfc1_mac} OpenStackOperations.Get Port Mac p1in
222 ${SF1_IP} OpenStackOperations.Get Port Ip p1in
223 BuiltIn.Wait Until Keyword Succeeds 500s 60s OpenStackOperations.Verify If Instance Is Arpingable From Dhcp Namespace @{NETWORKS}[0] ${sfc1_mac} ${SF1_IP}
224 ${src_mac} OpenStackOperations.Get Port Mac source_vm_port
225 ${src_ip} OpenStackOperations.Get Port Ip source_vm_port
226 BuiltIn.Wait Until Keyword Succeeds 500s 60s OpenStackOperations.Verify If Instance Is Arpingable From Dhcp Namespace @{NETWORKS}[0] ${src_mac} ${src_ip}
227 ${dest_mac} OpenStackOperations.Get Port Mac dest_vm_port
228 ${dest_ip} OpenStackOperations.Get Port Ip dest_vm_port
229 BuiltIn.Wait Until Keyword Succeeds 500s 60s OpenStackOperations.Verify If Instance Is Arpingable From Dhcp Namespace @{NETWORKS}[0] ${dest_mac} ${dest_ip}
230 BuiltIn.Comment If the Tests reach this point, all the Instances are reachable.
231 ${NET1_VM_IPS} BuiltIn.Create List ${src_ip} ${dest_ip}
232 BuiltIn.Set Suite Variable @{NET1_VM_IPS}
233 BuiltIn.Set Suite Variable ${SF1_IP}
234 BuiltIn.Wait Until Keyword Succeeds 300s 60s OpenStackOperations.Check If Instance Is Ready For Ssh Login Using PublicKey @{NETWORKS}[0] ${SF1_IP} user=ubuntu
235 ... idfile=/tmp/odlsfctest
236 BuiltIn.Wait Until Keyword Succeeds 300s 60s OpenStackOperations.Check If Instance Is Ready For Ssh Login Using Password @{NETWORKS}[0] @{NET1_VM_IPS}[0]
237 BuiltIn.Wait Until Keyword Succeeds 300s 60s OpenStackOperations.Check If Instance Is Ready For Ssh Login Using Password @{NETWORKS}[0] @{NET1_VM_IPS}[1]
238 OpenStackOperations.Show Debugs @{NET_1_VMS}
239 OpenStackOperations.Get Suite Debugs
241 Start Applications on VM Instances For Test
242 BuiltIn.Comment Run Web server Scripts on destination vm listening to 80,81 and 82 ports
243 OpenStackOperations.Execute Command on VM Instance @{NETWORKS}[0] @{NET1_VM_IPS}[1] ${WEBSERVER_80} &
244 OpenStackOperations.Execute Command on VM Instance @{NETWORKS}[0] @{NET1_VM_IPS}[1] ${WEBSERVER_81} &
245 OpenStackOperations.Execute Command on VM Instance @{NETWORKS}[0] @{NET1_VM_IPS}[1] ${WEBSERVER_82} &
246 BuiltIn.Comment Get vxlan_tool script
247 Utils.Download File On Openstack Node ${OS_CNTL_CONN_ID} vxlan_tool.py ${VXLAN_TOOL_URL}
248 BuiltIn.Comment Copy vxlan_tool script to SFC VM
249 OpenStackOperations.Copy File To VM Instance With PublicKey Auth @{NETWORKS}[0] ${SF1_IP} /tmp/vxlan_tool.py user=${CLOUD_USER_NAME} idfile=/tmp/odlsfctest
250 BuiltIn.Comment Bring up the second Interface for egress
251 Execute Command on VM Instance with PublicKey Auth @{NETWORKS}[0] ${SF1_IP} sudo ifconfig ens3 up user=${CLOUD_USER_NAME} idfile=/tmp/odlsfctest
253 Start Vxlan Tool in SF
254 [Arguments] ${network} ${sf_vm_ip} ${args}=${EMPTY}
255 [Documentation] Starts the tool in the SF VM's
256 Execute Command on VM Instance with PublicKey Auth ${network} ${sf_vm_ip} nohup sudo python3 /tmp/vxlan_tool.py ${args} & user=ubuntu idfile=/tmp/odlsfctest
258 Stop Vxlan Tool in SF
259 [Arguments] ${network} ${sf_vm_ip}
260 [Documentation] Starts the tool in the SF VM's
261 Execute Command on VM Instance With PublicKey Auth ${network} ${sf_vm_ip} sudo pkill python3 user=ubuntu idfile=/tmp/odlsfctest
263 Access Http And Check Status
264 [Arguments] ${vm_ip} ${curl_command} ${ret_code} ${cmd_timeout}=30s
265 ${curl_resp} OpenStackOperations.Execute Command on VM Instance @{NETWORKS}[0] @{NET1_VM_IPS}[0] ${curl_command} cmd_timeout=${cmd_timeout}
266 BuiltIn.Should Contain ${curl_resp} ${ret_code}