upgrade tempest environment based on requirements.txt
[integration/test.git] / csit / suites / openstack / tempest / tempest.robot
1 *** Settings ***
2 Documentation     Test suite for running tempest tests. It is assumed that the test environment
3 ...               is already deployed and ready.
4 Suite Setup       Log In To Tempest Executor And Setup Test Environment
5 Suite Teardown    Clean Up After Running Tempest
6 Test Setup        Log Testcase Start To Controller Karaf
7 Library           SSHLibrary
8 Resource          ../../../libraries/Utils.robot
9 Resource          ../../../libraries/DevstackUtils.robot
10 Variables         ../../../variables/Variables.py
11
12 *** Variables ***
13 ${exclusion_regex}    'metering|test_l3_agent_scheduler.L3AgentSchedulerTestJSON|test_extensions.ExtensionsTestJSON.test_list_show_extensions'
14 ${tempest_directory}    /opt/stack/tempest
15 ${tempest_config_file}    ./tempest.conf
16
17 *** Test Cases ***
18 tempest.api.network
19     Run Tempest Tests    ${TEST_NAME}    ${exclusion_regex}    ${tempest_config_file}
20
21 tempest.scenario.test_minimum_basic
22     [Tags]    exclude
23     Run Tempest Tests    ${TEST_NAME}
24
25 *** Keywords ***
26 Log In To Tempest Executor And Setup Test Environment
27     [Documentation]    Open SSH connection to a devstack system and source the openstack
28     ...    credentials needed to run the tempest tests
29     # source_pwd is expected to exist in the below Create Network, Create Subnet keywords.    Might be a bug.
30     ${source_pwd}    Set Variable    yes
31     Set Suite Variable    ${source_pwd}
32     # Tempest network.api tests need an existing external network in order to create
33     # routers against.    Creating that here.
34     Create Network    external --router:external=True
35     Create Subnet    external    external-subnet    10.0.0.0/24
36     List Networks
37     ${control_node_conn_id}=    SSHLibrary.Open Connection    ${OS_CONTROL_NODE_IP}    prompt=${DEFAULT_LINUX_PROMPT_STRICT}
38     Utils.Flexible SSH Login    ${OS_USER}
39     Write Commands Until Prompt    cd ${tempest_directory}
40     Write Commands Until Prompt    sudo pip install -r requirements.txt --upgrade    timeout=300s
41     Write Commands Until Prompt    source ${DEVSTACK_DEPLOY_PATH}/openrc admin admin
42     ${net_id}=    Get Net Id    external    ${control_node_conn_id}
43     Generate Tempest Conf File    ${net_id}
44
45 Generate Tempest Conf File
46     [Arguments]    ${external_network_id}
47     [Documentation]    Tempest will be run with a config file ./tempest.conf. That file needs to be auto
48     ...    generated first, then updated with the current openstack info, including the specific external
49     ...    network id. There was trouble with permissions in upstream CI, so everything is done with sudo
50     ...    and even the tempest.conf is changed to 777 permissions.
51     Write Commands Until Prompt    source ${DEVSTACK_DEPLOY_PATH}/openrc admin admin
52     Write Commands Until Prompt    cd /opt/stack/tempest
53     Write Commands Until Prompt    sudo -E oslo-config-generator --config-file $(find . -name config-generator.tempest.conf) --output-file ${tempest_config_file}
54     # TODO: the below set of configs may not all be neccessary, so we could try to trim out what's not needed.
55     Add Config To File On Existing SSH Connection    ${tempest_config_file}    service_available    neutron    true
56     Add Config To File On Existing SSH Connection    ${tempest_config_file}    identity    catalog_type    identity
57     Add Config To File On Existing SSH Connection    ${tempest_config_file}    identity    uri    http://localhost:5000/v2.0
58     Add Config To File On Existing SSH Connection    ${tempest_config_file}    identity    uri_v3    http://localhost:8774/v3
59     Add Config To File On Existing SSH Connection    ${tempest_config_file}    identity    auth_version    v2
60     Add Config To File On Existing SSH Connection    ${tempest_config_file}    identity    v2_admin_endpoint_type    adminURL
61     Add Config To File On Existing SSH Connection    ${tempest_config_file}    identity    username    $OS_USERNAME
62     Add Config To File On Existing SSH Connection    ${tempest_config_file}    identity    admin_role    admin
63     Add Config To File On Existing SSH Connection    ${tempest_config_file}    identity    password    $OS_PASSWORD
64     Add Config To File On Existing SSH Connection    ${tempest_config_file}    auth    admin_username    $OS_USERNAME
65     Add Config To File On Existing SSH Connection    ${tempest_config_file}    auth    admin_project_name    $OS_TENANT_NAME
66     Add Config To File On Existing SSH Connection    ${tempest_config_file}    auth    admin_password    $OS_PASSWORD
67     Add Config To File On Existing SSH Connection    ${tempest_config_file}    network    public_network_id    ${external_network_id}
68     Add Config To File On Existing SSH Connection    ${tempest_config_file}    DEFAULT    verbose    true
69     Write Commands Until Prompt    sudo cat ./tempest.conf
70     Write Commands Until Prompt    sudo chmod 777 ./tempest.conf
71
72 Add Config To File On Existing SSH Connection
73     [Arguments]    ${config_file}    ${config_section}    ${config_key}    ${config_value}
74     [Documentation]    uses crudini to populate oslo cofg file.
75     # this keyword is only one line so seems like extra overhead, but this may be a good candidate to move
76     # to a library at some point, when/if other suites need to use it, so wanted to make it generic.
77     Write Commands Until Prompt    sudo -E crudini --set ${config_file} ${config_section} ${config_key} ${config_value}
78
79 Clean Up After Running Tempest
80     [Documentation]    Clean up any extra leftovers that were created to allow tempest tests to run.
81     Delete SubNet     external-subnet
82     Delete Network    external
83     List Networks
84     Close All Connections