blob: a0353ca7c8fb3fa8851c3ab065ed4f3253232870 [file] [log] [blame]
Felipe Monteiro52c55652017-03-06 11:37:25 -05001#!/bin/bash -xe
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15# This script is executed inside post_test_hook function in devstack gate.
16# First argument ($1) expects 'rbac-role' as value for setting appropriate
17# tempest rbac option 'rbac_test_role'.
18
Felipe Monteiro52c55652017-03-06 11:37:25 -050019# Allow tempest.conf to be modified by Jenkins.
20sudo chown -R jenkins:stack $BASE/new/tempest
21sudo chown -R jenkins:stack $BASE/data/tempest
22
23TEMPEST_CONFIG=$BASE/new/tempest/etc/tempest.conf
24TEMPEST_COMMAND="sudo -H -u tempest tox"
Felipe Monteiro90c7eef2017-04-03 14:42:06 +010025
26DEVSTACK_GATE_TEMPEST_REGEX="(?!.*\[.*\bslow\b.*\])(^patrole_tempest_plugin\.tests\.api)"
27DEVSTACK_MULTINODE_GATE_TEMPEST_REGEX="(?=.*\[.*\bslow\b.*\])(^patrole_tempest_plugin\.tests\.api)"
Felipe Monteiro52c55652017-03-06 11:37:25 -050028
29# Import devstack function 'iniset'.
30source $BASE/new/devstack/functions
31
32# First argument is expected to contain value equal either to 'admin' or
33# 'member' (both lower-case).
34RBAC_ROLE=$1
35
36if [[ "$RBAC_ROLE" == "member" ]]; then
37 RBAC_ROLE="Member"
38fi
39
Felipe Monteiro90c7eef2017-04-03 14:42:06 +010040# Second argument is expected to contain value indicating whether the
41# environment is "multinode" or not (empty string).
anthony.lin59c886c2017-03-23 14:33:00 -050042TYPE=$2
43
Felipe Monteiroa7a29162017-04-12 20:42:12 +010044function set_uuid_tokens() {
45 # Use uuid tokens for faster test runs
46 KEYSTONE_CONF=/etc/keystone/keystone.conf
47 iniset $KEYSTONE_CONF token provider uuid
48 sudo service apache2 restart
49}
Felipe Monteiro52c55652017-03-06 11:37:25 -050050
Felipe Monteiroa7a29162017-04-12 20:42:12 +010051function setup_config() {
52 # Set enable_rbac=True under [rbac] section in tempest.conf
53 iniset $TEMPEST_CONFIG rbac enable_rbac True
54 # Set rbac_test_role=$RBAC_ROLE under [rbac] section in tempest.conf
55 iniset $TEMPEST_CONFIG rbac rbac_test_role $RBAC_ROLE
56 # Set strict_policy_check=False under [rbac] section in tempest.conf
57 iniset $TEMPEST_CONFIG rbac strict_policy_check False
58 # Set additional, necessary CONF values
Felipe Monteiroa7a29162017-04-12 20:42:12 +010059 iniset $TEMPEST_CONFIG auth tempest_roles Member
Felipe Monteiroa7a29162017-04-12 20:42:12 +010060}
Felipe Monteiro52c55652017-03-06 11:37:25 -050061
Felipe Monteiroa7a29162017-04-12 20:42:12 +010062function run_tests() {
63 # Give permissions back to Tempest.
64 sudo chown -R tempest:stack $BASE/new/tempest
65 sudo chown -R tempest:stack $BASE/data/tempest
Felipe Monteiro52c55652017-03-06 11:37:25 -050066
Felipe Monteiroa7a29162017-04-12 20:42:12 +010067 set -o errexit
Felipe Monteiro52c55652017-03-06 11:37:25 -050068
Felipe Monteiroa7a29162017-04-12 20:42:12 +010069 # cd into Tempest directory before executing tox.
70 cd $BASE/new/tempest
anthony.lin59c886c2017-03-23 14:33:00 -050071
Felipe Monteiroa7a29162017-04-12 20:42:12 +010072 if [[ "$TYPE" == "multinode" ]]; then
73 $TEMPEST_COMMAND -eall-plugin -- $DEVSTACK_MULTINODE_GATE_TEMPEST_REGEX --concurrency=$TEMPEST_CONCURRENCY
Felipe Monteiroa7a29162017-04-12 20:42:12 +010074 else
75 $TEMPEST_COMMAND -eall-plugin -- $DEVSTACK_GATE_TEMPEST_REGEX --concurrency=$TEMPEST_CONCURRENCY
76 fi
77
78 sudo -H -u tempest .tox/all-plugin/bin/tempest list-plugins
79}
80
81set_uuid_tokens
82setup_config
83run_tests