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
This commit is contained in:
Rakesh H S 2016-02-18 18:54:00 +05:30
parent 714627b39b
commit c7ab4e82af
4 changed files with 23 additions and 6 deletions

View File

@ -21,10 +21,15 @@ IntegrationTestGroup = [
cfg.StrOpt('username', cfg.StrOpt('username',
default=os.environ.get('OS_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', cfg.StrOpt('password',
default=os.environ.get('OS_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), secret=True),
cfg.StrOpt('tenant_name', cfg.StrOpt('tenant_name',
default=(os.environ.get('OS_PROJECT_NAME') or default=(os.environ.get('OS_PROJECT_NAME') or

View File

@ -42,11 +42,14 @@ test_encryption_vol_type = {
class EncryptionVolTypeTest(functional_base.FunctionalTestsBase): class EncryptionVolTypeTest(functional_base.FunctionalTestsBase):
def setUp(self): def setUp(self):
super(EncryptionVolTypeTest, self).setUp() 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() self.conf = config.init_conf()
# cinder security policy usage of volume type is limited # cinder security policy usage of volume type is limited
# to being used by administrators only. # to being used by administrators only.
# Temporarily set username as admin for this test case. # Temporarily switch to admin
self.conf.username = 'admin' self.conf.username = self.conf.admin_username
self.conf.password = self.conf.admin_password
self.manager = clients.ClientManager(self.conf) self.manager = clients.ClientManager(self.conf)
self.client = self.manager.orchestration_client self.client = self.manager.orchestration_client
self.volume_client = self.manager.volume_client self.volume_client = self.manager.volume_client

View File

@ -33,15 +33,21 @@
# Visible fixed network name (string value) # Visible fixed network name (string value)
#fixed_network_name = heat-net #fixed_network_name = heat-net
# Username to use for API requests. (string value) # Username to use for non admin API requests. (string value)
#username = <None> #username = <None>
# Username to use for admin API requests. (string value)
#admin_username = <None>
# Visible floating network name (string value) # Visible floating network name (string value)
#floating_network_name = public #floating_network_name = public
# API key to use when authenticating. (string value) # Non admin API key to use when authenticating. (string value)
#password = <None> #password = <None>
# Admin API key to use when authenticating. (string value)
#admin_password = <None>
# Path to environment file which defines the resource type # Path to environment file which defines the resource type
# Heat::InstallConfigAgent. Needs to be appropriate for the image_ref. (string # Heat::InstallConfigAgent. Needs to be appropriate for the image_ref. (string
# value) # value)

View File

@ -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 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 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 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 # Add scenario tests to skip
# VolumeBackupRestoreIntegrationTest skipped until failure rate can be reduced ref bug #1382300 # VolumeBackupRestoreIntegrationTest skipped until failure rate can be reduced ref bug #1382300