Cluster Library consolidation 3
[integration/test.git] / csit / libraries / DevstackUtils.robot
index 8b495c7d9e27c196585629cd54ecc048fc94202a..7be4a109d3d5f9e489700b7effe53173b24e2f10 100644 (file)
@@ -8,6 +8,7 @@ Library           Collections
 Library           RequestsLibrary
 Library           ./UtilLibrary.py
 Resource          KarafKeywords.robot
+Resource          OpenStackOperations.robot
 Variables         ../variables/Variables.py
 
 *** Variables ***
@@ -23,25 +24,39 @@ ${CLEAN_DEVSTACK_HOST}    False
 
 *** Keywords ***
 Run Tempest Tests
-    [Arguments]    ${tempest_regex}    ${timeout}=600s
-    [Documentation]  Execute the tempest tests
-    Write Commands Until Prompt    cd /opt/stack/new/tempest
-    Write Commands Until Prompt    sudo rm -rf /opt/stack/new/tempest/.testrepository
-    Write Commands Until Prompt    sudo testr init
-    ${results}=    Write Commands Until Prompt    sudo -E testr run ${tempest_regex} --subunit | subunit-trace --no-failure-debug -f    timeout=${timeout}
-    Create File    ${WORKSPACE}/tempest_output.log    data=${results}
+    [Arguments]    ${tempest_regex}    ${tempest_exclusion_regex}=""    ${tempest_conf}=""    ${tempest_directory}=/opt/stack/tempest    ${timeout}=600s
+    [Documentation]    Execute the tempest tests.
+    Write Commands Until Prompt    source ${DEVSTACK_DEPLOY_PATH}/openrc admin admin
+    Write Commands Until Prompt    cd ${tempest_directory}
+    Write Commands Until Prompt    sudo rm -rf ${tempest_directory}/.testrepository
+    Write Commands Until Prompt    sudo testr list-tests | egrep ${tempest_regex} | egrep -v ${tempest_exclusion_regex} > tests_to_execute.txt
+    ${tests_to_execute}=    Write Commands Until Prompt    sudo cat tests_to_execute.txt
+    Log    ${tests_to_execute}
+    # run_tempests.sh is a wrapper to testr, and we are providing the config file
+    ${results}=    Write Commands Until Prompt    sudo -E ./run_tempest.sh -C ${tempest_conf} -N ${tempest_regex} -- --load-list tests_to_execute.txt    timeout=${timeout}
+    Log    ${results}
+    Create File    tempest_output_${tempest_regex}.log    data=${results}
     Should Contain    ${results}    Failed: 0
     # TODO: also need to verify some non-zero pass count as well as other results are ok (e.g. skipped, etc)
 
 Devstack Suite Setup Tests
-    [Documentation]  Login to  the Openstack Control Node to run tempest suite
-    SSHLibrary.Open Connection    ${OS_CONTROL_NODE_IP}    prompt=${DEFAULT_LINUX_PROMPT}
+    [Arguments]    ${source_pwd}=no    ${odl_ip}=${ODL_SYSTEM_IP}
+    [Documentation]    Login to the Openstack Control Node to run tempest suite
+    Create Session    session    http://${odl_ip}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
+    ${devstack_conn_id}=    SSHLibrary.Open Connection    ${OS_CONTROL_NODE_IP}    prompt=${DEFAULT_LINUX_PROMPT}
+    Set Suite Variable    ${devstack_conn_id}
+    Set Suite Variable    ${source_pwd}
+    Log    ${devstack_conn_id}
     Utils.Flexible SSH Login    ${OS_USER}    ${DEVSTACK_SYSTEM_PASSWORD}
     SSHLibrary.Set Client Configuration    timeout=${default_devstack_prompt_timeout}
 
 Devstack Suite Setup
-    [Documentation]  Login to  the Openstack Control Node to run tempest suite
-    SSHLibrary.Open Connection    ${DEVSTACK_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}
+    [Arguments]    ${source_pwd}=no
+    [Documentation]    Login to the Openstack Control Node to run tempest suite
+    ${devstack_conn_id}=    SSHLibrary.Open Connection    ${DEVSTACK_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}
+    Set Suite Variable    ${devstack_conn_id}
+    Set Suite Variable    ${source_pwd}
+    Log    ${devstack_conn_id}
     Utils.Flexible SSH Login    ${DEVSTACK_SYSTEM_USER}    ${DEVSTACK_SYSTEM_PASSWORD}
     SSHLibrary.Set Client Configuration    timeout=${default_devstack_prompt_timeout}
     Run Keyword If    ${CLEAN_DEVSTACK_HOST}    Clean DevStack Host In Case It Is Not Sterile
@@ -104,8 +119,8 @@ Write Commands Until Prompt
     [Return]    ${output}
 
 Get Networking ODL Version Of Release
-    [Documentation]   Get version of ODL to be installed
     [Arguments]    ${version}
+    [Documentation]    Get version of ODL to be installed
     # once Beryllium SR1 goes out, we can change beryllium-latest to use 0.4.2
     Return From Keyword If    "${version}" == "beryllium-latest"    beryllium-snapshot-0.4.2
     Return From Keyword If    "${version}" == "beryllium-SR1"    beryllium-snapshot-0.4.1
@@ -120,7 +135,7 @@ Get Networking ODL Version Of Release
     Return From Keyword If    "${version}" == "helium"    helium
 
 Show Devstack Debugs
-    [Documentation]   Collect the devstack logs to debug in case of failure
+    [Documentation]    Collect the devstack logs to debug in case of failure
     Write Commands Until Prompt    gunzip /opt/stack/logs/devstacklog.txt.gz
     Write Commands Until Prompt    tail -n2000 /opt/stack/logs/devstacklog.txt    timeout=600s
     Write Commands Until Prompt    grep 'distribution-karaf.*zip' /opt/stack/logs/devstacklog.txt