Felipe Monteiro | 52c5565 | 2017-03-06 11:37:25 -0500 | [diff] [blame] | 1 | #!/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. |
| 20 | PATROLE_DIR=$BASE/new/patrole |
| 21 | sudo pip install -e $PATROLE_DIR |
| 22 | |
| 23 | # Allow tempest.conf to be modified by Jenkins. |
| 24 | sudo chown -R jenkins:stack $BASE/new/tempest |
| 25 | sudo chown -R jenkins:stack $BASE/data/tempest |
| 26 | |
| 27 | TEMPEST_CONFIG=$BASE/new/tempest/etc/tempest.conf |
| 28 | TEMPEST_COMMAND="sudo -H -u tempest tox" |
Felipe Monteiro | 90c7eef | 2017-04-03 14:42:06 +0100 | [diff] [blame] | 29 | |
| 30 | DEVSTACK_GATE_TEMPEST_REGEX="(?!.*\[.*\bslow\b.*\])(^patrole_tempest_plugin\.tests\.api)" |
| 31 | DEVSTACK_MULTINODE_GATE_TEMPEST_REGEX="(?=.*\[.*\bslow\b.*\])(^patrole_tempest_plugin\.tests\.api)" |
Felipe Monteiro | 52c5565 | 2017-03-06 11:37:25 -0500 | [diff] [blame] | 32 | |
| 33 | # Import devstack function 'iniset'. |
| 34 | source $BASE/new/devstack/functions |
| 35 | |
| 36 | # First argument is expected to contain value equal either to 'admin' or |
| 37 | # 'member' (both lower-case). |
| 38 | RBAC_ROLE=$1 |
| 39 | |
| 40 | if [[ "$RBAC_ROLE" == "member" ]]; then |
| 41 | RBAC_ROLE="Member" |
| 42 | fi |
| 43 | |
Felipe Monteiro | 90c7eef | 2017-04-03 14:42:06 +0100 | [diff] [blame] | 44 | # Second argument is expected to contain value indicating whether the |
| 45 | # environment is "multinode" or not (empty string). |
anthony.lin | 59c886c | 2017-03-23 14:33:00 -0500 | [diff] [blame] | 46 | TYPE=$2 |
| 47 | |
Felipe Monteiro | a7a2916 | 2017-04-12 20:42:12 +0100 | [diff] [blame] | 48 | function set_uuid_tokens() { |
| 49 | # Use uuid tokens for faster test runs |
| 50 | KEYSTONE_CONF=/etc/keystone/keystone.conf |
| 51 | iniset $KEYSTONE_CONF token provider uuid |
| 52 | sudo service apache2 restart |
| 53 | } |
Felipe Monteiro | 52c5565 | 2017-03-06 11:37:25 -0500 | [diff] [blame] | 54 | |
Felipe Monteiro | a7a2916 | 2017-04-12 20:42:12 +0100 | [diff] [blame] | 55 | function setup_config() { |
| 56 | # Set enable_rbac=True under [rbac] section in tempest.conf |
| 57 | iniset $TEMPEST_CONFIG rbac enable_rbac True |
| 58 | # Set rbac_test_role=$RBAC_ROLE under [rbac] section in tempest.conf |
| 59 | iniset $TEMPEST_CONFIG rbac rbac_test_role $RBAC_ROLE |
| 60 | # Set strict_policy_check=False under [rbac] section in tempest.conf |
| 61 | iniset $TEMPEST_CONFIG rbac strict_policy_check False |
| 62 | # Set additional, necessary CONF values |
Felipe Monteiro | a7a2916 | 2017-04-12 20:42:12 +0100 | [diff] [blame] | 63 | iniset $TEMPEST_CONFIG auth tempest_roles Member |
Felipe Monteiro | a7a2916 | 2017-04-12 20:42:12 +0100 | [diff] [blame] | 64 | } |
Felipe Monteiro | 52c5565 | 2017-03-06 11:37:25 -0500 | [diff] [blame] | 65 | |
Felipe Monteiro | a7a2916 | 2017-04-12 20:42:12 +0100 | [diff] [blame] | 66 | function run_tests() { |
| 67 | # Give permissions back to Tempest. |
| 68 | sudo chown -R tempest:stack $BASE/new/tempest |
| 69 | sudo chown -R tempest:stack $BASE/data/tempest |
Felipe Monteiro | 52c5565 | 2017-03-06 11:37:25 -0500 | [diff] [blame] | 70 | |
Felipe Monteiro | a7a2916 | 2017-04-12 20:42:12 +0100 | [diff] [blame] | 71 | set -o errexit |
Felipe Monteiro | 52c5565 | 2017-03-06 11:37:25 -0500 | [diff] [blame] | 72 | |
Felipe Monteiro | a7a2916 | 2017-04-12 20:42:12 +0100 | [diff] [blame] | 73 | # cd into Tempest directory before executing tox. |
| 74 | cd $BASE/new/tempest |
anthony.lin | 59c886c | 2017-03-23 14:33:00 -0500 | [diff] [blame] | 75 | |
Felipe Monteiro | a7a2916 | 2017-04-12 20:42:12 +0100 | [diff] [blame] | 76 | if [[ "$TYPE" == "multinode" ]]; then |
| 77 | $TEMPEST_COMMAND -eall-plugin -- $DEVSTACK_MULTINODE_GATE_TEMPEST_REGEX --concurrency=$TEMPEST_CONCURRENCY |
Felipe Monteiro | a7a2916 | 2017-04-12 20:42:12 +0100 | [diff] [blame] | 78 | else |
| 79 | $TEMPEST_COMMAND -eall-plugin -- $DEVSTACK_GATE_TEMPEST_REGEX --concurrency=$TEMPEST_CONCURRENCY |
| 80 | fi |
| 81 | |
| 82 | sudo -H -u tempest .tox/all-plugin/bin/tempest list-plugins |
| 83 | } |
| 84 | |
| 85 | set_uuid_tokens |
| 86 | setup_config |
| 87 | run_tests |