Add OpenStack grenade 85/66185/16
authorSam Hague <shague@redhat.com>
Sun, 3 Dec 2017 23:33:39 +0000 (18:33 -0500)
committerJamo Luhrsen <jluhrsen@redhat.com>
Fri, 8 Dec 2017 05:44:04 +0000 (05:44 +0000)
Change-Id: I19d64b38dacd99c2b98a60260a5a4ba102b6255a
Signed-off-by: Sam Hague <shague@redhat.com>
Signed-off-by: Jamo Luhrsen <jluhrsen@redhat.com>
12 files changed:
csit/libraries/DevstackUtils.robot
csit/libraries/OpenStackOperations.robot
csit/suites/netvirt/elan/elan.robot
csit/suites/netvirt/vpnservice/vpn_basic.robot
csit/suites/netvirt/vpnservice/vpn_basic_ipv6.robot
csit/suites/openstack/connectivity/external_network.robot
csit/suites/openstack/connectivity/l2.robot
csit/suites/openstack/connectivity/l3.robot
csit/suites/openstack/connectivity/security_group.robot
csit/suites/openstack/extensions/sfc.robot
csit/suites/openstack/securitygroup/neutron_security_group.robot
csit/suites/openstack/tempest/tempest.robot

index ae8088c96c2486d9354238025d726b50bc3c6aa8..2d317d342d2dbecf378c5e29e6552bc4867d7eae 100644 (file)
@@ -135,12 +135,6 @@ Modify Config In File On Existing SSH Connection
     # to a library at some point, when/if other suites need to use it, so wanted to make it generic.
     Write Commands Until Prompt    sudo -E crudini --${modifier} ${config_file} ${config_section} ${config_key} ${config_value}
 
-Clean Up After Running Tempest
-    [Documentation]    Clean up any extra leftovers that were created to allow tempest tests to run.
-    Delete Network    ${external_net_name}
-    List Networks
-    Close All Connections
-
 Create Blacklist File
     [Documentation]    For each exclusion regex in the required @{${OPENSTACK_BRANCH}_exclusion_regexes} list a new
     ...    line will be created in the required ${blacklist_file} location. This file is pushed to the OS_CONTROL_NODE
index 8e3c42916b82484cf0e7d14429549315a6053a5c..f5c4a929f46ba8f024d666ba2b3a8e111466a303 100644 (file)
@@ -3,6 +3,7 @@ Documentation     Openstack library. This library is useful for tests to create
 Library           Collections
 Library           SSHLibrary
 Library           OperatingSystem
+Library           RequestsLibrary
 Resource          DataModels.robot
 Resource          Utils.robot
 Resource          SSHKeywords.robot
@@ -163,6 +164,13 @@ Create And Associate Floating IPs
     \    Should Be True    '${rc}' == '0'
     [Return]    ${ip_list}
 
+Delete Floating IP
+    [Arguments]    ${fip}
+    [Documentation]    Delete floating ip with neutron request.
+    ${rc}    ${output}=    Run And Return Rc And Output    openstack floating ip delete ${fip}
+    Log    ${output}
+    Should Be True    '${rc}' == '0'
+
 Verify Gateway Ips
     [Documentation]    Verifies the Gateway Ips with dump flow.
     ${output}=    Write Commands Until Prompt And Log    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
@@ -335,9 +343,9 @@ Get Match
     [Documentation]    Wrapper around Get Regexp Matches to return None if not found or the first match if found.
     @{matches} =    String.Get Regexp Matches    ${text}    ${regexp}
     ${matches_length} =    Get Length    ${matches}
-    BuiltIn.Set Test Variable    ${match}    None
-    BuiltIn.Run Keyword If    ${matches_length} > ${index}    BuiltIn.Set Test Variable    ${match}    @{matches}[${index}]
-    [Return]    ${match}
+    BuiltIn.Set Suite Variable    ${OS_MATCH}    None
+    BuiltIn.Run Keyword If    ${matches_length} > ${index}    BuiltIn.Set Suite Variable    ${OS_MATCH}    @{matches}[${index}]
+    [Return]    ${OS_MATCH}
 
 Get VM IP
     [Arguments]    ${fail_on_none}    ${vm}
