L2Gw Test Cases Suite1
[integration/test.git] / csit / libraries / DevstackUtils.robot
1 *** Settings ***
2 Documentation     General Utils library. This library has broad scope, it can be used by any robot system tests.
3 Library           SSHLibrary
4 Library           String
5 Library           DateTime
6 Library           Process
7 Library           Collections
8 Library           RequestsLibrary
9 Library           ./UtilLibrary.py
10 Resource          KarafKeywords.robot
11 Resource          OpenStackOperations.robot
12 Variables         ../variables/Variables.py
13
14 *** Variables ***
15 ${default_devstack_prompt_timeout}    10s
16 ${DEVSTACK_SYSTEM_PASSWORD}    \    # set to empty, but provide for others to override if desired
17
18 *** Keywords ***
19 Run Tempest Tests
20     [Arguments]    ${tempest_regex}    ${tempest_exclusion_regex}=""    ${tempest_conf}=""    ${tempest_directory}=/opt/stack/tempest    ${timeout}=600s
21     [Documentation]    Execute the tempest tests.
22     Return From Keyword If    "skip_if_${OPENSTACK_BRANCH}" in @{TEST_TAGS}
23     Return From Keyword If    "skip_if_${SECURITY_GROUP_MODE}" in @{TEST_TAGS}
24     ${devstack_conn_id}=    Get ControlNode Connection
25     Switch Connection    ${devstack_conn_id}
26     Write Commands Until Prompt    source ${DEVSTACK_DEPLOY_PATH}/openrc admin admin
27     Write Commands Until Prompt    cd ${tempest_directory}
28     # From Ocata and moving forward, we can replace 'ostestr' with 'tempest run'
29     # Note: If black-regex cancels out the entire regex (white-regex), all tests are run
30     # --black-regex ${tempest_exclusion_regex} is removed for now since it only seems to work from newton
31     ${results}=    Write Commands Until Prompt    ostestr --regex ${tempest_regex}    timeout=${timeout}
32     Log    ${results}
33     # Save stdout to file
34     Create File    tempest_output_${tempest_regex}.log    data=${results}
35     # output tempest generated log file which may have different debug levels than what stdout would show
36     # FIXME: having the INFO level tempest logs is helpful as it gives details like the UUIDs of nouns used in the
37     # the tests which can sometimes be tracked in ODL and Openstack logs when debugging. However, this "cat" step
38     # does not even complete for the tempest.api.network tests in under 2min. We need a faster way to get this
39     # info. Probably pulling the log file and storing it on the log server is best. Hopefully someone can get
40     # to this. For now, commenting out this next debug step.
41     # ${output}=    Write Commands Until Prompt    cat ${tempest_directory}/tempest.log    timeout=120s
42     # Log    ${output}
43     Should Contain    ${results}    Failed: 0
44     # TODO: also need to verify some non-zero pass count as well as other results are ok (e.g. skipped, etc)
45
46 Devstack Suite Setup
47     [Arguments]    ${source_pwd}=no    ${odl_ip}=${ODL_SYSTEM_IP}
48     [Documentation]    Login to the Openstack Control Node to run tempest suite
49     Create Session    session    http://${odl_ip}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
50     ${devstack_conn_id}=    SSHLibrary.Open Connection    ${OS_CONTROL_NODE_IP}    prompt=${DEFAULT_LINUX_PROMPT}
51     Set Suite Variable    ${devstack_conn_id}
52     Set Suite Variable    ${source_pwd}
53     Log    ${devstack_conn_id}
54     Utils.Flexible SSH Login    ${OS_USER}    ${DEVSTACK_SYSTEM_PASSWORD}
55     SSHLibrary.Set Client Configuration    timeout=${default_devstack_prompt_timeout}
56
57 Write Commands Until Prompt
58     [Arguments]    ${cmd}    ${timeout}=${default_devstack_prompt_timeout}
59     [Documentation]    quick wrapper for Write and Read Until Prompt Keywords to make test cases more readable
60     Log    ${cmd}
61     SSHLibrary.Set Client Configuration    timeout=${timeout}
62     SSHLibrary.Read
63     SSHLibrary.Write    ${cmd}
64     ${output}=    SSHLibrary.Read Until Prompt
65     [Return]    ${output}