blob: af7c856f8084989c4516eaf613e3233ef3bfcd4e [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
19# Install pip manually.
20PATROLE_DIR=$BASE/new/patrole
21sudo pip install -e $PATROLE_DIR
22
23# Allow tempest.conf to be modified by Jenkins.
24sudo chown -R jenkins:stack $BASE/new/tempest
25sudo chown -R jenkins:stack $BASE/data/tempest
26
27TEMPEST_CONFIG=$BASE/new/tempest/etc/tempest.conf
28TEMPEST_COMMAND="sudo -H -u tempest tox"
Felipe Monteiro90c7eef2017-04-03 14:42:06 +010029
30DEVSTACK_GATE_TEMPEST_REGEX="(?!.*\[.*\bslow\b.*\])(^patrole_tempest_plugin\.tests\.api)"
Felipe Monteiroa7a29162017-04-12 20:42:12 +010031DEVSTACK_GATE_TEMPEST_HEAT_REGEX="(?!.*\[.*\bslow\b.*\])(^patrole_tempest_plugin\.tests\.api\.orchestration)"
Felipe Monteiro90c7eef2017-04-03 14:42:06 +010032DEVSTACK_MULTINODE_GATE_TEMPEST_REGEX="(?=.*\[.*\bslow\b.*\])(^patrole_tempest_plugin\.tests\.api)"
Felipe Monteiro52c55652017-03-06 11:37:25 -050033
34# Import devstack function 'iniset'.
35source $BASE/new/devstack/functions
36
37# First argument is expected to contain value equal either to 'admin' or
38# 'member' (both lower-case).
39RBAC_ROLE=$1
40
41if [[ "$RBAC_ROLE" == "member" ]]; then
42 RBAC_ROLE="Member"
43fi
44
Felipe Monteiro90c7eef2017-04-03 14:42:06 +010045# Second argument is expected to contain value indicating whether the
46# environment is "multinode" or not (empty string).
anthony.lin59c886c2017-03-23 14:33:00 -050047TYPE=$2
48
Felipe Monteiroa7a29162017-04-12 20:42:12 +010049function set_uuid_tokens() {
50 # Use uuid tokens for faster test runs
51 KEYSTONE_CONF=/etc/keystone/keystone.conf
52 iniset $KEYSTONE_CONF token provider uuid
53 sudo service apache2 restart
54}
Felipe Monteiro52c55652017-03-06 11:37:25 -050055
Felipe Monteiroa7a29162017-04-12 20:42:12 +010056function setup_config() {
57 # Set enable_rbac=True under [rbac] section in tempest.conf
58 iniset $TEMPEST_CONFIG rbac enable_rbac True
59 # Set rbac_test_role=$RBAC_ROLE under [rbac] section in tempest.conf
60 iniset $TEMPEST_CONFIG rbac rbac_test_role $RBAC_ROLE
61 # Set strict_policy_check=False under [rbac] section in tempest.conf
62 iniset $TEMPEST_CONFIG rbac strict_policy_check False
63 # Set additional, necessary CONF values
Felipe Monteiroa7a29162017-04-12 20:42:12 +010064 iniset $TEMPEST_CONFIG auth tempest_roles Member
Felipe Monteiroa7a29162017-04-12 20:42:12 +010065}
Felipe Monteiro52c55652017-03-06 11:37:25 -050066
Felipe Monteiroa7a29162017-04-12 20:42:12 +010067function run_tests() {
68 # Give permissions back to Tempest.
69 sudo chown -R tempest:stack $BASE/new/tempest
70 sudo chown -R tempest:stack $BASE/data/tempest
Felipe Monteiro52c55652017-03-06 11:37:25 -050071
Felipe Monteiroa7a29162017-04-12 20:42:12 +010072 set -o errexit
Felipe Monteiro52c55652017-03-06 11:37:25 -050073
Felipe Monteiroa7a29162017-04-12 20:42:12 +010074 # cd into Tempest directory before executing tox.
75 cd $BASE/new/tempest
anthony.lin59c886c2017-03-23 14:33:00 -050076
Felipe Monteiroa7a29162017-04-12 20:42:12 +010077 if [[ "$TYPE" == "multinode" ]]; then
78 $TEMPEST_COMMAND -eall-plugin -- $DEVSTACK_MULTINODE_GATE_TEMPEST_REGEX --concurrency=$TEMPEST_CONCURRENCY
79 elif [[ "$TYPE" == "heat" ]]; then
80 $TEMPEST_COMMAND -eall-plugin -- $DEVSTACK_GATE_TEMPEST_HEAT_REGEX --concurrency=$TEMPEST_CONCURRENCY
81 else
82 $TEMPEST_COMMAND -eall-plugin -- $DEVSTACK_GATE_TEMPEST_REGEX --concurrency=$TEMPEST_CONCURRENCY
83 fi
84
85 sudo -H -u tempest .tox/all-plugin/bin/tempest list-plugins
86}
87
88set_uuid_tokens
89setup_config
90run_tests