@@ -600,6 +608,11 @@ Remove Interface
     ${rc}    ${output}=    Run And Return Rc And Output    openstack router remove subnet ${router_name} ${interface_name}
     Should Be True    '${rc}' == '0'
 
+Remove Gateway
+    [Arguments]    ${router_name}
+    [Documentation]    Remove external gateway from the router.
+    BuiltIn.Log    openstack router unset ${router_name} --external-gateway
+
 Update Router
     [Arguments]    ${router_name}    ${cmd}
     [Documentation]    Update the router with the command. Router name and command should be passed as argument.
@@ -616,6 +629,7 @@ Delete Router
     [Arguments]    ${router_name}
     [Documentation]    Delete Router and Interface to the subnets.
     ${rc}    ${output}=    Run And Return Rc And Output    openstack router delete ${router_name}
+    Log    ${output}
     Should Be True    '${rc}' == '0'
 
 Get DumpFlows And Ovsconfig
@@ -1119,3 +1133,64 @@ Neutron Cleanup
     \    BuiltIn.Run Keyword And Ignore Error    Delete Network    ${network}
     : FOR    ${sg}    IN    @{sgs}
     \    BuiltIn.Run Keyword And Ignore Error    Delete SecurityGroup    ${sg}
+
+OpenStack List All
+    [Documentation]    Get a list of different OpenStack resources that might be in use.
+    @{modules} =    BuiltIn.Create List    floating ip    server    router    port    network
+    ...    subnet    security group    security group rule
+    : FOR    ${module}    IN    @{modules}
+    \    OpenStack CLI    openstack ${module} list
+
+OpenStack CLI Get List
+    [Arguments]    ${cmd}
+    [Documentation]    Return a json list from the output of an OpenStack command.
+    ${json} =    OpenStack CLI    ${cmd}
+    @{list} =    RequestsLibrary.To Json    ${json}
+    BuiltIn.Log    ${list}
+    [Return]    @{list}
+
+OpenStack CLI
+    [Arguments]    ${cmd}
+    [Documentation]    Run the given OpenStack ${cmd}.
+    ${rc}    ${output} =    OperatingSystem.Run And Return Rc And Output    ${cmd}
+    BuiltIn.Log    ${output}
+    Should Be True    '${rc}' == '0'
+    [Return]    ${output}
+
+OpenStack Cleanup All
+    [Documentation]    Cleanup all Openstack resources with best effort. The keyword will query for all resources
+    ...    in use and then attempt to delete them. Errors are ignored to allow the cleanup to continue.
+    @{fips} =    OpenStack CLI Get List    openstack floating ip list -f json
+    : FOR    ${fip}    IN    @{fips}
+    \    BuiltIn.Run Keyword And Ignore Error    Delete Floating IP    ${fip['ID']}
+    @{vms} =    OpenStack CLI Get List    openstack server list -f json
+    : FOR    ${vm}    IN    @{vms}
+    \    BuiltIn.Run Keyword And Ignore Error    Delete Vm Instance    ${vm['ID']}
+    @{routers} =    OpenStack CLI Get List    openstack router list -f json
+    : FOR    ${router}    IN    @{routers}
+    \    BuiltIn.Run Keyword And Ignore Error    Cleanup Router    ${router['ID']}
+    @{ports} =    OpenStack CLI Get List    openstack port list -f json
+    : FOR    ${port}    IN    @{ports}
+    \    BuiltIn.Run Keyword And Ignore Error    Delete Port    ${port['ID']}
+    @{networks} =    OpenStack CLI Get List    openstack network list -f json
+    : FOR    ${network}    IN    @{networks}
+    \    BuiltIn.Run Keyword And Ignore Error    Delete Subnet    ${network['Subnets']}
+    \    BuiltIn.Run Keyword And Ignore Error    Delete Network    ${network['ID']}
+    @{security_groups} =    OpenStack CLI Get List    openstack security group list -f json
+    : FOR    ${security_group}    IN    @{security_groups}
+    \    BuiltIn.Run Keyword If    "${security_group['Name']}" != "default"    BuiltIn.Run Keyword And Ignore Error    Delete SecurityGroup    ${security_group['ID']}
+    OpenStack List All
+
+Cleanup Router
+    [Arguments]    ${id}
+    [Documentation]    Delete a router, but first remove any interfaces or gateways so that the delete will be successful.
+    @{ports} =    OpenStack CLI Get List    openstack port list --router ${id} -f json --long
+    : FOR    ${port}    IN    @{ports}
+    \    ${subnet_id} =    Get Match    ${port['Fixed IP Addresses']}    [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}    0
+    \    BuiltIn.Run Keyword If    "${port['Device Owner']}" == "network:router_gateway"    BuiltIn.Run Keyword And Ignore Error    Remove Gateway    ${id}
+    \    BuiltIn.Run Keyword If    "${port['Device Owner']}" == "network:router_interface"    BuiltIn.Run Keyword And Ignore Error    Remove Interface    ${id}    ${subnet_id}
+    BuiltIn.Run Keyword And Ignore Error    Delete Router    ${id}
+
+OpenStack Suite Teardown
+    OpenStack Cleanup All
+    SSHLibrary.Close All Connections
index 5388947aa8e53b325cabe3df9cf289b7c2a81176..0a20b9e0a4b001af4ea1160d73774f262b4e4088 100644 (file)
@@ -137,20 +137,7 @@ Elan SuiteTeardown
     [Documentation]    Elan suite teardown
     OpenStackOperations.Get OvsDebugInfo
     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set INFO org.opendaylight.genius.mdsalutil.internal.MDSALManager
