2 Documentation Test suite to verify SFC configuration and packet flows.
3 Suite Setup BuiltIn.Run Keywords SetupUtils.Setup_Utils_For_Setup_And_Teardown
4 ... AND DevstackUtils.Devstack Suite Setup
5 Suite Teardown BuiltIn.Run Keywords Delete Configurations
6 ... AND Close All Connections
7 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
8 Test Teardown Get Test Teardown Debugs
9 ... AND Get Test Teardown Debugs For SFC
11 Library OperatingSystem
12 Library RequestsLibrary
13 Resource ../../../libraries/DevstackUtils.robot
14 Resource ../../../libraries/OpenStackOperations.robot
15 Resource ../../../libraries/SetupUtils.robot
16 Resource ../../../libraries/Utils.robot
17 Resource ../../../libraries/KarafKeywords.robot
20 ${SECURITY_GROUP} sg-sfc
21 @{NETWORKS_NAME} network_1
22 @{SUBNETS_NAME} l2_subnet_1
23 @{VM_INSTANCES} sf1 sf2 sf3 source_vm dest_vm
24 @{SUBNETS_RANGE} 30.0.0.0/24
25 @{PORTS} p1in p1out p2in p2out p3in p3out source_vm_port
29 Create VXLAN Network (network_1)
30 [Documentation] Create Network with neutron request.
31 Create Network @{NETWORKS_NAME}[0]
33 Create Subnets For network_1
34 [Documentation] Create Sub Nets for the Networks with neutron request.
35 Create SubNet @{NETWORKS_NAME}[0] @{SUBNETS_NAME}[0] @{SUBNETS_RANGE}[0]
38 [Documentation] Allow all TCP/UDP/ICMP packets for this suite
39 OpenStackOperations.Create Allow All SecurityGroup ${SECURITY_GROUP}
42 [Documentation] Precreate neutron ports to be used for SFC VMs
43 : FOR ${port} IN @{PORTS}
44 \ Create Port @{NETWORKS_NAME}[0] ${port} sg=${SECURITY_GROUP}
47 [Documentation] Create Four Vm instances using flavor and image names for a network.
48 Create Vm Instance With Ports p1in p1out sf1 sg=${SECURITY_GROUP}
49 Create Vm Instance With Ports p2in p2out sf2 sg=${SECURITY_GROUP}
50 Create Vm Instance With Ports p3in p3out sf3 sg=${SECURITY_GROUP}
51 Create Vm Instance With Port source_vm_port source_vm sg=${SECURITY_GROUP}
52 Create Vm Instance With Port dest_vm_port dest_vm sg=${SECURITY_GROUP}
54 Check Vm Instances Have Ip Address
55 [Documentation] Test case to verify that all created VMs are ready and have received their ip addresses.
56 ... We are polling first and longest on the last VM created assuming that if it's received it's address
57 ... already the other instances should have theirs already or at least shortly thereafter.
58 # first, ensure all VMs are in ACTIVE state. if not, we can just fail the test case and not waste time polling
60 : FOR ${vm} IN @{VM_INSTANCES}
61 \ Poll VM Is ACTIVE ${vm}
62 ${status} ${message} Run Keyword And Ignore Error Wait Until Keyword Succeeds 60s 15s Collect VM IP Addresses
63 ... true @{VM_INSTANCES}
64 ${NET1_VM_IPS} ${NET1_DHCP_IP} Collect VM IP Addresses false @{VM_INSTANCES}
65 ${VM_INSTANCES}= Collections.Combine Lists ${VM_INSTANCES}
66 ${VM_IPS}= Collections.Combine Lists ${NET1_VM_IPS}
67 ${LOOP_COUNT} Get Length ${VM_INSTANCES}
68 : FOR ${index} IN RANGE 0 ${LOOP_COUNT}
69 \ ${status} ${message} Run Keyword And Ignore Error Should Not Contain @{VM_IPS}[${index}] None
70 \ Run Keyword If '${status}' == 'FAIL' Write Commands Until Prompt openstack console log show @{VM_INSTANCES}[${index}] 30s
71 Set Suite Variable ${NET1_VM_IPS}
72 Should Not Contain ${NET1_VM_IPS} None
73 Should Not Contain ${NET1_DHCP_IP} None
74 [Teardown] Run Keywords Show Debugs @{VM_INSTANCES}
75 ... AND Get Test Teardown Debugs
77 Create Flow Classifiers
78 [Documentation] Create SFC Flow Classifier for TCP traffic between source VM and destination VM
79 Create SFC Flow Classifier FC_http @{NET1_VM_IPS}[3] @{NET1_VM_IPS}[4] tcp 80 source_vm_port
82 [Documentation] Create SFC Port Pairs
83 Create SFC Port Pair PP1 p1in p1out
84 Create SFC Port Pair PP2 p2in p2out
85 Create SFC Port Pair PP3 p3in p3out
87 Create Port Pair Groups
88 [Documentation] Create SFC Port Pair Groups
89 Create SFC Port Pair Group With Two Pairs PG1 PP1 PP2
90 Create SFC Port Pair Group PG2 PP3
93 [Documentation] Create SFC Port Chain using two port groups an classifier created previously
94 Create SFC Port Chain PC1 PG1 PG2 FC_http
96 Start Web Server On Destination VM
97 [Documentation] Start a simple web server on the destination VM
98 Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[4] while true; do echo -e "HTTP/1.0 200 OK\r\nContent-Length: 21\r\n\r\nWelcome to web-server" | sudo nc -l -p 80 ; done &
100 Add Static Routing On Service Function VMs
101 [Documentation] Enable eth1 and add static routing between the ports on the SF VMs
102 : FOR ${INDEX} IN RANGE 0 2
103 \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo sh -c 'echo "auto eth1" >> /etc/network/interfaces'
104 \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo sh -c 'echo "iface eth1 inet dhcp" >> /etc/network/interfaces'
105 \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo /etc/init.d/S40network restart
106 \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
107 \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo ip route add @{NET1_VM_IPS}[3] dev eth0
108 \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo ip route add @{NET1_VM_IPS}[4] dev eth1
110 Connectivity Tests From Vm Instance1 In network_1
111 [Documentation] Login to the source VM instance, and send a HTTP GET using curl to the destination VM instance
112 # FIXME need to somehow verify it goes through SFs (flows?)
113 ${DEST_VM_LIST} Create List @{NET1_VM_IPS}[4]
114 Test Operations From Vm Instance network_1 @{NET1_VM_IPS}[3] ${DEST_VM_LIST}
115 Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[3] curl http://@{NET1_VM_IPS}[4]
118 Delete Configurations
119 [Documentation] Delete all elements that were created in the test case section. These are done
120 ... in a local keyword so this can be called as part of the Suite Teardown. When called as part
121 ... of the Suite Teardown, all steps will be attempted. This prevents robot framework from bailing
122 ... on the rest of a test case if one step intermittently has trouble and fails. The goal is to attempt
123 ... to leave the test environment as clean as possible upon completion of this suite.
124 : FOR ${VmElement} IN @{VM_INSTANCES}
125 \ Delete Vm Instance ${VmElement}
126 Delete SFC Port Chain PC1
127 Delete SFC Port Pair Group PG1
128 Delete SFC Port Pair Group PG2
129 Delete SFC Port Pair PP1
130 Delete SFC Port Pair PP2
131 Delete SFC Port Pair PP3
132 Delete SFC Flow Classifier FC_http
133 : FOR ${port} IN @{PORTS}
134 \ Delete Port ${port}
135 Delete SubNet l2_subnet_1
136 : FOR ${NetworkElement} IN @{NETWORKS_NAME}
137 \ Delete Network ${NetworkElement}