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 | e68ac0b | 2017-03-08 13:45:18 -0500 | [diff] [blame] | 29 | # TODO(felipemonteiro): This regex does a negative lookahead to exclude slow |
| 30 | # tests that contain the @test.attr(type='slow') decorator above them. Slower |
| 31 | # tests will execute those tests in a separate gate, which will require |
| 32 | # future modification of this script. |
anthony.lin | 59c886c | 2017-03-23 14:33:00 -0500 | [diff] [blame] | 33 | DEVSTACK_FAST_GATE_TEMPEST_REGEX="(?!.*\[.*\bslow\b.*\])(^patrole_tempest_plugin\.tests\.api)" |
| 34 | DEVSTACK_SLOW_GATE_TEMPEST_REGEX="(?=.*\[.*\bslow\b.*\])(^patrole_tempest_plugin\.tests\.api)" |
Felipe Monteiro | 52c5565 | 2017-03-06 11:37:25 -0500 | [diff] [blame] | 35 | |
| 36 | # Import devstack function 'iniset'. |
| 37 | source $BASE/new/devstack/functions |
| 38 | |
Rick Bartra | 89f498f | 2017-03-20 15:54:45 -0400 | [diff] [blame] | 39 | # Use uuid tokens for faster test runs |
| 40 | KEYSTONE_CONF=/etc/keystone/keystone.conf |
| 41 | iniset $KEYSTONE_CONF token provider uuid |
| 42 | sudo service apache2 restart |
| 43 | |
Felipe Monteiro | 52c5565 | 2017-03-06 11:37:25 -0500 | [diff] [blame] | 44 | # First argument is expected to contain value equal either to 'admin' or |
| 45 | # 'member' (both lower-case). |
| 46 | RBAC_ROLE=$1 |
| 47 | |
| 48 | if [[ "$RBAC_ROLE" == "member" ]]; then |
| 49 | RBAC_ROLE="Member" |
| 50 | fi |
| 51 | |
anthony.lin | 59c886c | 2017-03-23 14:33:00 -0500 | [diff] [blame] | 52 | # Second argument is expected to contain value to indicate whether it is |
| 53 | # a "fast' or "slow test" gate |
| 54 | TYPE=$2 |
| 55 | |
Samantha Blanco | 0d88008 | 2017-03-23 18:14:37 -0400 | [diff] [blame] | 56 | # Set enable_rbac=True under [rbac] section in tempest.conf |
| 57 | iniset $TEMPEST_CONFIG rbac enable_rbac True |
Felipe Monteiro | 52c5565 | 2017-03-06 11:37:25 -0500 | [diff] [blame] | 58 | # Set rbac_test_role=$RBAC_ROLE under [rbac] section in tempest.conf |
| 59 | iniset $TEMPEST_CONFIG rbac rbac_test_role $RBAC_ROLE |
Samantha Blanco | 0d88008 | 2017-03-23 18:14:37 -0400 | [diff] [blame] | 60 | # Set strict_policy_check=False under [rbac] section in tempest.conf |
| 61 | iniset $TEMPEST_CONFIG rbac strict_policy_check False |
Felipe Monteiro | 52c5565 | 2017-03-06 11:37:25 -0500 | [diff] [blame] | 62 | # Set additional, necessary CONF values |
| 63 | iniset $TEMPEST_CONFIG auth use_dynamic_credentials True |
| 64 | iniset $TEMPEST_CONFIG auth tempest_roles Member |
Felipe Monteiro | 86fdd63 | 2017-03-13 12:07:38 -0400 | [diff] [blame] | 65 | iniset $TEMPEST_CONFIG identity auth_version v3 |
Felipe Monteiro | 52c5565 | 2017-03-06 11:37:25 -0500 | [diff] [blame] | 66 | |
| 67 | # Give permissions back to Tempest. |
| 68 | sudo chown -R tempest:stack $BASE/new/tempest |
| 69 | sudo chown -R tempest:stack $BASE/data/tempest |
| 70 | |
| 71 | set -o errexit |
| 72 | |
| 73 | # cd into Tempest directory before executing tox. |
| 74 | cd $BASE/new/tempest |
| 75 | |
anthony.lin | 59c886c | 2017-03-23 14:33:00 -0500 | [diff] [blame] | 76 | # Select Fast Gate if Type is set to 'fast', else use 'slow' gate |
| 77 | if [[ "$TYPE" == "fast" ]]; then |
| 78 | $TEMPEST_COMMAND -eall-plugin -- $DEVSTACK_FAST_GATE_TEMPEST_REGEX --concurrency=$TEMPEST_CONCURRENCY |
| 79 | else |
| 80 | $TEMPEST_COMMAND -eall-plugin -- $DEVSTACK_SLOW_GATE_TEMPEST_REGEX --concurrency=$TEMPEST_CONCURRENCY |
| 81 | fi |
| 82 | |
Felipe Monteiro | 52c5565 | 2017-03-06 11:37:25 -0500 | [diff] [blame] | 83 | sudo -H -u tempest .tox/all-plugin/bin/tempest list-plugins |