-    SingleElan SuiteTeardown
-    SSHLibrary.Close All Connections
-
-SingleElan SuiteTeardown
-    [Documentation]    Delete network,subnet and port
-    BuiltIn.Log    Delete Neutron Ports, Subnet and network
-    : FOR    ${Port}    IN    @{NET_1_PORTS}
-    \    OpenStackOperations.Delete Port    ${Port}
-    OpenStackOperations.Delete SubNet    @{SUBNETS}[0]
-    OpenStackOperations.Delete Network    @{NETWORKS}[0]
-    OpenStackOperations.Delete SecurityGroup    ${SECURITY_GROUP}
-
-SingleElan SuiteSetup
-    [Documentation]    Create single ELAN with Multiple DPN
+    OpenStackOperations.OpenStack Suite Teardown
 
 MultipleElan Testsuite Setup
     [Documentation]    Create additional ELAN for multipleElan with Multiple DPN test
index e039e81bbe2fb5df2774912033f6ef579588ff71..11dacb99aaaf55146d56783f52326d1b69f2c53e 100644 (file)
@@ -3,7 +3,7 @@ Documentation     Test suite to validate vpnservice functionality in an openstac
 ...               The assumption of this suite is that the environment is already configured with the proper
 ...               integration bridges and vxlan tunnels.
 Suite Setup       VpnOperations.Basic Vpnservice Suite Setup
-Suite Teardown    SSHLibrary.Close All Connections
+Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
 Library           OperatingSystem
@@ -277,8 +277,3 @@ Delete Multiple L3VPN
     VpnOperations.VPN Delete L3VPN    vpnid=@{VPN_INSTANCE_IDS}[0]
     VpnOperations.VPN Delete L3VPN    vpnid=@{VPN_INSTANCE_IDS}[1]
     VpnOperations.VPN Delete L3VPN    vpnid=@{VPN_INSTANCE_IDS}[2]
