From c7ab4e82afc4cf3fa7d130ecaad5ace18eb46852 Mon Sep 17 00:00:00 2001 From: Rakesh H S Date: Thu, 18 Feb 2016 18:54:00 +0530 Subject: [PATCH] Fix test_encryption_vol_type to take admin creds from conf Heat integration test test_encryption_vol_type will not work in environments where admin user is named differently or does not have the same password as that of the demo user. The admin credentials is now made available via heat_integrationtests.conf. The tests which require admin privileges should be run only if admin credentials are available and use the same. Change-Id: I5f329be6d4c4249763e0aec8696fb87605a0812a Closes-Bug: #1546993 --- heat_integrationtests/common/config.py | 9 +++++++-- .../functional/test_encryption_vol_type.py | 7 +++++-- .../heat_integrationtests.conf.sample | 10 ++++++++-- heat_integrationtests/prepare_test_env.sh | 3 +++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/heat_integrationtests/common/config.py b/heat_integrationtests/common/config.py index 39c084681a..6d3560026e 100644 --- a/heat_integrationtests/common/config.py +++ b/heat_integrationtests/common/config.py @@ -21,10 +21,15 @@ IntegrationTestGroup = [ cfg.StrOpt('username', default=os.environ.get('OS_USERNAME'), - help="Username to use for API requests."), + help="Username to use for non admin API requests."), cfg.StrOpt('password', default=os.environ.get('OS_PASSWORD'), - help="API key to use when authenticating.", + help="Non admin API key to use when authenticating.", + secret=True), + cfg.StrOpt('admin_username', + help="Username to use for admin API requests."), + cfg.StrOpt('admin_password', + help="Admin API key to use when authentication.", secret=True), cfg.StrOpt('tenant_name', default=(os.environ.get('OS_PROJECT_NAME') or diff --git a/heat_integrationtests/functional/test_encryption_vol_type.py b/heat_integrationtests/functional/test_encryption_vol_type.py index e1a3e769b1..2679990dbf 100644 --- a/heat_integrationtests/functional/test_encryption_vol_type.py +++ b/heat_integrationtests/functional/test_encryption_vol_type.py @@ -42,11 +42,14 @@ test_encryption_vol_type = { class EncryptionVolTypeTest(functional_base.FunctionalTestsBase): def setUp(self): super(EncryptionVolTypeTest, self).setUp() + if not self.conf.admin_username or not self.conf.admin_password: + self.skipTest('No admin creds found, skipping') self.conf = config.init_conf() # cinder security policy usage of volume type is limited # to being used by administrators only. - # Temporarily set username as admin for this test case. - self.conf.username = 'admin' + # Temporarily switch to admin + self.conf.username = self.conf.admin_username + self.conf.password = self.conf.admin_password self.manager = clients.ClientManager(self.conf) self.client = self.manager.orchestration_client self.volume_client = self.manager.volume_client diff --git a/heat_integrationtests/heat_integrationtests.conf.sample b/heat_integrationtests/heat_integrationtests.conf.sample index 9941922003..19b13e1fe5 100644 --- a/heat_integrationtests/heat_integrationtests.conf.sample +++ b/heat_integrationtests/heat_integrationtests.conf.sample @@ -33,15 +33,21 @@ # Visible fixed network name (string value) #fixed_network_name = heat-net -# Username to use for API requests. (string value) +# Username to use for non admin API requests. (string value) #username = +# Username to use for admin API requests. (string value) +#admin_username = + # Visible floating network name (string value) #floating_network_name = public -# API key to use when authenticating. (string value) +# Non admin API key to use when authenticating. (string value) #password = +# Admin API key to use when authenticating. (string value) +#admin_password = + # Path to environment file which defines the resource type # Heat::InstallConfigAgent. Needs to be appropriate for the image_ref. (string # value) diff --git a/heat_integrationtests/prepare_test_env.sh b/heat_integrationtests/prepare_test_env.sh index 128b5a5e1c..78833922d4 100755 --- a/heat_integrationtests/prepare_test_env.sh +++ b/heat_integrationtests/prepare_test_env.sh @@ -36,6 +36,9 @@ iniset heat_integrationtests.conf DEFAULT image_ref fedora-heat-test-image iniset heat_integrationtests.conf DEFAULT boot_config_env $DEST/heat-templates/hot/software-config/boot-config/test_image_env.yaml iniset heat_integrationtests.conf DEFAULT heat_config_notify_script $DEST/heat-templates/hot/software-config/elements/heat-config/bin/heat-config-notify iniset heat_integrationtests.conf DEFAULT minimal_image_ref cirros-0.3.4-x86_64-uec +# admin creds already sourced, store in conf +iniset heat_integrationtests.conf DEFAULT admin_username $OS_USERNAME +iniset heat_integrationtests.conf DEFAULT admin_password $OS_PASSWORD # Add scenario tests to skip # VolumeBackupRestoreIntegrationTest skipped until failure rate can be reduced ref bug #1382300