Add missing create sg in ha l3
[integration/test.git] / csit / suites / openstack / extensions / sfc.robot
index 27eb9d5f729d7e99714e46d01c8db4ce037b2b92..1c7c4f3a5820695aa88fa9afa7f192692a6aec21 100644 (file)
@@ -2,9 +2,11 @@
 Documentation     Test suite to verify SFC configuration and packet flows.
 Suite Setup       BuiltIn.Run Keywords    SetupUtils.Setup_Utils_For_Setup_And_Teardown
 ...               AND    DevstackUtils.Devstack Suite Setup
 Documentation     Test suite to verify SFC configuration and packet flows.
 Suite Setup       BuiltIn.Run Keywords    SetupUtils.Setup_Utils_For_Setup_And_Teardown
 ...               AND    DevstackUtils.Devstack Suite Setup
-Suite Teardown    Close All Connections
+Suite Teardown    BuiltIn.Run Keywords    Delete Configurations
+...               AND    Close All Connections
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
-Test Teardown     Get Test Teardown Debugs
+Test Teardown     BuiltIn.Run Keywords    OpenStackOperations.Get Test Teardown Debugs
+...               AND    OpenStackOperations.Get Test Teardown Debugs For SFC
 Library           SSHLibrary
 Library           OperatingSystem
 Library           RequestsLibrary
 Library           SSHLibrary
 Library           OperatingSystem
 Library           RequestsLibrary
@@ -50,27 +52,12 @@ Create Vm Instances
     Create Vm Instance With Port    dest_vm_port    dest_vm    sg=${SECURITY_GROUP}
 
 Check Vm Instances Have Ip Address
     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.
-    ...    We are polling first and longest on the last VM created assuming that if it's received it's address
-    ...    already the other instances should have theirs already or at least shortly thereafter.
-    # 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}
-    \    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}
-    ${VM_INSTANCES}=    Collections.Combine Lists    ${VM_INSTANCES}
-    ${VM_IPS}=    Collections.Combine Lists    ${NET1_VM_IPS}
-    ${LOOP_COUNT}    Get Length    ${VM_INSTANCES}
-    : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
-    \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
-    \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    nova console-log @{VM_INSTANCES}[${index}]    30s
-    Set Suite Variable    ${NET1_VM_IPS}
-    Should Not Contain    ${NET1_VM_IPS}    None
-    Should Not Contain    ${NET1_DHCP_IP}    None
-    [Teardown]    Run Keywords    Show Debugs    @{VM_INSTANCES}
-    ...    AND    Get Test Teardown Debugs
+    @{NET1_VM_IPS}    ${NET1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{VM_INSTANCES}
+    BuiltIn.Set Suite Variable    @{NET1_VM_IPS}
+    BuiltIn.Should Not Contain    ${NET1_VM_IPS}    None
+    BuiltIn.Should Not Contain    ${NET1_DHCP_IP}    None
+    [Teardown]    BuiltIn.Run Keywords    OpenStackOperations.Show Debugs    @{VM_INSTANCES}
+    ...    AND    OpenStackOperations.Get Test Teardown Debugs
 
 Create Flow Classifiers
     [Documentation]    Create SFC Flow Classifier for TCP traffic between source VM and destination VM
 
 Create Flow Classifiers
     [Documentation]    Create SFC Flow Classifier for TCP traffic between source VM and destination VM
@@ -93,32 +80,34 @@ Create Port Chain
 
 Start Web Server On Destination VM
     [Documentation]    Start a simple web server on the destination VM
 
 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\nContent-Length: 21\r\n\r\nWelcome to web-server" | sudo nc -l -p 80 ; done &
+    OpenStackOperations.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
     : FOR    ${INDEX}    IN RANGE    0    2
 
 Add Static Routing On Service Function VMs
     [Documentation]    Enable eth1 and add static routing between the ports on the SF VMs
     : FOR    ${INDEX}    IN RANGE    0    2
-    \    Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo sh -c 'echo "auto eth1" >> /etc/network/interfaces'
-    \    Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo sh -c 'echo "iface eth1 inet dhcp" >> /etc/network/interfaces'
-    \    Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo /etc/init.d/S40network restart
-    \    Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
-    \    Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo ip route add @{NET1_VM_IPS}[3] dev eth0
-    \    Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo ip route add @{NET1_VM_IPS}[4] dev eth1
+    \    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo sh -c 'echo "auto eth1" >> /etc/network/interfaces'
+    \    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo sh -c 'echo "iface eth1 inet dhcp" >> /etc/network/interfaces'
+    \    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo /etc/init.d/S40network restart
+    \    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
+    \    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo ip route add @{NET1_VM_IPS}[3] dev eth0
+    \    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[${INDEX}]    sudo ip route add @{NET1_VM_IPS}[4] dev eth1
 
 Connectivity Tests From Vm Instance1 In network_1
     [Documentation]    Login to the source VM instance, and send a HTTP GET using curl to the destination VM instance
     # FIXME need to somehow verify it goes through SFs (flows?)
 
 Connectivity Tests From Vm Instance1 In network_1
     [Documentation]    Login to the source VM instance, and send a HTTP GET using curl to the destination VM instance
     # FIXME need to somehow verify it goes through SFs (flows?)
-    ${DEST_VM_LIST}    Create List    @{NET1_VM_IPS}[4]
+    ${DEST_VM_LIST}    BuiltIn.Create List    @{NET1_VM_IPS}[4]
     Test Operations From Vm Instance    network_1    @{NET1_VM_IPS}[3]    ${DEST_VM_LIST}
     Test Operations From Vm Instance    network_1    @{NET1_VM_IPS}[3]    ${DEST_VM_LIST}
-    Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[3]    curl http://@{NET1_VM_IPS}[4]
-
-Delete Vm Instances In network_1
-    [Documentation]    Delete Vm instances using instance names in network_1.
+    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS_NAME}[0]    @{NET1_VM_IPS}[3]    curl http://@{NET1_VM_IPS}[4]
+
+*** Keywords ***
+Delete Configurations
+    [Documentation]    Delete all elements that were created in the test case section. These are done
+    ...    in a local keyword so this can be called as part of the Suite Teardown. When called as part
+    ...    of the Suite Teardown, all steps will be attempted. This prevents robot framework from bailing
+    ...    on the rest of a test case if one step intermittently has trouble and fails. The goal is to attempt
+    ...    to leave the test environment as clean as possible upon completion of this suite.
     : FOR    ${VmElement}    IN    @{VM_INSTANCES}
     \    Delete Vm Instance    ${VmElement}
     : FOR    ${VmElement}    IN    @{VM_INSTANCES}
     \    Delete Vm Instance    ${VmElement}
-
-Delete All SFC Objects
-    [Documentation]    Delete all previously created SFC objects
     Delete SFC Port Chain    PC1
     Delete SFC Port Pair Group    PG1
     Delete SFC Port Pair Group    PG2
     Delete SFC Port Chain    PC1
     Delete SFC Port Pair Group    PG1
     Delete SFC Port Pair Group    PG2
@@ -126,17 +115,9 @@ Delete All SFC Objects
     Delete SFC Port Pair    PP2
     Delete SFC Port Pair    PP3
     Delete SFC Flow Classifier    FC_http
     Delete SFC Port Pair    PP2
     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}
     : 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
     Delete SubNet    l2_subnet_1
-
-Delete Networks
-    [Documentation]    Delete Networks with neutron request.
     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
     \    Delete Network    ${NetworkElement}
     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
     \    Delete Network    ${NetworkElement}
+    Delete SecurityGroup    ${SECURITY_GROUP}