-
-Cleanup
-    @{vms} =    BuiltIn.Create List    @{NET_1_VMS}    @{NET_2_VMS}
-    @{sgs} =    BuiltIn.Create List    ${SECURITY_GROUP}
-    Basic Vpnservice Suite Cleanup    ${VPN_INSTANCE_IDS}    ${vms}    ${NETWORKS}    ${SUBNETS}    ${PORTS}    ${sgs}
index f5e895ea0fb8addf55e6ab323c6ce2a51ddf598b..366f185a9d7b1525e1349895b22ac750cd304bc0 100644 (file)
@@ -5,7 +5,7 @@ Documentation     Test suite to validate IPv6 vpnservice functionality in an Ope
 Suite Setup       BuiltIn.Run Keywords    OpenStackOperations.Get OvsDebugInfo
 ...               AND    VpnOperations.Basic Vpnservice Suite Setup
 ...               AND    OpenStackOperations.Get OvsDebugInfo
-Suite Teardown    SSHLibrary.Close All Connections
+Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
 Library           OperatingSystem
@@ -284,8 +284,3 @@ Delete Multiple L3VPN
     VpnOperations.VPN Delete L3VPN    vpnid=@{VPN_INSTANCE_IDS}[0]
     VpnOperations.VPN Delete L3VPN    vpnid=@{VPN_INSTANCE_IDS}[1]
     VpnOperations.VPN Delete L3VPN    vpnid=@{VPN_INSTANCE_IDS}[2]
-
-Cleanup
-    @{vms} =    BuiltIn.Create List    @{NET_1_VMS}    @{NET_2_VMS}
-    @{sgs} =    BuiltIn.Create List    ${SECURITY_GROUP}
-    Basic Vpnservice Suite Cleanup    ${VPN_INSTANCE_IDS}    ${vms}    ${NETWORKS}    ${SUBNETS}    ${PORTS}    ${sgs}
index f8ef21f67a08977c79b5d22c26d9e8edd2de9911..40fe9e7f899af3e8784d1a74991f2f1922e9dfa0 100644 (file)
@@ -2,7 +2,7 @@
 Documentation     Test suite to check North-South connectivity in L3 using a router and an external network
 Suite Setup       BuiltIn.Run Keywords    SetupUtils.Setup_Utils_For_Setup_And_Teardown
 ...               AND    DevstackUtils.Devstack Suite Setup
-Suite Teardown    Close All Connections
+Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
 Library           SSHLibrary
index b7f91f213fcbdd7865087270cfd6a657103da92d..27e09f9505f12cb16c6fb5f4c6a8cba9bdf98b81 100644 (file)
@@ -2,7 +2,7 @@
 Documentation     Test suite to verify packet flows between vm instances.
 Suite Setup       BuiltIn.Run Keywords    SetupUtils.Setup_Utils_For_Setup_And_Teardown
 ...               AND    DevstackUtils.Devstack Suite Setup
-Suite Teardown    Close All Connections
+Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
 Library           SSHLibrary
index f60b952158f9311527800f96d85a119a15f4562f..ac67148e8ac8017d2e9d243b9a8cff204fb26534 100644 (file)
@@ -2,7 +2,7 @@
 Documentation     Test suite to check connectivity in L3 using routers.
 Suite Setup       BuiltIn.Run Keywords    SetupUtils.Setup_Utils_For_Setup_And_Teardown
 ...               AND    DevstackUtils.Devstack Suite Setup
-Suite Teardown    Close All Connections
+Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
 Library           SSHLibrary
index 9bdbe44672a0f233344e6663b4009ecf9f4f43fb..c4c2cd7226cc0d1c6b11c78d64e7933af4860014 100644 (file)
@@ -5,7 +5,7 @@ Documentation     Test suite to verify security groups basic and advanced functi
 ...               a false failure. The real value of this suite will be in stateful mode.
 Suite Setup       BuiltIn.Run Keywords    SetupUtils.Setup_Utils_For_Setup_And_Teardown
 ...               AND    DevstackUtils.Devstack Suite Setup
-Suite Teardown    Suite Teardown
+Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
 Force Tags        skip_if_${SECURITY_GROUP_MODE}
