Add Robot test for running Tempest test suite
[validation.git] / tests / openstack / tempest / tempest.resource
1 ##############################################################################
2 # Copyright (c) 2019 AT&T Intellectual Property.                             #
3 # Copyright (c) 2019 Nokia.                                                  #
4 #                                                                            #
5 # Licensed under the Apache License, Version 2.0 (the "License");            #
6 # you maynot use this file except in compliance with the License.            #
7 #                                                                            #
8 # You may obtain a copy of the License at                                    #
9 #       http://www.apache.org/licenses/LICENSE-2.0                           #
10 #                                                                            #
11 # Unless required by applicable law or agreed to in writing, software        #
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
14 # See the License for the specific language governing permissions and        #
15 # limitations under the License.                                             #
16 ##############################################################################
17
18
19 *** Settings ***
20 Library            BuiltIn
21 Library            Collections
22 Library            OperatingSystem
23 Library            Process
24 Library            String
25
26
27 *** Variables ***
28 ${REPORTDIR}       ${LOG_PATH}/${SUITE_NAME.replace(' ','_')}
29 ${WORKSPACE}       sut
30 ${WORKDIR}         ${TEMPDIR}/tempest-run/${WORKSPACE}
31
32
33 *** Keywords ***
34 Setup Workspace
35    Create Directory    ${WORKDIR}
36    ${result}=          Run Process  tempest  init  --name  ${WORKSPACE}  ${WORKDIR}
37    Should Be Equal As Integers  ${result.rc}  0
38
39 Remove Workspace
40    Run Process         tempest  workspace  remove  --name  ${WORKSPACE}
41    Remove Directory    ${WORKDIR}  recursive=True
42
43 Create Tempest Configuration File
44    ${env}=             Get Deployment Credential Variables
45    ${result}=          Run Process  discover-tempest-config
46    ...                     --create
47    ...                     --out  ${WORKDIR}/etc/tempest.conf
48    ...                     DEFAULT.log_dir  ${WORKDIR}/logs
49    ...                     DEFAULT.log_file  tempest.log
50    ...                     oslo_concurrency.lock_path  ${WORKDIR}/tempest_lock
51    ...                     auth.use_dynamic_credentials  true
52    ...                   env=${env}
53    Should Be Equal As Integers  ${result.rc}  0
54
55 Get Deployment Credential Variables
56    ${env}=             Get Environment Variables
57    ${openrc}=          Get File  /root/openrc
58    ${str}=             Get Lines Matching Regexp  ${openrc}  ^export .*
59    @{lines}=           Split To Lines  ${str}
60    :FOR  ${line}  IN  @{lines}
61    \   ${str}=             Remove String Using Regexp  ${line}  ^export${SPACE}
62    \   ${key}  ${value}    Split String  ${str}  separator==
63    \   Set To Dictionary   ${env}  ${key}=${value}
64    Should Not Be Empty  ${env}
65    [Return]            ${env}
66
67 Run Tempest Refstack Tests
68    ${result}=          Run Process  tempest  run
69    ...                     --workspace  ${WORKSPACE}
70    ...                     --load-list  ${CURDIR}/test_list.txt
71    ...                     --blacklist-file  ${CURDIR}/blacklist.txt
72    ...                     --concurrency  4
73    ...                   stdout=${WORKDIR}/logs/tempest_run.log
74    ...                   stderr=STDOUT
75    Copy Files          ${WORKDIR}/logs/*  ${REPORTDIR}/
76    Should Contain      ${result.stdout}  - Failed: 0