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 Close All Connections
6 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
7 Test Teardown Get Test Teardown Debugs
9 Library OperatingSystem
10 Library RequestsLibrary
11 Resource ../../../libraries/DevstackUtils.robot
12 Resource ../../../libraries/OpenStackOperations.robot
13 Resource ../../../libraries/SetupUtils.robot
14 Resource ../../../libraries/Utils.robot
15 Resource ../../../libraries/KarafKeywords.robot
18 @{NETWORKS_NAME} network_1
19 @{SUBNETS_NAME} l2_subnet_1
20 @{VM_INSTANCES} sf1 sf2 sf3 source_vm dest_vm
21 @{SUBNETS_RANGE} 30.0.0.0/24
22 @{PORTS} p1in p1out p2in p2out p3in p3out source_vm_port
26 Create VXLAN Network (network_1)
27 [Documentation] Create Network with neutron request.
28 Create Network @{NETWORKS_NAME}[0]
30 Create Subnets For network_1
31 [Documentation] Create Sub Nets for the Networks with neutron request.
32 Create SubNet @{NETWORKS_NAME}[0] @{SUBNETS_NAME}[0] @{SUBNETS_RANGE}[0]
35 [Documentation] Allow all packets for this suite
36 Neutron Security Group Create sg-sfc
37 Neutron Security Group Rule Create sg-sfc direction=ingress port_range_max=65535 port_range_min=1 protocol=tcp remote_ip_prefix=0.0.0.0/0
38 Neutron Security Group Rule Create sg-sfc direction=egress port_range_max=65535 port_range_min=1 protocol=tcp remote_ip_prefix=0.0.0.0/0
39 Neutron Security Group Rule Create sg-sfc direction=ingress port_range_max=65535 port_range_min=1 protocol=udp remote_ip_prefix=0.0.0.0/0
40 Neutron Security Group Rule Create sg-sfc direction=egress port_range_max=65535 port_range_min=1 protocol=udp remote_ip_prefix=0.0.0.0/0
41 Neutron Security Group Rule Create sg-sfc direction=ingress protocol=icmp remote_ip_prefix=0.0.0.0/0
42 Neutron Security Group Rule Create sg-sfc direction=egress protocol=icmp remote_ip_prefix=0.0.0.0/0
45 [Documentation] Precreate neutron ports to be used for SFC VMs
46 : FOR ${port} IN @{PORTS}
47 \ Create Port @{NETWORKS_NAME}[0] ${port} sg=sg-sfc
50 [Documentation] Create Four Vm instances using flavor and image names for a network.
51 Create Vm Instance With Ports p1in p1out sf1 sg=sg-sfc
52 Create Vm Instance With Ports p2in p2out sf2 sg=sg-sfc
53 Create Vm Instance With Ports p3in p3out sf3 sg=sg-sfc
54 Create Vm Instance With Port source_vm_port source_vm sg=sg-sfc
55 Create Vm Instance With Port dest_vm_port dest_vm sg=sg-sfc
57 Check Vm Instances Have Ip Address
58 [Documentation] Test case to verify that all created VMs are ready and have received their ip addresses.
59 ... We are polling first and longest on the last VM created assuming that if it's received it's address
60 ... already the other instances should have theirs already or at least shortly thereafter.
61 # first, ensure all VMs are in ACTIVE state. if not, we can just fail the test case and not waste time polling
63 : FOR ${vm} IN @{VM_INSTANCES}
64 \ Wait Until Keyword Succeeds 15s 5s Verify VM Is ACTIVE ${vm}
65 ${status} ${message} Run Keyword And Ignore Error Wait Until Keyword Succeeds 60s 5s Collect VM IP Addresses
66 ... true @{VM_INSTANCES}
67 ${NET1_VM_IPS} ${NET1_DHCP_IP} Collect VM IP Addresses false @{VM_INSTANCES}
68 ${VM_INSTANCES}= Collections.Combine Lists ${VM_INSTANCES}
69 ${VM_IPS}= Collections.Combine Lists ${NET1_VM_IPS}
70 ${LOOP_COUNT} Get Length ${VM_INSTANCES}
71 : FOR ${index} IN RANGE 0 ${LOOP_COUNT}
72 \ ${status} ${message} Run Keyword And Ignore Error Should Not Contain @{VM_IPS}[${index}] None
73 \ Run Keyword If '${status}' == 'FAIL' Write Commands Until Prompt nova console-log @{VM_INSTANCES}[${index}] 30s
74 Set Suite Variable ${NET1_VM_IPS}
75 Should Not Contain ${NET1_VM_IPS} None
76 Should Not Contain ${NET1_DHCP_IP} None
77 [Teardown] Run Keywords Show Debugs @{VM_INSTANCES}
78 ... AND Get Test Teardown Debugs
80 Create Flow Classifiers
81 [Documentation] Create SFC Flow Classifier for TCP traffic between source VM and destination VM
82 Create SFC Flow Classifier FC_http @{NET1_VM_IPS}[3] @{NET1_VM_IPS}[4] tcp 80 source_vm_port
85 [Documentation] Create SFC Port Pairs
86 Create SFC Port Pair PP1 p1in p1out
87 Create SFC Port Pair PP2 p2in p2out
88 Create SFC Port Pair PP3 p3in p3out
90 Create Port Pair Groups
91 [Documentation] Create SFC Port Pair Groups
92 Create SFC Port Pair Group With Two Pairs PG1 PP1 PP2
93 Create SFC Port Pair Group PG2 PP3
96 [Documentation] Create SFC Port Chain using two port groups an classifier created previously
97 Create SFC Port Chain PC1 PG1 PG2 FC_http
99 Start Web Server On Destination VM
100 [Documentation] Start a simple web server on the destination VM
101 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 &
103 Add Static Routing On Service Function VMs
104 [Documentation] Enable eth1 and add static routing between the ports on the SF VMs
105 : FOR ${INDEX} IN RANGE 0 2
106 \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo sh -c 'echo "auto eth1" >> /etc/network/interfaces'
107 \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo sh -c 'echo "iface eth1 inet dhcp" >> /etc/network/interfaces'
108 \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo /etc/init.d/S40network restart
109 \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
110 \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo ip route add @{NET1_VM_IPS}[3] dev eth0
111 \ Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[${INDEX}] sudo ip route add @{NET1_VM_IPS}[4] dev eth1
113 Connectivity Tests From Vm Instance1 In network_1
114 [Documentation] Login to the source VM instance, and send a HTTP GET using curl to the destination VM instance
115 # FIXME need to somehow verify it goes through SFs (flows?)
116 ${DEST_VM_LIST} Create List @{NET1_VM_IPS}[4]
117 Test Operations From Vm Instance network_1 @{NET1_VM_IPS}[3] ${DEST_VM_LIST}
118 Execute Command on VM Instance @{NETWORKS_NAME}[0] @{NET1_VM_IPS}[3] curl http://@{NET1_VM_IPS}[4]
120 Delete Vm Instances In network_1
121 [Documentation] Delete Vm instances using instance names in network_1.
122 : FOR ${VmElement} IN @{VM_INSTANCES}
123 \ Delete Vm Instance ${VmElement}
125 Delete All SFC Objects
126 [Documentation] Delete all previously created SFC objects
127 Delete SFC Port Chain PC1
128 Delete SFC Port Pair Group PG1
129 Delete SFC Port Pair Group PG2
130 Delete SFC Port Pair PP1
131 Delete SFC Port Pair PP2
132 Delete SFC Port Pair PP3
133 Delete SFC Flow Classifier FC_http
136 [Documentation] Delete neutron ports that were used for SFC VMs
137 : FOR ${port} IN @{PORTS}
138 \ Delete Port ${port}
140 Delete Sub Networks In network_1
141 [Documentation] Delete Sub Nets for the Networks with neutron request.
142 Delete SubNet l2_subnet_1
145 [Documentation] Delete Networks with neutron request.
146 : FOR ${NetworkElement} IN @{NETWORKS_NAME}
147 \ Delete Network ${NetworkElement}