@@ -225,17 +225,3 @@ Delete Vm Instances In net_1
 Delete Security Groups
     OpenStackOperations.Delete SecurityGroup    additional-sg
     OpenStackOperations.Delete SecurityGroup    ${SECURITY_GROUP}
-
-*** Keywords ***
-Suite Teardown
-    : FOR    ${vm}    IN    @{NET_1_VMS}
-    \    OpenStackOperations.Delete Vm Instance    ${vm}
-    : FOR    ${vm}    IN    @{NET_2_VMS}
-    \    OpenStackOperations.Delete Vm Instance    ${vm}
-    : FOR    ${subnet}    IN    @{SUBNETS}
-    \    BuiltIn.Run Keyword And Ignore Error    OpenStackOperations.Delete SubNet    ${subnet}
-    : FOR    ${network}    IN    @{NETWORKS}
-    \    BuiltIn.Run Keyword And Ignore Error    OpenStackOperations.Delete Network    ${network}
-    BuiltIn.Run Keyword And Ignore Error    OpenStackOperations.Delete SecurityGroup    additional-sg
-    BuiltIn.Run Keyword And Ignore Error    OpenStackOperations.Delete SecurityGroup    ${SECURITY_GROUP}
-    SSHLibrary.Close All Connections
index a4606074ba7a9076fd6f052e78dbbc92f4030bbf..9bf69fe7db31fa875d74422dd079ada9d75f1ca8 100644 (file)
@@ -2,8 +2,7 @@
 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    BuiltIn.Run Keywords    Delete Configurations
-...               AND    Close All Connections
+Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Test Teardown     BuiltIn.Run Keywords    OpenStackOperations.Get Test Teardown Debugs
 ...               AND    OpenStackOperations.Get Test Teardown Debugs For SFC
@@ -99,7 +98,6 @@ Connectivity Tests From Vm Instance1 In net_1
     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_VM_IPS}[3]    ${DEST_VM_LIST}
     OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[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
index c60329b12ad8265499c6e363fbf7b1ec611ea734..6387cc1f7319f545c96f942f0d4ab8e944309428 100644 (file)
@@ -2,7 +2,7 @@
 Documentation     Test Suite for Neutron Security Group
 Suite Setup       BuiltIn.Run Keywords    SetupUtils.Setup_Utils_For_Setup_And_Teardown
 ...               AND    DevstackUtils.Devstack Suite Setup
-Suite Teardown    SSHLibrary.Close All Connections
+Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
 Library           SSHLibrary
@@ -73,11 +73,6 @@ TC04_Create Security Rule with port_range_max = -1
     Get Flows    ${OS_COMPUTE_1_IP}    ${OS_COMPUTE_2_IP}
     Neutron Rule Creation With Invalid Parameters    ${SGS[3]}    ${ADD_ARG_SSH7}    ${INVALID_PORT_RANGE_MIN}
 
-Cleanup
-    @{vms} =    BuiltIn.Create List
-    @{sgs} =    BuiltIn.Create List    ${SG_UPDATED}    @{SGS}
-    OpenStackOperations.Neutron Cleanup    ${vms}    ${NETWORKS}    ${SUBNETS}    ${PORTS}    ${sgs}
-
 *** Keywords ***
 Get Flows
     [Arguments]    ${OS_COMPUTE_1_IP}    ${OS_COMPUTE_2_IP}
index a2cf1ba42aff96823b85312a273d206293b37454..f3ba5dfb8c8d1ce8cf2613121ce51de564bac3ba 100644 (file)
@@ -2,7 +2,7 @@
 Documentation     Test suite for running tempest tests. It is assumed that the test environment
 ...               is already deployed and ready.
 Suite Setup       DevstackUtils.Log In To Tempest Executor And Setup Test Environment
-Suite Teardown    DevstackUtils.Clean Up After Running Tempest
+Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Test Teardown     BuiltIn.Run Keywords    OpenStackOperations.Get Test Teardown Debugs
 Test Template     DevstackUtils.Run Tempest Tests