Browse code

Fix usage of tempest utils during config

Most of the tempest utilities need at least a partially setup
configuration file to work properly. This is because most of them
make api requests in order to perform the expected operations.
This causes a bit of a chicken and egg problem when we rely on
these utilities for configuration purposes since we don't know if
we have enough of a configuration file to run things. This previously
wasn't an issue because all we needed to run was verify-tempest config
and it wasn't in a critical path just for api extension discovery and
it wasn't relied on. But, with the addition of tempest preprovisioned
credentials we rely on a tempest util to create the credentials we
use for running things. We need to ensure the util has as complete of
a config file when it's run to ensure that everything is in the
correct state.

This commit moves the running of all tempest utils and the associated
iniset calls to the end of the configure_tempest function to ensure
that the utils have as complete a config file as possible.
Additionally, it makes all tempest util calls are venv isolated. (which
is mostly future proofing for when things are branched on stable)

Change-Id: I5844aed4e134fbc7210aa0eca83500e260915b7b

Matthew Treinish authored on 2016/04/12 01:52:39
Showing 1 changed files
... ...
@@ -317,44 +317,6 @@ function configure_tempest {
317 317
     fi
318 318
 
319 319
     # Compute Features
320
-    # Run ``verify_tempest_config -ur`` to retrieve enabled extensions on API endpoints
321
-    # NOTE(mtreinish): This must be done after auth settings are added to the tempest config
322
-    local tmp_cfg_file
323
-    tmp_cfg_file=$(mktemp)
324
-    cd $TEMPEST_DIR
325
-    if [[ "$OFFLINE" != "True" ]]; then
326
-        tox -revenv --notest
327
-    fi
328
-
329
-    # Auth
330
-    iniset $TEMPEST_CONFIG auth tempest_roles "Member"
331
-    if [[ $TEMPEST_USE_TEST_ACCOUNTS == "True" ]]; then
332
-        if [[ $TEMPEST_HAS_ADMIN == "True" ]]; then
333
-            tempest-account-generator -c $TEMPEST_CONFIG --os-username $admin_username --os-password "$password" --os-tenant-name $admin_project_name -r $TEMPEST_CONCURRENCY --with-admin etc/accounts.yaml
334
-        else
335
-            tempest-account-generator -c $TEMPEST_CONFIG --os-username $admin_username --os-password "$password" --os-tenant-name $admin_project_name -r $TEMPEST_CONCURRENCY etc/accounts.yaml
336
-        fi
337
-        iniset $TEMPEST_CONFIG auth use_dynamic_credentials False
338
-        iniset $TEMPEST_CONFIG auth test_accounts_file "etc/accounts.yaml"
339
-    elif [[ $TEMPEST_HAS_ADMIN == "False" ]]; then
340
-        iniset $TEMPEST_CONFIG auth use_dynamic_credentials ${TEMPEST_ALLOW_TENANT_ISOLATION:-False}
341
-
342
-    else
343
-        iniset $TEMPEST_CONFIG auth use_dynamic_credentials ${TEMPEST_ALLOW_TENANT_ISOLATION:-True}
344
-    fi
345
-
346
-    # NOTE(mtreinish): Respect constraints on tempest verify-config venv
347
-    tox -evenv -- pip install -c $REQUIREMENTS_DIR/upper-constraints.txt -r requirements.txt
348
-    tox -evenv -- tempest verify-config -uro $tmp_cfg_file
349
-
350
-    local compute_api_extensions=${COMPUTE_API_EXTENSIONS:-"all"}
351
-    if [[ ! -z "$DISABLE_COMPUTE_API_EXTENSIONS" ]]; then
352
-        # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
353
-        compute_api_extensions=${COMPUTE_API_EXTENSIONS:-$(iniget $tmp_cfg_file compute-feature-enabled api_extensions | tr -d " ")}
354
-        # Remove disabled extensions
355
-        compute_api_extensions=$(remove_disabled_extensions $compute_api_extensions $DISABLE_COMPUTE_API_EXTENSIONS)
356
-    fi
357
-
358 320
     # Set the microversion range for compute tests.
359 321
     # This is used to run the Nova microversions tests.
360 322
     # Setting [None, latest] range of microversion which allow Tempest to run all microversions tests.
... ...
@@ -383,7 +345,6 @@ function configure_tempest {
383 383
     iniset $TEMPEST_CONFIG compute-feature-enabled live_migration ${LIVE_MIGRATION_AVAILABLE:-False}
384 384
     iniset $TEMPEST_CONFIG compute-feature-enabled change_password False
385 385
     iniset $TEMPEST_CONFIG compute-feature-enabled block_migration_for_live_migration ${USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION:-False}
386
-    iniset $TEMPEST_CONFIG compute-feature-enabled api_extensions $compute_api_extensions
387 386
     # TODO(mriedem): Remove the preserve_ports flag when Juno is end of life.
388 387
     iniset $TEMPEST_CONFIG compute-feature-enabled preserve_ports True
389 388
     # TODO(gilliard): Remove the live_migrate_paused_instances flag when Juno is end of life.
... ...
@@ -420,15 +381,6 @@ function configure_tempest {
420 420
     iniset $TEMPEST_CONFIG network-feature-enabled ipv6 "$IPV6_ENABLED"
421 421
     iniset $TEMPEST_CONFIG network-feature-enabled ipv6_subnet_attributes "$IPV6_SUBNET_ATTRIBUTES_ENABLED"
422 422
 
423
-    local network_api_extensions=${NETWORK_API_EXTENSIONS:-"all"}
424
-    if [[ ! -z "$DISABLE_NETWORK_API_EXTENSIONS" ]]; then
425
-        # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
426
-        network_api_extensions=${NETWORK_API_EXTENSIONS:-$(iniget $tmp_cfg_file network-feature-enabled api_extensions | tr -d " ")}
427
-        # Remove disabled extensions
428
-        network_api_extensions=$(remove_disabled_extensions $network_api_extensions $DISABLE_NETWORK_API_EXTENSIONS)
429
-    fi
430
-    iniset $TEMPEST_CONFIG network-feature-enabled api_extensions $network_api_extensions
431
-
432 423
     # Orchestration Tests
433 424
     if is_service_enabled heat; then
434 425
         if [[ ! -z "$HEAT_CFN_IMAGE_URL" ]]; then
... ...
@@ -461,16 +413,6 @@ function configure_tempest {
461 461
     # Telemetry
462 462
     iniset $TEMPEST_CONFIG telemetry-feature-enabled events "True"
463 463
 
464
-    # Object Store
465
-    local object_storage_api_extensions=${OBJECT_STORAGE_API_EXTENSIONS:-"all"}
466
-    if [[ ! -z "$DISABLE_OBJECT_STORAGE_API_EXTENSIONS" ]]; then
467
-        # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
468
-        object_storage_api_extensions=${OBJECT_STORAGE_API_EXTENSIONS:-$(iniget $tmp_cfg_file object-storage-feature-enabled discoverable_apis | tr -d " ")}
469
-        # Remove disabled extensions
470
-        object_storage_api_extensions=$(remove_disabled_extensions $object_storage_api_extensions $DISABLE_STORAGE_API_EXTENSIONS)
471
-    fi
472
-    iniset $TEMPEST_CONFIG object-storage-feature-enabled discoverable_apis $object_storage_api_extensions
473
-
474 464
     # Validation
475 465
     iniset $TEMPEST_CONFIG validation run_validation ${TEMPEST_RUN_VALIDATION:-False}
476 466
     iniset $TEMPEST_CONFIG validation ip_version_for_ssh 4
... ...
@@ -484,15 +426,6 @@ function configure_tempest {
484 484
     # TODO(ynesenenko): Remove the volume_services flag when Liberty and Kilo will correct work with host info.
485 485
     iniset $TEMPEST_CONFIG volume-feature-enabled volume_services True
486 486
 
487
-    local volume_api_extensions=${VOLUME_API_EXTENSIONS:-"all"}
488
-    if [[ ! -z "$DISABLE_VOLUME_API_EXTENSIONS" ]]; then
489
-        # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
490
-        volume_api_extensions=${VOLUME_API_EXTENSIONS:-$(iniget $tmp_cfg_file volume-feature-enabled api_extensions | tr -d " ")}
491
-        # Remove disabled extensions
492
-        volume_api_extensions=$(remove_disabled_extensions $volume_api_extensions $DISABLE_VOLUME_API_EXTENSIONS)
493
-    fi
494
-    iniset $TEMPEST_CONFIG volume-feature-enabled api_extensions $volume_api_extensions
495
-
496 487
     if ! is_service_enabled c-bak; then
497 488
         iniset $TEMPEST_CONFIG volume-feature-enabled backup False
498 489
     fi
... ...
@@ -573,6 +506,76 @@ function configure_tempest {
573 573
         iniset $TEMPEST_CONFIG service_available cinder "False"
574 574
     fi
575 575
 
576
+    # Run tempest configuration utilities. This must be done last during configuration to
577
+    # ensure as complete a config as possible already exists
578
+
579
+    # NOTE(mtreinish): Respect constraints on tempest verify-config venv
580
+    local tmp_cfg_file
581
+    tmp_cfg_file=$(mktemp)
582
+    cd $TEMPEST_DIR
583
+    if [[ "$OFFLINE" != "True" ]]; then
584
+        tox -revenv --notest
585
+    fi
586
+    tox -evenv -- pip install -c $REQUIREMENTS_DIR/upper-constraints.txt -r requirements.txt
587
+
588
+    # Auth:
589
+    iniset $TEMPEST_CONFIG auth tempest_roles "Member"
590
+    if [[ $TEMPEST_USE_TEST_ACCOUNTS == "True" ]]; then
591
+        if [[ $TEMPEST_HAS_ADMIN == "True" ]]; then
592
+            tox -evenv -- tempest-account-generator -c $TEMPEST_CONFIG --os-username $admin_username --os-password "$password" --os-tenant-name $admin_project_name -r $TEMPEST_CONCURRENCY --with-admin etc/accounts.yaml
593
+        else
594
+            tox -evenv -- tempest-account-generator -c $TEMPEST_CONFIG --os-username $admin_username --os-password "$password" --os-tenant-name $admin_project_name -r $TEMPEST_CONCURRENCY etc/accounts.yaml
595
+        fi
596
+        iniset $TEMPEST_CONFIG auth use_dynamic_credentials False
597
+        iniset $TEMPEST_CONFIG auth test_accounts_file "etc/accounts.yaml"
598
+    elif [[ $TEMPEST_HAS_ADMIN == "False" ]]; then
599
+        iniset $TEMPEST_CONFIG auth use_dynamic_credentials ${TEMPEST_ALLOW_TENANT_ISOLATION:-False}
600
+
601
+    else
602
+        iniset $TEMPEST_CONFIG auth use_dynamic_credentials ${TEMPEST_ALLOW_TENANT_ISOLATION:-True}
603
+    fi
604
+
605
+    # API Extensions
606
+    # Run ``verify_tempest_config -ur`` to retrieve enabled extensions on API endpoints
607
+    # NOTE(mtreinish): This must be done after auth settings are added to the tempest config
608
+    tox -evenv -- tempest verify-config -uro $tmp_cfg_file
609
+    # Nova API extensions
610
+    local compute_api_extensions=${COMPUTE_API_EXTENSIONS:-"all"}
611
+    if [[ ! -z "$DISABLE_COMPUTE_API_EXTENSIONS" ]]; then
612
+        # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
613
+        compute_api_extensions=${COMPUTE_API_EXTENSIONS:-$(iniget $tmp_cfg_file compute-feature-enabled api_extensions | tr -d " ")}
614
+        # Remove disabled extensions
615
+        compute_api_extensions=$(remove_disabled_extensions $compute_api_extensions $DISABLE_COMPUTE_API_EXTENSIONS)
616
+    fi
617
+    iniset $TEMPEST_CONFIG compute-feature-enabled api_extensions $compute_api_extensions
618
+    # Neutron API Extensions
619
+    local network_api_extensions=${NETWORK_API_EXTENSIONS:-"all"}
620
+    if [[ ! -z "$DISABLE_NETWORK_API_EXTENSIONS" ]]; then
621
+        # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
622
+        network_api_extensions=${NETWORK_API_EXTENSIONS:-$(iniget $tmp_cfg_file network-feature-enabled api_extensions | tr -d " ")}
623
+        # Remove disabled extensions
624
+        network_api_extensions=$(remove_disabled_extensions $network_api_extensions $DISABLE_NETWORK_API_EXTENSIONS)
625
+    fi
626
+    iniset $TEMPEST_CONFIG network-feature-enabled api_extensions $network_api_extensions
627
+    # Swift API Extensions
628
+    local object_storage_api_extensions=${OBJECT_STORAGE_API_EXTENSIONS:-"all"}
629
+    if [[ ! -z "$DISABLE_OBJECT_STORAGE_API_EXTENSIONS" ]]; then
630
+        # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
631
+        object_storage_api_extensions=${OBJECT_STORAGE_API_EXTENSIONS:-$(iniget $tmp_cfg_file object-storage-feature-enabled discoverable_apis | tr -d " ")}
632
+        # Remove disabled extensions
633
+        object_storage_api_extensions=$(remove_disabled_extensions $object_storage_api_extensions $DISABLE_STORAGE_API_EXTENSIONS)
634
+    fi
635
+    iniset $TEMPEST_CONFIG object-storage-feature-enabled discoverable_apis $object_storage_api_extensions
636
+    # Cinder API Extensions
637
+    local volume_api_extensions=${VOLUME_API_EXTENSIONS:-"all"}
638
+    if [[ ! -z "$DISABLE_VOLUME_API_EXTENSIONS" ]]; then
639
+        # Enabled extensions are either the ones explicitly specified or those available on the API endpoint
640
+        volume_api_extensions=${VOLUME_API_EXTENSIONS:-$(iniget $tmp_cfg_file volume-feature-enabled api_extensions | tr -d " ")}
641
+        # Remove disabled extensions
642
+        volume_api_extensions=$(remove_disabled_extensions $volume_api_extensions $DISABLE_VOLUME_API_EXTENSIONS)
643
+    fi
644
+    iniset $TEMPEST_CONFIG volume-feature-enabled api_extensions $volume_api_extensions
645
+
576 646
     # Restore IFS
577 647
     IFS=$ifs
578 648
 }