Browse code

Add support to lib/tempest for using tempest test accounts

This commit adds support to lib/tempest for configuring tempest to use
the test accounts mechanism. It adds a new variable
TEMPEST_USE_TEST_ACCOUNTS which will be used to trigger using test
accounts. The generate tempest-account-generator utility packaged with
tempest is used to generate the users and projects and write an
accounts.yaml. Another option TEMPEST_CONCURRENCY is added to specify
the the number of accounts to create, the value defaults to the number
of processors on the system.

The auth configuration section is moved to the bottom of the
configure_tempest function to ensure the proper auth endpoint and
catalog entries are all set in the tempest.conf file because the
tempest-account-generator tool depends on tempest knowing how to talk
to keystone to create the accounts.

Change-Id: I8682f72ffe26fd133874f5c575df6389f787ffcc

Matthew Treinish authored on 2015/08/10 09:30:39
Showing 1 changed files
... ...
@@ -82,6 +82,21 @@ TEMPEST_STORAGE_PROTOCOL=${TEMPEST_STORAGE_PROTOCOL:-$TEMPEST_DEFAULT_STORAGE_PR
82 82
 IPV6_ENABLED=$(trueorfalse True IPV6_ENABLED)
83 83
 IPV6_SUBNET_ATTRIBUTES_ENABLED=$(trueorfalse True IPV6_SUBNET_ATTRIBUTES_ENABLED)
84 84
 
85
+# Do we want to make a configuration where Tempest has admin on
86
+# the cloud. We don't always want to so that we can ensure Tempest
87
+# would work on a public cloud.
88
+TEMPEST_HAS_ADMIN=$(trueorfalse True TEMPEST_HAS_ADMIN)
89
+
90
+# Credential provider configuration option variables
91
+TEMPEST_ALLOW_TENANT_ISOLATION=${TEMPEST_ALLOW_TENANT_ISOLATION:-$TEMPEST_HAS_ADMIN}
92
+TEMPEST_USE_TEST_ACCOUNTS=$(trueorfalse False $TEMPEST_USE_TEST_ACCOUNTS)
93
+
94
+# The number of workers tempest is expected to be run with. This is used for
95
+# generating a accounts.yaml for running with test-accounts. This is also the
96
+# same variable that devstack-gate uses to specify the number of workers that
97
+# it will run tempest with
98
+TEMPEST_CONCURRENCY=${TEMPEST_CONCURRENCY:-$(nproc)}
99
+
85 100
 
86 101
 # Functions
87 102
 # ---------
... ...
@@ -174,11 +189,6 @@ function configure_tempest {
174 174
 
175 175
     password=${ADMIN_PASSWORD:-secrete}
176 176
 
177
-    # Do we want to make a configuration where Tempest has admin on
178
-    # the cloud. We don't always want to so that we can ensure Tempest
179
-    # would work on a public cloud.
180
-    TEMPEST_HAS_ADMIN=$(trueorfalse True TEMPEST_HAS_ADMIN)
181
-
182 177
     # See ``lib/keystone`` where these users and tenants are set up
183 178
     ADMIN_USERNAME=${ADMIN_USERNAME:-admin}
184 179
     ADMIN_TENANT_NAME=${ADMIN_TENANT_NAME:-admin}
... ...
@@ -335,11 +345,6 @@ function configure_tempest {
335 335
     # Image Features
336 336
     iniset $TEMPEST_CONFIG image-feature-enabled deactivate_image True
337 337
 
338
-    # Auth
339
-    TEMPEST_ALLOW_TENANT_ISOLATION=${TEMPEST_ALLOW_TENANT_ISOLATION:-$TEMPEST_HAS_ADMIN}
340
-    iniset $TEMPEST_CONFIG auth allow_tenant_isolation ${TEMPEST_ALLOW_TENANT_ISOLATION:-True}
341
-    iniset $TEMPEST_CONFIG auth tempest_roles "Member"
342
-
343 338
     # Compute
344 339
     iniset $TEMPEST_CONFIG compute ssh_user ${DEFAULT_INSTANCE_USER:-cirros} # DEPRECATED
345 340
     iniset $TEMPEST_CONFIG compute network_for_ssh $PRIVATE_NETWORK_NAME
... ...
@@ -545,6 +550,19 @@ function configure_tempest {
545 545
         sudo chown $STACK_USER $BOTO_CONF
546 546
     fi
547 547
 
548
+    # Auth
549
+    iniset $TEMPEST_CONFIG auth tempest_roles "Member"
550
+    if [[ $TEMPEST_USE_TEST_ACCOUNTS == "True" ]]; then
551
+        if [[ $TEMPEST_HAS_ADMIN == "True" ]]; then
552
+            tempest-account-generator -c $TEMPEST_CONFIG --os-username $ADMIN_USERNAME --os-password $ADMIN_PASSWORD --os-tenant-name $ADMIN_TENANT_NAME -r $TEMPEST_CONCURRENCY --with-admin etc/accounts.yaml
553
+        else:
554
+            tempest-account-generator -c $TEMPEST_CONFIG --os-username $ADMIN_USERNAME --os-password $ADMIN_PASSWORD --os-tenant-name $ADMIN_TENANT_NAME -r $TEMPEST_CONCURRENCY etc/accounts.yaml
555
+        fi
556
+        iniset $TEMPEST_CONFIG auth allow_tenant_isolation False
557
+        iniset $TEMPEST_CONFIG auth test_accounts_file "etc/accounts.yaml"
558
+    else
559
+        iniset $TEMPEST_CONFIG auth allow_tenant_isolation ${TEMPEST_ALLOW_TENANT_ISOLATION:-True}
560
+    fi
548 561
     # Restore IFS
549 562
     IFS=$ifs
550 563
 }