Use function for Is Vm Active
[integration/test.git] / csit / suites / openstack / extensions / sfc.robot
index 8f9fd9ff782893f8977ac6a1ead7e028ff2797fd..27eb9d5f729d7e99714e46d01c8db4ce037b2b92 100644 (file)
@@ -15,6 +15,7 @@ Resource          ../../../libraries/Utils.robot
 Resource          ../../../libraries/KarafKeywords.robot
 
 *** Variables ***
+${SECURITY_GROUP}    sg-sfc
 @{NETWORKS_NAME}    network_1
 @{SUBNETS_NAME}    l2_subnet_1
 @{VM_INSTANCES}    sf1    sf2    sf3    source_vm    dest_vm
@@ -32,27 +33,21 @@ Create Subnets For network_1
     Create SubNet    @{NETWORKS_NAME}[0]    @{SUBNETS_NAME}[0]    @{SUBNETS_RANGE}[0]
 
 Add Allow All Rules
-    [Documentation]    Allow all packets for this suite
-    Neutron Security Group Create    sg-sfc
-    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
-    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
-    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
-    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
-    Neutron Security Group Rule Create    sg-sfc    direction=ingress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
-    Neutron Security Group Rule Create    sg-sfc    direction=egress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
+    [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
+    OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
 
 Create Neutron Ports
     [Documentation]    Precreate neutron ports to be used for SFC VMs
     : FOR    ${port}    IN    @{PORTS}
-    \    Create Port    @{NETWORKS_NAME}[0]    ${port}    sg=sg-sfc
+    \    Create Port    @{NETWORKS_NAME}[0]    ${port}    sg=${SECURITY_GROUP}
 
 Create Vm Instances
     [Documentation]    Create Four Vm instances using flavor and image names for a network.
-    Create Vm Instance With Ports    p1in    p1out    sf1    sg=sg-sfc
-    Create Vm Instance With Ports    p2in    p2out    sf2    sg=sg-sfc
-    Create Vm Instance With Ports    p3in    p3out    sf3    sg=sg-sfc
-    Create Vm Instance With Port    source_vm_port    source_vm    sg=sg-sfc
-    Create Vm Instance With Port    dest_vm_port    dest_vm    sg=sg-sfc
+    Create Vm Instance With Ports    p1in    p1out    sf1    sg=${SECURITY_GROUP}
+    Create Vm Instance With Ports    p2in    p2out    sf2    sg=${SECURITY_GROUP}
+    Create Vm Instance With Ports    p3in    p3out    sf3    sg=${SECURITY_GROUP}
+    Create Vm Instance With Port    source_vm_port    source_vm    sg=${SECURITY_GROUP}
+    Create Vm Instance With Port    dest_vm_port    dest_vm    sg=${SECURITY_GROUP}
 
 Check Vm Instances Have Ip Address
     [Documentation]    Test case to verify that all created VMs are ready and have received their ip addresses.
@@ -61,7 +56,7 @@ Check Vm Instances Have Ip Address
     # first, ensure all VMs are in ACTIVE state.    if not, we can just fail the test case and not waste time polling
     # for dhcp addresses
     : FOR    ${vm}    IN    @{VM_INSTANCES}
-    \    Wait Until Keyword Succeeds    15s    5s    Verify VM Is ACTIVE    ${vm}
+    \    Poll VM Is ACTIVE    ${vm}
     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
     ...    true    @{VM_INSTANCES}
     ${NET1_VM_IPS}    ${NET1_DHCP_IP}    Collect VM IP Addresses    false    @{VM_INSTANCES}
@@ -98,7 +93,7 @@ Create Port Chain
 
 Start Web Server On Destination VM
     [Documentation]    Start a simple web server on the destination VM
-    Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[4]    while true; do echo -e "HTTP/1.0 200 OK\r\n\r\nWelcome to $(hostname)" | sudo nc -l -p 80 ; done&
+    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 &
 
 Add Static Routing On Service Function VMs
     [Documentation]    Enable eth1 and add static routing between the ports on the SF VMs
@@ -132,6 +127,11 @@ Delete All SFC Objects
     Delete SFC Port Pair    PP3
     Delete SFC Flow Classifier    FC_http
 
+Delete Neutron Ports
+    [Documentation]    Delete neutron ports that were used for SFC VMs
+    : FOR    ${port}    IN    @{PORTS}
+    \    Delete Port    ${port}
+
 Delete Sub Networks In network_1
     [Documentation]    Delete Sub Nets for the Networks with neutron request.
     Delete SubNet    l2_subnet_1