Browse code

Tempest: configure exact set of extensions to test

So far devstack configures tempest either for testing all extensions
or a specific subset. It does not allow users for specifying a set
of extensions which should not be exercised.

This patch adds this support. To this aim, the tempest configuration
process will scan API endpoints for active extensions using the
verify_tempest_config.py tool, and then will remove those extensions
which have been explicitly disabled by the user.

If an explicit subset of extensions to enable is passed to devstack,
tempest will use this subset, rather than the list of active
extensions.

Implements blueprint branchless-tempest-extensions

Change-Id: I263bcf04668953f414a4ef18cb98c1c373e142ad

Salvatore authored on 2014/10/05 08:36:34
Showing 1 changed files
... ...
@@ -78,6 +78,18 @@ IPV6_SUBNET_ATTRIBUTES_ENABLED=$(trueorfalse True $IPV6_SUBNET_ATTRIBUTES_ENABLE
78 78
 # Functions
79 79
 # ---------
80 80
 
81
+# remove_disabled_extension - removes disabled extensions from the list of extensions
82
+# to test for a given service
83
+function remove_disabled_extensions {
84
+    local extensions_list=$1
85
+    shift
86
+    local disabled_exts=$*
87
+    for ext_to_remove in ${disabled_exts//,/ } ; do
88
+        extensions_list=${extensions_list/$ext_to_remove","}
89
+    done
90
+    echo $extensions_list
91
+}
92
+
81 93
 # configure_tempest() - Set config files, create data dirs, etc
82 94
 function configure_tempest {
83 95
     setup_develop $TEMPEST_DIR
... ...
@@ -299,12 +311,24 @@ function configure_tempest {
299 299
     iniset $TEMPEST_CONFIG compute ssh_connect_method $ssh_connect_method
300 300
 
301 301
     # Compute Features
302
+    # Run verify_tempest_config -ur to retrieve enabled extensions on API endpoints
303
+    # NOTE(mtreinish): This must be done after auth settings are added to the tempest config
304
+    local tmp_cfg_file=$(mktemp)
305
+    $TEMPEST_DIR/tempest/cmd/verify_tempest_config.py -uro $tmp_cfg_file
306
+
307
+    local compute_api_extensions=${COMPUTE_API_EXTENSIONS:-"all"}
308
+    if [[ ! -z "$DISABLE_COMPUTE_API_EXTENSIONS" ]]; then
309
+        # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
310
+        compute_api_extensions=${COMPUTE_API_EXTENSIONS:-$(iniget $tmp_cfg_file compute-feature-enabled api_extensions | tr -d " ")}
311
+        # Remove disabled extensions
312
+        compute_api_extensions=$(remove_disabled_extensions $compute_api_extensions $DISABLE_COMPUTE_API_EXTENSIONS)
313
+    fi
314
+
302 315
     iniset $TEMPEST_CONFIG compute-feature-enabled resize True
303 316
     iniset $TEMPEST_CONFIG compute-feature-enabled live_migration ${LIVE_MIGRATION_AVAILABLE:-False}
304 317
     iniset $TEMPEST_CONFIG compute-feature-enabled change_password False
305 318
     iniset $TEMPEST_CONFIG compute-feature-enabled block_migration_for_live_migration ${USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION:-False}
306
-    iniset $TEMPEST_CONFIG compute-feature-enabled api_extensions ${COMPUTE_API_EXTENSIONS:-"all"}
307
-    iniset $TEMPEST_CONFIG compute-feature-disabled api_extensions ${DISABLE_COMPUTE_API_EXTENSIONS}
319
+    iniset $TEMPEST_CONFIG compute-feature-enabled api_extensions $compute_api_extensions
308 320
 
309 321
     # Compute admin
310 322
     iniset $TEMPEST_CONFIG "compute-admin" username $ADMIN_USERNAME
... ...
@@ -319,8 +343,15 @@ function configure_tempest {
319 319
     iniset $TEMPEST_CONFIG network default_network "$FIXED_RANGE"
320 320
     iniset $TEMPEST_CONFIG network-feature-enabled ipv6 "$IPV6_ENABLED"
321 321
     iniset $TEMPEST_CONFIG network-feature-enabled ipv6_subnet_attributes "$IPV6_SUBNET_ATTRIBUTES_ENABLED"
322
-    iniset $TEMPEST_CONFIG network-feature-enabled api_extensions ${NETWORK_API_EXTENSIONS:-"all"}
323
-    iniset $TEMPEST_CONFIG network-feature-disabled api_extensions ${DISABLE_NETWORK_API_EXTENSIONS}
322
+
323
+    local network_api_extensions=${NETWORK_API_EXTENSIONS:-"all"}
324
+    if [[ ! -z "$DISABLE_NETWORK_API_EXTENSIONS" ]]; then
325
+        # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
326
+        network_api_extensions=${NETWORK_API_EXTENSIONS:-$(iniget $tmp_cfg_file network-feature-enabled api_extensions | tr -d " ")}
327
+        # Remove disabled extensions
328
+        network_api_extensions=$(remove_disabled_extensions $network_api_extensions $DISABLE_NETWORK_API_EXTENSIONS)
329
+    fi
330
+    iniset $TEMPEST_CONFIG network-feature-enabled api_extensions $network_api_extensions
324 331
 
325 332
     # boto
326 333
     iniset $TEMPEST_CONFIG boto ec2_url "$EC2_SERVICE_PROTOCOL://$SERVICE_HOST:8773/services/Cloud"
... ...
@@ -362,12 +393,25 @@ function configure_tempest {
362 362
     iniset $TEMPEST_CONFIG telemetry too_slow_to_test "False"
363 363
 
364 364
     # Object storage
365
-    iniset $TEMPEST_CONFIG object-storage-feature-enabled discoverable_apis ${OBJECT_STORAGE_API_EXTENSIONS:-"all"}
366
-    iniset $TEMPEST_CONFIG object-storage-feature-disabled discoverable_apis ${OBJECT_STORAGE_DISABLE_API_EXTENSIONS}
365
+    local object_storage_api_extensions=${OBJECT_STORAGE_API_EXTENSIONS:-"all"}
366
+    if [[ ! -z "$DISABLE_OBJECT_STORAGE_API_EXTENSIONS" ]]; then
367
+        # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
368
+        object_storage_api_extensions=${OBJECT_STORAGE_API_EXTENSIONS:-$(iniget $tmp_cfg_file object-storage-feature-enabled discoverable_apis | tr -d " ")}
369
+        # Remove disabled extensions
370
+        object_storage_api_extensions=$(remove_disabled_extensions $object_storage_api_extensions $DISABLE_STORAGE_API_EXTENSIONS)
371
+    fi
372
+    iniset $TEMPEST_CONFIG object-storage-feature-enabled discoverable_apis $object_storage_api_extensions
367 373
 
368 374
     # Volume
369
-    iniset $TEMPEST_CONFIG volume-feature-enabled api_extensions ${VOLUME_API_EXTENSIONS:-"all"}
370
-    iniset $TEMPEST_CONFIG volume-feature-disabled api_extensions ${DISABLE_VOLUME_API_EXTENSIONS}
375
+    local volume_api_extensions=${VOLUME_API_EXTENSIONS:-"all"}
376
+    if [[ ! -z "$DISABLE_VOLUME_API_EXTENSIONS" ]]; then
377
+        # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
378
+        volume_api_extensions=${VOLUME_API_EXTENSIONS:-$(iniget $tmp_cfg_file volume-feature-enabled api_extensions | tr -d " ")}
379
+        # Remove disabled extensions
380
+        volume_api_extensions=$(remove_disabled_extensions $volume_api_extensions $DISABLE_VOLUME_API_EXTENSIONS)
381
+    fi
382
+    iniset $TEMPEST_CONFIG volume-feature-enabled api_extensions $volume_api_extensions
383
+
371 384
     if ! is_service_enabled c-bak; then
372 385
         iniset $TEMPEST_CONFIG volume-feature-enabled backup False
373 386
     fi