Set enforce_type=True on config overrides in tests

This makes sure that type checking is done by oslo.config
on the test override values.

Change-Id: Ia8c1cb55fe98e9d06b9b9ff13e5c2d25aa67bff3
Closes-bug: #1517839
This commit is contained in:
Angus Salkeld 2016-04-11 10:52:22 +10:00
parent a607d38f63
commit 3ed5948b1c
39 changed files with 166 additions and 118 deletions

View File

@ -36,13 +36,13 @@ class KeystoneClientTest(common.HeatTestCase):
dummy_url = 'http://server.test:5000/v2.0' dummy_url = 'http://server.test:5000/v2.0'
cfg.CONF.set_override('auth_uri', dummy_url, cfg.CONF.set_override('auth_uri', dummy_url,
group='keystone_authtoken') group='keystone_authtoken', enforce_type=True)
cfg.CONF.set_override('admin_user', 'heat', cfg.CONF.set_override('admin_user', 'heat',
group='keystone_authtoken') group='keystone_authtoken', enforce_type=True)
cfg.CONF.set_override('admin_password', 'verybadpass', cfg.CONF.set_override('admin_password', 'verybadpass',
group='keystone_authtoken') group='keystone_authtoken', enforce_type=True)
cfg.CONF.set_override('admin_tenant_name', 'service', cfg.CONF.set_override('admin_tenant_name', 'service',
group='keystone_authtoken') group='keystone_authtoken', enforce_type=True)
self.addCleanup(self.m.VerifyAll) self.addCleanup(self.m.VerifyAll)
def _stubs_v2(self, method='token', auth_ok=True, trust_scoped=True, def _stubs_v2(self, method='token', auth_ok=True, trust_scoped=True,

View File

@ -64,7 +64,8 @@ cfg.CONF.import_opt('region_name_for_services', 'heat.common.config')
class CloudServersTest(common.HeatTestCase): class CloudServersTest(common.HeatTestCase):
def setUp(self): def setUp(self):
super(CloudServersTest, self).setUp() super(CloudServersTest, self).setUp()
cfg.CONF.set_override('region_name_for_services', 'RegionOne') cfg.CONF.set_override('region_name_for_services', 'RegionOne',
enforce_type=True)
self.ctx = utils.dummy_context() self.ctx = utils.dummy_context()
self.fc = fakes.FakeClient() self.fc = fakes.FakeClient()

View File

@ -49,10 +49,12 @@ sys.path.insert(0, ROOT)
sys.path.insert(0, BASE_DIR) sys.path.insert(0, BASE_DIR)
cfg.CONF.import_opt('plugin_dirs', 'heat.common.config') cfg.CONF.import_opt('plugin_dirs', 'heat.common.config')
cfg.CONF.set_override(name='plugin_dirs', override=PLUGIN_DIRS) cfg.CONF.set_override(name='plugin_dirs', override=PLUGIN_DIRS,
enforce_type=True)
cfg.CONF.import_opt('environment_dir', 'heat.common.config') cfg.CONF.import_opt('environment_dir', 'heat.common.config')
cfg.CONF.set_override(name='environment_dir', override=TEMP_ENV_DIR) cfg.CONF.set_override(name='environment_dir', override=TEMP_ENV_DIR,
enforce_type=True)
# This is required for ReadTheDocs.org, but isn't a bad idea anyway. # This is required for ReadTheDocs.org, but isn't a bad idea anyway.
os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_dashboard.settings' os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_dashboard.settings'

View File

@ -403,7 +403,7 @@ class EngineService(service.Service):
if ((cfg.CONF.database.max_overflow is None) or if ((cfg.CONF.database.max_overflow is None) or
(cfg.CONF.database.max_overflow < worker_pool_size)): (cfg.CONF.database.max_overflow < worker_pool_size)):
cfg.CONF.set_override('max_overflow', worker_pool_size, cfg.CONF.set_override('max_overflow', worker_pool_size,
group='database') group='database', enforce_type=True)
def _stop_rpc_server(self): def _stop_rpc_server(self):
# Stop rpc connection at first for preventing new requests # Stop rpc connection at first for preventing new requests

View File

@ -544,7 +544,7 @@ class Ec2TokenTest(common.HeatTestCase):
importutils.import_module('keystonemiddleware.auth_token') importutils.import_module('keystonemiddleware.auth_token')
dummy_url = 'http://123:5000/v2.0' dummy_url = 'http://123:5000/v2.0'
cfg.CONF.set_override('auth_uri', dummy_url, cfg.CONF.set_override('auth_uri', dummy_url,
group='keystone_authtoken') group='keystone_authtoken', enforce_type=True)
ec2 = ec2token.EC2Token(app='woot', conf={}) ec2 = ec2token.EC2Token(app='woot', conf={})
params = {'AWSAccessKeyId': 'foo', 'Signature': 'xyz'} params = {'AWSAccessKeyId': 'foo', 'Signature': 'xyz'}
req_env = {'SERVER_NAME': 'heat', req_env = {'SERVER_NAME': 'heat',

View File

@ -131,7 +131,7 @@ blarg: wibble
self.assertRaises(webob.exc.HTTPBadRequest, data.template) self.assertRaises(webob.exc.HTTPBadRequest, data.template)
def test_template_exceeds_max_template_size(self): def test_template_exceeds_max_template_size(self):
cfg.CONF.set_override('max_template_size', 10) cfg.CONF.set_override('max_template_size', 10, enforce_type=True)
template = json.dumps(['a'] * cfg.CONF.max_template_size) template = json.dumps(['a'] * cfg.CONF.max_template_size)
body = {'template': template} body = {'template': template}
data = stacks.InstantiationData(body) data = stacks.InstantiationData(body)
@ -1127,7 +1127,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_create_err_stack_bad_reqest(self, mock_enforce): def test_create_err_stack_bad_reqest(self, mock_enforce):
cfg.CONF.set_override('debug', True) cfg.CONF.set_override('debug', True, enforce_type=True)
template = {u'Foo': u'bar'} template = {u'Foo': u'bar'}
parameters = {u'InstanceType': u'm1.xlarge'} parameters = {u'InstanceType': u'm1.xlarge'}
body = {'template': template, body = {'template': template,

View File

@ -391,7 +391,7 @@ class JSONRequestDeserializerTest(common.HeatTestCase):
self.assertEqual(expected, actual) self.assertEqual(expected, actual)
def test_from_json_exceeds_max_json_mb(self): def test_from_json_exceeds_max_json_mb(self):
cfg.CONF.set_override('max_json_body_size', 10) cfg.CONF.set_override('max_json_body_size', 10, enforce_type=True)
body = json.dumps(['a'] * cfg.CONF.max_json_body_size) body = json.dumps(['a'] * cfg.CONF.max_json_body_size)
self.assertTrue(len(body) > cfg.CONF.max_json_body_size) self.assertTrue(len(body) > cfg.CONF.max_json_body_size)
error = self.assertRaises(exception.RequestLimitExceeded, error = self.assertRaises(exception.RequestLimitExceeded,

View File

@ -579,7 +579,8 @@ class InstancesTest(common.HeatTestCase):
def test_instance_create_with_stack_scheduler_hints(self): def test_instance_create_with_stack_scheduler_hints(self):
return_server = self.fc.servers.list()[1] return_server = self.fc.servers.list()[1]
sh.cfg.CONF.set_override('stack_scheduler_hints', True) sh.cfg.CONF.set_override('stack_scheduler_hints', True,
enforce_type=True)
# Unroll _create_test_instance, to enable check # Unroll _create_test_instance, to enable check
# for addition of heat ids (stack id, resource name) # for addition of heat ids (stack id, resource name)
stack_name = 'test_instance_create_with_stack_scheduler_hints' stack_name = 'test_instance_create_with_stack_scheduler_hints'

View File

@ -154,7 +154,8 @@ class LoadBalancerTest(common.HeatTestCase):
rsrc.validate()) rsrc.validate())
def test_loadbalancer_validate_badtemplate(self): def test_loadbalancer_validate_badtemplate(self):
cfg.CONF.set_override('loadbalancer_template', '/a/noexist/x.y') cfg.CONF.set_override('loadbalancer_template', '/a/noexist/x.y',
enforce_type=True)
rsrc = self.setup_loadbalancer() rsrc = self.setup_loadbalancer()
self.assertRaises(exception.StackValidationFailed, rsrc.validate) self.assertRaises(exception.StackValidationFailed, rsrc.validate)

View File

@ -181,7 +181,7 @@ class VolumeTest(vt_base.BaseVolumeTest):
def test_volume_create_error(self): def test_volume_create_error(self):
fv = vt_base.FakeVolume('creating') fv = vt_base.FakeVolume('creating')
stack_name = 'test_volume_create_error_stack' stack_name = 'test_volume_create_error_stack'
cfg.CONF.set_override('action_retry_limit', 0) cfg.CONF.set_override('action_retry_limit', 0, enforce_type=True)
self._mock_create_volume(fv, stack_name, final_status='error') self._mock_create_volume(fv, stack_name, final_status='error')
@ -607,7 +607,7 @@ class VolumeTest(vt_base.BaseVolumeTest):
def test_snapshot_no_volume(self): def test_snapshot_no_volume(self):
"""Test that backup does not start for failed resource.""" """Test that backup does not start for failed resource."""
stack_name = 'test_volume_snapshot_novol_stack' stack_name = 'test_volume_snapshot_novol_stack'
cfg.CONF.set_override('action_retry_limit', 0) cfg.CONF.set_override('action_retry_limit', 0, enforce_type=True)
fv = self._mock_create_volume(vt_base.FakeVolume('creating'), fv = self._mock_create_volume(vt_base.FakeVolume('creating'),
stack_name, stack_name,
final_status='error') final_status='error')
@ -663,7 +663,7 @@ class VolumeTest(vt_base.BaseVolumeTest):
def test_create_from_snapshot_error(self): def test_create_from_snapshot_error(self):
stack_name = 'test_volume_create_from_snap_err_stack' stack_name = 'test_volume_create_from_snap_err_stack'
cfg.CONF.set_override('action_retry_limit', 0) cfg.CONF.set_override('action_retry_limit', 0, enforce_type=True)
fv = vt_base.FakeVolume('restoring-backup') fv = vt_base.FakeVolume('restoring-backup')
fvbr = vt_base.FakeBackupRestore('vol-123') fvbr = vt_base.FakeBackupRestore('vol-123')

View File

@ -44,12 +44,14 @@ class ClientsTest(common.HeatTestCase):
def test_bad_cloud_backend(self): def test_bad_cloud_backend(self):
con = mock.Mock() con = mock.Mock()
cfg.CONF.set_override('cloud_backend', 'some.weird.object') cfg.CONF.set_override('cloud_backend', 'some.weird.object',
enforce_type=True)
exc = self.assertRaises(exception.Invalid, clients.Clients, con) exc = self.assertRaises(exception.Invalid, clients.Clients, con)
self.assertIn('Invalid cloud_backend setting in heat.conf detected', self.assertIn('Invalid cloud_backend setting in heat.conf detected',
six.text_type(exc)) six.text_type(exc))
cfg.CONF.set_override('cloud_backend', 'heat.engine.clients.Clients') cfg.CONF.set_override('cloud_backend', 'heat.engine.clients.Clients',
enforce_type=True)
exc = self.assertRaises(exception.Invalid, clients.Clients, con) exc = self.assertRaises(exception.Invalid, clients.Clients, con)
self.assertIn('Invalid cloud_backend setting in heat.conf detected', self.assertIn('Invalid cloud_backend setting in heat.conf detected',
six.text_type(exc)) six.text_type(exc))
@ -100,7 +102,7 @@ class ClientsTest(common.HeatTestCase):
def test_clients_get_heat_cfn_metadata_url_conf(self): def test_clients_get_heat_cfn_metadata_url_conf(self):
cfg.CONF.set_override('heat_metadata_server_url', cfg.CONF.set_override('heat_metadata_server_url',
'http://server.test:123') 'http://server.test:123', enforce_type=True)
obj = self._client_cfn_url() obj = self._client_cfn_url()
self.assertEqual("http://server.test:123/v1/", self.assertEqual("http://server.test:123/v1/",
obj.get_cfn_metadata_server_url()) obj.get_cfn_metadata_server_url())
@ -182,11 +184,11 @@ class ClientPluginTest(common.HeatTestCase):
plugin = FooClientsPlugin(con) plugin = FooClientsPlugin(con)
cfg.CONF.set_override('ca_file', '/tmp/bar', cfg.CONF.set_override('ca_file', '/tmp/bar',
group='clients_heat') group='clients_heat', enforce_type=True)
cfg.CONF.set_override('ca_file', '/tmp/foo', cfg.CONF.set_override('ca_file', '/tmp/foo',
group='clients') group='clients', enforce_type=True)
cfg.CONF.set_override('endpoint_type', 'internalURL', cfg.CONF.set_override('endpoint_type', 'internalURL',
group='clients') group='clients', enforce_type=True)
# check heat group # check heat group
self.assertEqual('/tmp/bar', self.assertEqual('/tmp/bar',
@ -357,7 +359,8 @@ class ClientPluginTest(common.HeatTestCase):
self.assertRaises(TypeError, client_plugin.ClientPlugin, c) self.assertRaises(TypeError, client_plugin.ClientPlugin, c)
def test_create_client_on_token_expiration(self): def test_create_client_on_token_expiration(self):
cfg.CONF.set_override('reauthentication_auth_method', 'trusts') cfg.CONF.set_override('reauthentication_auth_method', 'trusts',
enforce_type=True)
con = mock.Mock() con = mock.Mock()
con.auth_plugin.auth_ref.will_expire_soon.return_value = False con.auth_plugin.auth_ref.will_expire_soon.return_value = False
plugin = FooClientsPlugin(con) plugin = FooClientsPlugin(con)

View File

@ -55,10 +55,13 @@ class KeystoneClientTest(common.HeatTestCase):
self.m.StubOutWithMock(ks_auth, 'load_from_conf_options') self.m.StubOutWithMock(ks_auth, 'load_from_conf_options')
cfg.CONF.set_override('auth_uri', 'http://server.test:5000/v2.0', cfg.CONF.set_override('auth_uri', 'http://server.test:5000/v2.0',
group='keystone_authtoken') group='keystone_authtoken', enforce_type=True)
cfg.CONF.set_override('stack_user_domain_id', 'adomain123') cfg.CONF.set_override('stack_user_domain_id', 'adomain123',
cfg.CONF.set_override('stack_domain_admin', 'adminuser123') enforce_type=True)
cfg.CONF.set_override('stack_domain_admin_password', 'adminsecret') cfg.CONF.set_override('stack_domain_admin', 'adminuser123',
enforce_type=True)
cfg.CONF.set_override('stack_domain_admin_password', 'adminsecret',
enforce_type=True)
self.addCleanup(self.m.VerifyAll) self.addCleanup(self.m.VerifyAll)
@ -483,7 +486,8 @@ class KeystoneClientTest(common.HeatTestCase):
"""Test create_trust_context with existing trust_id.""" """Test create_trust_context with existing trust_id."""
self._stubs_v3(method='trust') self._stubs_v3(method='trust')
cfg.CONF.set_override('deferred_auth_method', 'trusts') cfg.CONF.set_override('deferred_auth_method', 'trusts',
enforce_type=True)
self.m.ReplayAll() self.m.ReplayAll()
ctx = utils.dummy_context() ctx = utils.dummy_context()
@ -513,9 +517,11 @@ class KeystoneClientTest(common.HeatTestCase):
project_id='42', project_id='42',
stub_trust_context=True) stub_trust_context=True)
cfg.CONF.set_override('deferred_auth_method', 'trusts') cfg.CONF.set_override('deferred_auth_method', 'trusts',
enforce_type=True)
if delegate_roles: if delegate_roles:
cfg.CONF.set_override('trusts_delegated_roles', delegate_roles) cfg.CONF.set_override('trusts_delegated_roles', delegate_roles,
enforce_type=True)
trustor_roles = ['heat_stack_owner', 'admin', '__member__'] trustor_roles = ['heat_stack_owner', 'admin', '__member__']
trustee_roles = delegate_roles or trustor_roles trustee_roles = delegate_roles or trustor_roles
@ -552,8 +558,10 @@ class KeystoneClientTest(common.HeatTestCase):
project_id='42', project_id='42',
stub_trust_context=True) stub_trust_context=True)
cfg.CONF.set_override('deferred_auth_method', 'trusts') cfg.CONF.set_override('deferred_auth_method', 'trusts',
cfg.CONF.set_override('trusts_delegated_roles', ['heat_stack_owner']) enforce_type=True)
cfg.CONF.set_override('trusts_delegated_roles', ['heat_stack_owner'],
enforce_type=True)
self.mock_ks_v3_client.trusts = self.m.CreateMockAnything() self.mock_ks_v3_client.trusts = self.m.CreateMockAnything()
self.mock_ks_v3_client.trusts.create( self.mock_ks_v3_client.trusts.create(
@ -606,7 +614,8 @@ class KeystoneClientTest(common.HeatTestCase):
"""Test consuming a trust when initializing.""" """Test consuming a trust when initializing."""
self._stubs_v3(method='trust') self._stubs_v3(method='trust')
cfg.CONF.set_override('deferred_auth_method', 'trusts') cfg.CONF.set_override('deferred_auth_method', 'trusts',
enforce_type=True)
self.m.ReplayAll() self.m.ReplayAll()
ctx = utils.dummy_context() ctx = utils.dummy_context()
@ -624,7 +633,8 @@ class KeystoneClientTest(common.HeatTestCase):
"""Test consuming a trust when initializing, error scoping.""" """Test consuming a trust when initializing, error scoping."""
self._stubs_v3(method='trust', trust_scoped=False) self._stubs_v3(method='trust', trust_scoped=False)
cfg.CONF.set_override('deferred_auth_method', 'trusts') cfg.CONF.set_override('deferred_auth_method', 'trusts',
enforce_type=True)
self.m.ReplayAll() self.m.ReplayAll()
ctx = utils.dummy_context() ctx = utils.dummy_context()
@ -641,7 +651,8 @@ class KeystoneClientTest(common.HeatTestCase):
"""Test consuming a trust when initializing, impersonation error.""" """Test consuming a trust when initializing, impersonation error."""
self._stubs_v3(method='trust', user_id='wrong_user_id') self._stubs_v3(method='trust', user_id='wrong_user_id')
cfg.CONF.set_override('deferred_auth_method', 'trusts') cfg.CONF.set_override('deferred_auth_method', 'trusts',
enforce_type=True)
self.m.ReplayAll() self.m.ReplayAll()
ctx = utils.dummy_context() ctx = utils.dummy_context()
@ -687,7 +698,8 @@ class KeystoneClientTest(common.HeatTestCase):
"""Test delete_trust when deleting trust.""" """Test delete_trust when deleting trust."""
self._stubs_v3() self._stubs_v3()
cfg.CONF.set_override('deferred_auth_method', 'trusts') cfg.CONF.set_override('deferred_auth_method', 'trusts',
enforce_type=True)
self.mock_ks_v3_client.trusts = self.m.CreateMockAnything() self.mock_ks_v3_client.trusts = self.m.CreateMockAnything()
self.mock_ks_v3_client.trusts.delete('atrust123').AndReturn(None) self.mock_ks_v3_client.trusts.delete('atrust123').AndReturn(None)
@ -701,7 +713,8 @@ class KeystoneClientTest(common.HeatTestCase):
"""Test delete_trust when trust already deleted.""" """Test delete_trust when trust already deleted."""
self._stubs_v3() self._stubs_v3()
cfg.CONF.set_override('deferred_auth_method', 'trusts') cfg.CONF.set_override('deferred_auth_method', 'trusts',
enforce_type=True)
self.mock_ks_v3_client.trusts = self.m.CreateMockAnything() self.mock_ks_v3_client.trusts = self.m.CreateMockAnything()
self.mock_ks_v3_client.trusts.delete('atrust123').AndRaise( self.mock_ks_v3_client.trusts.delete('atrust123').AndRaise(
kc_exception.NotFound) kc_exception.NotFound)
@ -1390,7 +1403,8 @@ class KeystoneClientTest(common.HeatTestCase):
Test that None value is passed as region name if region name is not Test that None value is passed as region name if region name is not
specified in the config file or as one of the arguments. specified in the config file or as one of the arguments.
""" """
cfg.CONF.set_override('region_name_for_services', None) cfg.CONF.set_override('region_name_for_services', None,
enforce_type=True)
service_url = 'http://example.com:1234/v1' service_url = 'http://example.com:1234/v1'
kwargs = { kwargs = {
'region_name': None 'region_name': None
@ -1403,7 +1417,8 @@ class KeystoneClientTest(common.HeatTestCase):
Test that region name passed as argument is not override by region name Test that region name passed as argument is not override by region name
specified in the config file. specified in the config file.
""" """
cfg.CONF.set_override('region_name_for_services', 'RegionOne') cfg.CONF.set_override('region_name_for_services', 'RegionOne',
enforce_type=True)
service_url = 'http://regiontwo.example.com:1234/v1' service_url = 'http://regiontwo.example.com:1234/v1'
kwargs = { kwargs = {
'region_name': 'RegionTwo' 'region_name': 'RegionTwo'
@ -1418,7 +1433,7 @@ class KeystoneClientTest(common.HeatTestCase):
""" """
region_name_for_services = 'RegionOne' region_name_for_services = 'RegionOne'
cfg.CONF.set_override('region_name_for_services', cfg.CONF.set_override('region_name_for_services',
region_name_for_services) region_name_for_services, enforce_type=True)
kwargs = { kwargs = {
'region_name': region_name_for_services 'region_name': region_name_for_services
} }
@ -1431,7 +1446,8 @@ class KeystoneClientTest(common.HeatTestCase):
Test that default region name for services from context is passed Test that default region name for services from context is passed
if region name is not specified in arguments. if region name is not specified in arguments.
""" """
cfg.CONF.set_override('region_name_for_services', 'RegionOne') cfg.CONF.set_override('region_name_for_services', 'RegionOne',
enforce_type=True)
service_url = 'http://regiontwo.example.com:1234/v1' service_url = 'http://regiontwo.example.com:1234/v1'
region_name_for_services = 'RegionTwo' region_name_for_services = 'RegionTwo'
expected_kwargs = { expected_kwargs = {
@ -1449,7 +1465,8 @@ class KeystoneClientTest(common.HeatTestCase):
class KeystoneClientTestDomainName(KeystoneClientTest): class KeystoneClientTestDomainName(KeystoneClientTest):
def setUp(self): def setUp(self):
cfg.CONF.set_override('stack_user_domain_name', 'fake_domain_name') cfg.CONF.set_override('stack_user_domain_name', 'fake_domain_name',
enforce_type=True)
super(KeystoneClientTestDomainName, self).setUp() super(KeystoneClientTestDomainName, self).setUp()
cfg.CONF.clear_override('stack_user_domain_id') cfg.CONF.clear_override('stack_user_domain_id')

View File

@ -392,13 +392,14 @@ class NovaClientPluginUserdataTest(NovaClientPluginTestCase):
def test_build_userdata(self): def test_build_userdata(self):
"""Tests the build_userdata function.""" """Tests the build_userdata function."""
cfg.CONF.set_override('heat_metadata_server_url', cfg.CONF.set_override('heat_metadata_server_url',
'http://server.test:123') 'http://server.test:123', enforce_type=True)
cfg.CONF.set_override('heat_watch_server_url', cfg.CONF.set_override('heat_watch_server_url',
'http://server.test:345') 'http://server.test:345', enforce_type=True)
cfg.CONF.set_override('instance_connection_is_secure', cfg.CONF.set_override('instance_connection_is_secure',
False) False, enforce_type=True)
cfg.CONF.set_override( cfg.CONF.set_override(
'instance_connection_https_validate_certificates', False) 'instance_connection_https_validate_certificates', False,
enforce_type=True)
data = self.nova_plugin.build_userdata({}) data = self.nova_plugin.build_userdata({})
self.assertIn("Content-Type: text/cloud-config;", data) self.assertIn("Content-Type: text/cloud-config;", data)
self.assertIn("Content-Type: text/cloud-boothook;", data) self.assertIn("Content-Type: text/cloud-boothook;", data)
@ -412,9 +413,9 @@ class NovaClientPluginUserdataTest(NovaClientPluginTestCase):
def test_build_userdata_without_instance_user(self): def test_build_userdata_without_instance_user(self):
"""Don't add a custom instance user when not requested.""" """Don't add a custom instance user when not requested."""
cfg.CONF.set_override('heat_metadata_server_url', cfg.CONF.set_override('heat_metadata_server_url',
'http://server.test:123') 'http://server.test:123', enforce_type=True)
cfg.CONF.set_override('heat_watch_server_url', cfg.CONF.set_override('heat_watch_server_url',
'http://server.test:345') 'http://server.test:345', enforce_type=True)
data = self.nova_plugin.build_userdata({}, instance_user=None) data = self.nova_plugin.build_userdata({}, instance_user=None)
self.assertNotIn('user: ', data) self.assertNotIn('user: ', data)
self.assertNotIn('useradd', data) self.assertNotIn('useradd', data)
@ -423,9 +424,9 @@ class NovaClientPluginUserdataTest(NovaClientPluginTestCase):
def test_build_userdata_with_instance_user(self): def test_build_userdata_with_instance_user(self):
"""Add a custom instance user.""" """Add a custom instance user."""
cfg.CONF.set_override('heat_metadata_server_url', cfg.CONF.set_override('heat_metadata_server_url',
'http://server.test:123') 'http://server.test:123', enforce_type=True)
cfg.CONF.set_override('heat_watch_server_url', cfg.CONF.set_override('heat_watch_server_url',
'http://server.test:345') 'http://server.test:345', enforce_type=True)
data = self.nova_plugin.build_userdata({}, instance_user='ec2-user') data = self.nova_plugin.build_userdata({}, instance_user='ec2-user')
self.assertIn('user: ', data) self.assertIn('user: ', data)
self.assertIn('useradd', data) self.assertIn('useradd', data)

View File

@ -104,7 +104,7 @@ class HeatTestCase(testscenarios.WithScenarios,
'environment.d') 'environment.d')
cfg.CONF.set_default('environment_dir', env_dir) cfg.CONF.set_default('environment_dir', env_dir)
cfg.CONF.set_override('error_wait_time', None) cfg.CONF.set_override('error_wait_time', None, enforce_type=True)
self.addCleanup(cfg.CONF.reset) self.addCleanup(cfg.CONF.reset)
messaging.setup("fake://", optional=True) messaging.setup("fake://", optional=True)

View File

@ -599,7 +599,8 @@ class SqlAlchemyTest(common.HeatTestCase):
self.assertEqual(['id'], sort_keys) self.assertEqual(['id'], sort_keys)
def test_stack_get_all_hidden_tags(self): def test_stack_get_all_hidden_tags(self):
cfg.CONF.set_override('hidden_stack_tags', ['hidden']) cfg.CONF.set_override('hidden_stack_tags', ['hidden'],
enforce_type=True)
stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs] stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]
stacks[0].tags = ['hidden'] stacks[0].tags = ['hidden']
@ -709,7 +710,8 @@ class SqlAlchemyTest(common.HeatTestCase):
self.assertEqual(stacks[0].id, st_db[0].id) self.assertEqual(stacks[0].id, st_db[0].id)
def test_stack_get_all_by_tag_with_show_hidden(self): def test_stack_get_all_by_tag_with_show_hidden(self):
cfg.CONF.set_override('hidden_stack_tags', ['hidden']) cfg.CONF.set_override('hidden_stack_tags', ['hidden'],
enforce_type=True)
stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs] stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]
stacks[0].tags = ['tag1'] stacks[0].tags = ['tag1']
@ -746,7 +748,8 @@ class SqlAlchemyTest(common.HeatTestCase):
self.assertEqual(3, st_db) self.assertEqual(3, st_db)
def test_count_all_hidden_tags(self): def test_count_all_hidden_tags(self):
cfg.CONF.set_override('hidden_stack_tags', ['hidden']) cfg.CONF.set_override('hidden_stack_tags', ['hidden'],
enforce_type=True)
stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs] stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]
stacks[0].tags = ['hidden'] stacks[0].tags = ['hidden']
@ -776,7 +779,8 @@ class SqlAlchemyTest(common.HeatTestCase):
self.assertEqual(2, st_db) self.assertEqual(2, st_db)
def test_count_all_by_tag_with_show_hidden(self): def test_count_all_by_tag_with_show_hidden(self):
cfg.CONF.set_override('hidden_stack_tags', ['hidden']) cfg.CONF.set_override('hidden_stack_tags', ['hidden'],
enforce_type=True)
stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs] stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]
stacks[0].tags = ['tag1'] stacks[0].tags = ['tag1']

View File

@ -55,7 +55,7 @@ class StackServiceAdoptTest(common.HeatTestCase):
return template, adopt_data return template, adopt_data
def test_stack_adopt_with_params(self): def test_stack_adopt_with_params(self):
cfg.CONF.set_override('enable_stack_adopt', True) cfg.CONF.set_override('enable_stack_adopt', True, enforce_type=True)
env = {'parameters': {"app_dbx": "test"}} env = {'parameters': {"app_dbx": "test"}}
template, adopt_data = self._get_adopt_data_and_template(env) template, adopt_data = self._get_adopt_data_and_template(env)
result = self.man.create_stack(self.ctx, "test_adopt_with_params", result = self.man.create_stack(self.ctx, "test_adopt_with_params",
@ -68,7 +68,7 @@ class StackServiceAdoptTest(common.HeatTestCase):
stack.raw_template.environment['parameters']) stack.raw_template.environment['parameters'])
def test_stack_adopt_saves_input_params(self): def test_stack_adopt_saves_input_params(self):
cfg.CONF.set_override('enable_stack_adopt', True) cfg.CONF.set_override('enable_stack_adopt', True, enforce_type=True)
env = {'parameters': {"app_dbx": "foo"}} env = {'parameters': {"app_dbx": "foo"}}
input_params = { input_params = {
"parameters": {"app_dbx": "bar"} "parameters": {"app_dbx": "bar"}
@ -84,7 +84,7 @@ class StackServiceAdoptTest(common.HeatTestCase):
stack.raw_template.environment['parameters']) stack.raw_template.environment['parameters'])
def test_stack_adopt_stack_state(self): def test_stack_adopt_stack_state(self):
cfg.CONF.set_override('enable_stack_adopt', True) cfg.CONF.set_override('enable_stack_adopt', True, enforce_type=True)
env = {'parameters': {"app_dbx": "test"}} env = {'parameters': {"app_dbx": "test"}}
template, adopt_data = self._get_adopt_data_and_template(env) template, adopt_data = self._get_adopt_data_and_template(env)
result = self.man.create_stack(self.ctx, "test_adopt_stack_state", result = self.man.create_stack(self.ctx, "test_adopt_stack_state",
@ -97,7 +97,7 @@ class StackServiceAdoptTest(common.HeatTestCase):
def test_stack_adopt_disabled(self): def test_stack_adopt_disabled(self):
# to test disable stack adopt # to test disable stack adopt
cfg.CONF.set_override('enable_stack_adopt', False) cfg.CONF.set_override('enable_stack_adopt', False, enforce_type=True)
env = {'parameters': {"app_dbx": "test"}} env = {'parameters': {"app_dbx": "test"}}
template, adopt_data = self._get_adopt_data_and_template(env) template, adopt_data = self._get_adopt_data_and_template(env)
ex = self.assertRaises( ex = self.assertRaises(

View File

@ -86,12 +86,12 @@ class StackCreateTest(common.HeatTestCase):
environment_files=environment_files) environment_files=environment_files)
def test_stack_create_equals_max_per_tenant(self): def test_stack_create_equals_max_per_tenant(self):
cfg.CONF.set_override('max_stacks_per_tenant', 1) cfg.CONF.set_override('max_stacks_per_tenant', 1, enforce_type=True)
stack_name = 'service_create_test_stack_equals_max' stack_name = 'service_create_test_stack_equals_max'
self._test_stack_create(stack_name) self._test_stack_create(stack_name)
def test_stack_create_exceeds_max_per_tenant(self): def test_stack_create_exceeds_max_per_tenant(self):
cfg.CONF.set_override('max_stacks_per_tenant', 0) cfg.CONF.set_override('max_stacks_per_tenant', 0, enforce_type=True)
stack_name = 'service_create_test_stack_exceeds_max' stack_name = 'service_create_test_stack_exceeds_max'
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self._test_stack_create, stack_name) self._test_stack_create, stack_name)
@ -240,7 +240,7 @@ class StackCreateTest(common.HeatTestCase):
return_value=stk.env) return_value=stk.env)
mock_stack = self.patchobject(stack, 'Stack', return_value=stk) mock_stack = self.patchobject(stack, 'Stack', return_value=stk)
cfg.CONF.set_override('max_resources_per_stack', 3) cfg.CONF.set_override('max_resources_per_stack', 3, enforce_type=True)
result = self.man.create_stack(self.ctx, stack_name, template, params, result = self.man.create_stack(self.ctx, stack_name, template, params,
None, {}) None, {})
@ -272,7 +272,7 @@ class StackCreateTest(common.HeatTestCase):
} }
} }
cfg.CONF.set_override('max_resources_per_stack', 2) cfg.CONF.set_override('max_resources_per_stack', 2, enforce_type=True)
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.man.create_stack, self.ctx, stack_name, self.man.create_stack, self.ctx, stack_name,
tpl, params, None, {}) tpl, params, None, {})
@ -354,6 +354,6 @@ class StackCreateTest(common.HeatTestCase):
def test_stack_create_max_unlimited(self, total_res_mock, validate_mock): def test_stack_create_max_unlimited(self, total_res_mock, validate_mock):
total_res_mock.return_value = 9999 total_res_mock.return_value = 9999
validate_mock.return_value = None validate_mock.return_value = None
cfg.CONF.set_override('max_resources_per_stack', -1) cfg.CONF.set_override('max_resources_per_stack', -1, enforce_type=True)
stack_name = 'service_create_test_max_unlimited' stack_name = 'service_create_test_max_unlimited'
self._test_stack_create(stack_name) self._test_stack_create(stack_name)

View File

@ -444,7 +444,7 @@ class ServiceStackUpdateTest(common.HeatTestCase):
mock_validate = self.patchobject(stk, 'validate', return_value=None) mock_validate = self.patchobject(stk, 'validate', return_value=None)
# do update # do update
cfg.CONF.set_override('max_resources_per_stack', 3) cfg.CONF.set_override('max_resources_per_stack', 3, enforce_type=True)
api_args = {'timeout_mins': 60} api_args = {'timeout_mins': 60}
result = self.man.update_stack(self.ctx, old_stack.identifier(), result = self.man.update_stack(self.ctx, old_stack.identifier(),
@ -532,7 +532,7 @@ class ServiceStackUpdateTest(common.HeatTestCase):
sid = old_stack.store() sid = old_stack.store()
self.assertIsNotNone(sid) self.assertIsNotNone(sid)
cfg.CONF.set_override('max_resources_per_stack', 2) cfg.CONF.set_override('max_resources_per_stack', 2, enforce_type=True)
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.man.update_stack, self.ctx, self.man.update_stack, self.ctx,

View File

@ -997,7 +997,8 @@ class CinderVolumeTest(vt_base.BaseVolumeTest):
def test_cinder_create_with_stack_scheduler_hints(self): def test_cinder_create_with_stack_scheduler_hints(self):
fv = vt_base.FakeVolume('creating') fv = vt_base.FakeVolume('creating')
sh.cfg.CONF.set_override('stack_scheduler_hints', True) sh.cfg.CONF.set_override('stack_scheduler_hints', True,
enforce_type=True)
stack_name = 'test_cvolume_stack_scheduler_hints_stack' stack_name = 'test_cvolume_stack_scheduler_hints_stack'
t = template_format.parse(single_cinder_volume_template) t = template_format.parse(single_cinder_volume_template)

View File

@ -130,7 +130,7 @@ class RemoteStackTest(tests_common.HeatTestCase):
self.that_region = 'RegionTwo' self.that_region = 'RegionTwo'
self.bad_region = 'RegionNone' self.bad_region = 'RegionNone'
cfg.CONF.set_override('action_retry_limit', 0) cfg.CONF.set_override('action_retry_limit', 0, enforce_type=True)
self.parent = None self.parent = None
self.heat = None self.heat = None
self.client_plugin = None self.client_plugin = None

View File

@ -75,7 +75,7 @@ class TestMagnumBay(common.HeatTestCase):
self.assertEqual((b.CREATE, b.COMPLETE), b.state) self.assertEqual((b.CREATE, b.COMPLETE), b.state)
def test_bay_create_failed(self): def test_bay_create_failed(self):
cfg.CONF.set_override('action_retry_limit', 0) cfg.CONF.set_override('action_retry_limit', 0, enforce_type=True)
b = self._create_resource('bay', self.rsrc_defn, self.stack, b = self._create_resource('bay', self.rsrc_defn, self.stack,
stat='CREATE_FAILED') stat='CREATE_FAILED')
exc = self.assertRaises( exc = self.assertRaises(

View File

@ -430,7 +430,7 @@ class PoolTest(common.HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_create_failed_error_status(self): def test_create_failed_error_status(self):
cfg.CONF.set_override('action_retry_limit', 0) cfg.CONF.set_override('action_retry_limit', 0, enforce_type=True)
snippet = template_format.parse(pool_template) snippet = template_format.parse(pool_template)
self.stack = utils.parse_stack(snippet) self.stack = utils.parse_stack(snippet)

View File

@ -899,7 +899,8 @@ class ServersTest(common.HeatTestCase):
return_value=self.fc) return_value=self.fc)
return_server = self.fc.servers.list()[1] return_server = self.fc.servers.list()[1]
return_server.id = '5678' return_server.id = '5678'
sh.cfg.CONF.set_override('stack_scheduler_hints', True) sh.cfg.CONF.set_override('stack_scheduler_hints', True,
enforce_type=True)
# Unroll _create_test_server, to enable check # Unroll _create_test_server, to enable check
# for addition of heat ids (stack id, resource name) # for addition of heat ids (stack id, resource name)
stack_name = 'test_server_w_stack_sched_hints_s' stack_name = 'test_server_w_stack_sched_hints_s'

View File

@ -111,7 +111,7 @@ class SaharaClusterTest(common.HeatTestCase):
self.cl_mgr.get.assert_called_once_with(self.fake_cl.id) self.cl_mgr.get.assert_called_once_with(self.fake_cl.id)
def test_cluster_create_fails(self): def test_cluster_create_fails(self):
cfg.CONF.set_override('action_retry_limit', 0) cfg.CONF.set_override('action_retry_limit', 0, enforce_type=True)
cluster = self._init_cluster(self.t) cluster = self._init_cluster(self.t)
self.cl_mgr.create.return_value = self.fake_cl self.cl_mgr.create.return_value = self.fake_cl
self.cl_mgr.get.return_value = FakeCluster(status='Error') self.cl_mgr.get.return_value = FakeCluster(status='Error')

View File

@ -117,7 +117,7 @@ class SenlinClusterTest(common.HeatTestCase):
self.senlin_mock.get_cluster.assert_called_once_with(self.fake_cl.id) self.senlin_mock.get_cluster.assert_called_once_with(self.fake_cl.id)
def test_cluster_create_error(self): def test_cluster_create_error(self):
cfg.CONF.set_override('action_retry_limit', 0) cfg.CONF.set_override('action_retry_limit', 0, enforce_type=True)
cluster = self._init_cluster(self.t) cluster = self._init_cluster(self.t)
self.senlin_mock.create_cluster.return_value = self.fake_cl self.senlin_mock.create_cluster.return_value = self.fake_cl
self.senlin_mock.get_cluster.return_value = FakeCluster( self.senlin_mock.get_cluster.return_value = FakeCluster(

View File

@ -102,7 +102,7 @@ class SenlinNodeTest(common.HeatTestCase):
self.senlin_mock.get_node.assert_called_once_with(self.fake_node.id) self.senlin_mock.get_node.assert_called_once_with(self.fake_node.id)
def test_node_create_error(self): def test_node_create_error(self):
cfg.CONF.set_override('action_retry_limit', 0) cfg.CONF.set_override('action_retry_limit', 0, enforce_type=True)
self.senlin_mock.create_node.return_value = self.fake_node self.senlin_mock.create_node.return_value = self.fake_node
self.senlin_mock.get_node.return_value = FakeNode( self.senlin_mock.get_node.return_value = FakeNode(
status='ERROR') status='ERROR')

View File

@ -108,7 +108,7 @@ class SenlinPolicyTest(common.HeatTestCase):
**expect_kwargs) **expect_kwargs)
def test_policy_create_fail(self): def test_policy_create_fail(self):
cfg.CONF.set_override('action_retry_limit', 0) cfg.CONF.set_override('action_retry_limit', 0, enforce_type=True)
policy = self._init_policy(self.t) policy = self._init_policy(self.t)
self.senlin_mock.create_policy.return_value = self.fake_p self.senlin_mock.create_policy.return_value = self.fake_p
self.senlin_mock.cluster_attach_policy.return_value = { self.senlin_mock.cluster_attach_policy.return_value = {

View File

@ -123,7 +123,7 @@ class TestRequestContext(common.HeatTestCase):
def test_keystone_v3_endpoint_in_context(self): def test_keystone_v3_endpoint_in_context(self):
"""Ensure that the context is the preferred source for the auth_uri.""" """Ensure that the context is the preferred source for the auth_uri."""
cfg.CONF.set_override('auth_uri', 'http://xyz', cfg.CONF.set_override('auth_uri', 'http://xyz',
group='clients_keystone') group='clients_keystone', enforce_type=True)
policy_check = 'heat.common.policy.Enforcer.check_is_admin' policy_check = 'heat.common.policy.Enforcer.check_is_admin'
with mock.patch(policy_check) as pc: with mock.patch(policy_check) as pc:
pc.return_value = False pc.return_value = False
@ -139,10 +139,10 @@ class TestRequestContext(common.HeatTestCase):
the preferred source when the context does not have the auth_uri. the preferred source when the context does not have the auth_uri.
""" """
cfg.CONF.set_override('auth_uri', 'http://xyz', cfg.CONF.set_override('auth_uri', 'http://xyz',
group='clients_keystone') group='clients_keystone', enforce_type=True)
importutils.import_module('keystonemiddleware.auth_token') importutils.import_module('keystonemiddleware.auth_token')
cfg.CONF.set_override('auth_uri', 'http://abc/v2.0', cfg.CONF.set_override('auth_uri', 'http://abc/v2.0',
group='keystone_authtoken') group='keystone_authtoken', enforce_type=True)
policy_check = 'heat.common.policy.Enforcer.check_is_admin' policy_check = 'heat.common.policy.Enforcer.check_is_admin'
with mock.patch(policy_check) as pc: with mock.patch(policy_check) as pc:
pc.return_value = False pc.return_value = False
@ -164,7 +164,7 @@ class TestRequestContext(common.HeatTestCase):
""" """
importutils.import_module('keystonemiddleware.auth_token') importutils.import_module('keystonemiddleware.auth_token')
cfg.CONF.set_override('auth_uri', 'http://abc/v2.0', cfg.CONF.set_override('auth_uri', 'http://abc/v2.0',
group='keystone_authtoken') group='keystone_authtoken', enforce_type=True)
policy_check = 'heat.common.policy.Enforcer.check_is_admin' policy_check = 'heat.common.policy.Enforcer.check_is_admin'
with mock.patch(policy_check) as pc: with mock.patch(policy_check) as pc:
pc.return_value = False pc.return_value = False
@ -187,11 +187,11 @@ class TestRequestContext(common.HeatTestCase):
def test_create_trusts_auth_plugin_with_correct_user_domain_id(self): def test_create_trusts_auth_plugin_with_correct_user_domain_id(self):
importutils.import_module('keystonemiddleware.auth_token') importutils.import_module('keystonemiddleware.auth_token')
cfg.CONF.set_override('auth_uri', 'http://abc/v2.0', cfg.CONF.set_override('auth_uri', 'http://abc/v2.0',
group='keystone_authtoken') group='keystone_authtoken', enforce_type=True)
cfg.CONF.set_override('admin_user', 'heat', cfg.CONF.set_override('admin_user', 'heat',
group='keystone_authtoken') group='keystone_authtoken', enforce_type=True)
cfg.CONF.set_override('admin_password', 'password', cfg.CONF.set_override('admin_password', 'password',
group='keystone_authtoken') group='keystone_authtoken', enforce_type=True)
policy_check = 'heat.common.policy.Enforcer.check_is_admin' policy_check = 'heat.common.policy.Enforcer.check_is_admin'
with mock.patch(policy_check) as pc: with mock.patch(policy_check) as pc:
pc.return_value = False pc.return_value = False

View File

@ -33,7 +33,7 @@ from heat.tests import utils
class StackConvergenceCreateUpdateDeleteTest(common.HeatTestCase): class StackConvergenceCreateUpdateDeleteTest(common.HeatTestCase):
def setUp(self): def setUp(self):
super(StackConvergenceCreateUpdateDeleteTest, self).setUp() super(StackConvergenceCreateUpdateDeleteTest, self).setUp()
cfg.CONF.set_override('convergence_engine', True) cfg.CONF.set_override('convergence_engine', True, enforce_type=True)
self.stack = None self.stack = None
@mock.patch.object(parser.Stack, 'mark_complete') @mock.patch.object(parser.Stack, 'mark_complete')
@ -530,7 +530,7 @@ class StackConvergenceCreateUpdateDeleteTest(common.HeatTestCase):
class TestConvgStackStateSet(common.HeatTestCase): class TestConvgStackStateSet(common.HeatTestCase):
def setUp(self): def setUp(self):
super(TestConvgStackStateSet, self).setUp() super(TestConvgStackStateSet, self).setUp()
cfg.CONF.set_override('convergence_engine', True) cfg.CONF.set_override('convergence_engine', True, enforce_type=True)
self.stack = tools.get_stack( self.stack = tools.get_stack(
'test_stack', utils.dummy_context(), 'test_stack', utils.dummy_context(),
template=tools.wp_template, convergence=True) template=tools.wp_template, convergence=True)

View File

@ -30,7 +30,8 @@ class CryptTest(common.HeatTestCase):
def test_init_auth_encryption_key_length(self): def test_init_auth_encryption_key_length(self):
"""Test for length of the auth_encryption_length in config file""" """Test for length of the auth_encryption_length in config file"""
cfg.CONF.set_override('auth_encryption_key', 'abcdefghijklma') cfg.CONF.set_override('auth_encryption_key', 'abcdefghijklma',
enforce_type=True)
err = self.assertRaises(exception.Error, err = self.assertRaises(exception.Error,
config.startup_sanity_check) config.startup_sanity_check)
exp_msg = ('heat.conf misconfigured, auth_encryption_key ' exp_msg = ('heat.conf misconfigured, auth_encryption_key '

View File

@ -209,7 +209,7 @@ class StackConvergenceServiceCreateUpdateTest(common.HeatTestCase):
def setUp(self): def setUp(self):
super(StackConvergenceServiceCreateUpdateTest, self).setUp() super(StackConvergenceServiceCreateUpdateTest, self).setUp()
cfg.CONF.set_override('convergence_engine', True) cfg.CONF.set_override('convergence_engine', True, enforce_type=True)
self.ctx = utils.dummy_context() self.ctx = utils.dummy_context()
self.man = service.EngineService('a-host', 'a-topic') self.man = service.EngineService('a-host', 'a-topic')
@ -829,7 +829,7 @@ class StackServiceTest(common.HeatTestCase):
@tools.stack_context('service_export_stack') @tools.stack_context('service_export_stack')
def test_export_stack(self): def test_export_stack(self):
cfg.CONF.set_override('enable_stack_abandon', True) cfg.CONF.set_override('enable_stack_abandon', True, enforce_type=True)
self.m.StubOutWithMock(parser.Stack, 'load') self.m.StubOutWithMock(parser.Stack, 'load')
parser.Stack.load(self.ctx, parser.Stack.load(self.ctx,
stack=mox.IgnoreArg()).AndReturn(self.stack) stack=mox.IgnoreArg()).AndReturn(self.stack)
@ -862,7 +862,7 @@ class StackServiceTest(common.HeatTestCase):
@tools.stack_context('service_abandon_stack') @tools.stack_context('service_abandon_stack')
def test_abandon_stack(self): def test_abandon_stack(self):
cfg.CONF.set_override('enable_stack_abandon', True) cfg.CONF.set_override('enable_stack_abandon', True, enforce_type=True)
self.m.StubOutWithMock(parser.Stack, 'load') self.m.StubOutWithMock(parser.Stack, 'load')
parser.Stack.load(self.ctx, parser.Stack.load(self.ctx,
stack=mox.IgnoreArg()).AndReturn(self.stack) stack=mox.IgnoreArg()).AndReturn(self.stack)
@ -1203,7 +1203,7 @@ class StackServiceTest(common.HeatTestCase):
@mock.patch.object(stack_object.Stack, 'count_all') @mock.patch.object(stack_object.Stack, 'count_all')
def test_validate_new_stack_checks_stack_limit(self, mock_db_count): def test_validate_new_stack_checks_stack_limit(self, mock_db_count):
cfg.CONF.set_override('max_stacks_per_tenant', 99) cfg.CONF.set_override('max_stacks_per_tenant', 99, enforce_type=True)
mock_db_count.return_value = 99 mock_db_count.return_value = 99
template = templatem.Template( template = templatem.Template(
{'HeatTemplateFormatVersion': '2012-12-12'}) {'HeatTemplateFormatVersion': '2012-12-12'})
@ -1238,7 +1238,7 @@ class StackServiceTest(common.HeatTestCase):
self.assertEqual(msg, six.text_type(ex)) self.assertEqual(msg, six.text_type(ex))
def test_validate_new_stack_checks_resource_limit(self): def test_validate_new_stack_checks_resource_limit(self):
cfg.CONF.set_override('max_resources_per_stack', 5) cfg.CONF.set_override('max_resources_per_stack', 5, enforce_type=True)
template = {'HeatTemplateFormatVersion': '2012-12-12', template = {'HeatTemplateFormatVersion': '2012-12-12',
'Resources': { 'Resources': {
'Res1': {'Type': 'GenericResource1'}, 'Res1': {'Type': 'GenericResource1'},
@ -1385,7 +1385,7 @@ class StackServiceTest(common.HeatTestCase):
self.assertEqual('FAILED', test_stack.resources.get('r3').status) self.assertEqual('FAILED', test_stack.resources.get('r3').status)
def test_parse_adopt_stack_data_without_parameters(self): def test_parse_adopt_stack_data_without_parameters(self):
cfg.CONF.set_override('enable_stack_adopt', True) cfg.CONF.set_override('enable_stack_adopt', True, enforce_type=True)
template = {"heat_template_version": "2015-04-30", template = {"heat_template_version": "2015-04-30",
"resources": { "resources": {
"myres": { "myres": {
@ -1410,7 +1410,7 @@ class StackServiceTest(common.HeatTestCase):
self.ctx, 'stack_name', template, {}, {}, None, args) self.ctx, 'stack_name', template, {}, {}, None, args)
def test_parse_adopt_stack_data_with_parameters(self): def test_parse_adopt_stack_data_with_parameters(self):
cfg.CONF.set_override('enable_stack_adopt', True) cfg.CONF.set_override('enable_stack_adopt', True, enforce_type=True)
template = {"heat_template_version": "2015-04-30", template = {"heat_template_version": "2015-04-30",
"parameters": { "parameters": {
"volsize": {"type": "number"} "volsize": {"type": "number"}

View File

@ -181,7 +181,8 @@ def constraint_mapping():
with open(plugin_file, 'w+') as ef: with open(plugin_file, 'w+') as ef:
ef.write(constraint_content) ef.write(constraint_content)
self.addCleanup(sys.modules.pop, "heat.engine.plugins.test") self.addCleanup(sys.modules.pop, "heat.engine.plugins.test")
cfg.CONF.set_override('plugin_dirs', plugin_dir.path) cfg.CONF.set_override('plugin_dirs', plugin_dir.path,
enforce_type=True)
env = environment.Environment({}) env = environment.Environment({})
resources._load_global_environment(env) resources._load_global_environment(env)
@ -200,7 +201,8 @@ def constraint_mapping():
with open(plugin_file, 'w+') as ef: with open(plugin_file, 'w+') as ef:
ef.write(constraint_content) ef.write(constraint_content)
self.addCleanup(sys.modules.pop, "heat.engine.plugins.test") self.addCleanup(sys.modules.pop, "heat.engine.plugins.test")
cfg.CONF.set_override('plugin_dirs', plugin_dir.path) cfg.CONF.set_override('plugin_dirs', plugin_dir.path,
enforce_type=True)
env = environment.Environment({}) env = environment.Environment({})
error = self.assertRaises(ValueError, error = self.assertRaises(ValueError,
@ -393,7 +395,8 @@ class GlobalEnvLoadingTest(common.HeatTestCase):
envfile = os.path.join(envdir.path, 'test.yaml') envfile = os.path.join(envdir.path, 'test.yaml')
with open(envfile, 'w+') as ef: with open(envfile, 'w+') as ef:
ef.write(g_env_content) ef.write(g_env_content)
cfg.CONF.set_override('environment_dir', envdir.path) cfg.CONF.set_override('environment_dir', envdir.path,
enforce_type=True)
# 2. load global env # 2. load global env
g_env = environment.Environment({}, user_env=False) g_env = environment.Environment({}, user_env=False)
@ -415,7 +418,8 @@ class GlobalEnvLoadingTest(common.HeatTestCase):
envfile = os.path.join(envdir.path, 'test.yaml') envfile = os.path.join(envdir.path, 'test.yaml')
with open(envfile, 'w+') as ef: with open(envfile, 'w+') as ef:
ef.write(g_env_content) ef.write(g_env_content)
cfg.CONF.set_override('environment_dir', envdir.path) cfg.CONF.set_override('environment_dir', envdir.path,
enforce_type=True)
# 2. load global env # 2. load global env
g_env = environment.Environment({}, user_env=False) g_env = environment.Environment({}, user_env=False)
@ -441,7 +445,8 @@ class GlobalEnvLoadingTest(common.HeatTestCase):
envfile = os.path.join(envdir.path, 'test.yaml') envfile = os.path.join(envdir.path, 'test.yaml')
with open(envfile, 'w+') as ef: with open(envfile, 'w+') as ef:
ef.write(g_env_content) ef.write(g_env_content)
cfg.CONF.set_override('environment_dir', envdir.path) cfg.CONF.set_override('environment_dir', envdir.path,
enforce_type=True)
# 2. load global env # 2. load global env
g_env = environment.Environment({}, user_env=False) g_env = environment.Environment({}, user_env=False)
@ -483,7 +488,8 @@ class GlobalEnvLoadingTest(common.HeatTestCase):
ef.write(g_env_content) ef.write(g_env_content)
with open(os.path.join(envdir.path, 'b.yaml'), 'w+') as ef: with open(os.path.join(envdir.path, 'b.yaml'), 'w+') as ef:
ef.write(g_env_content) ef.write(g_env_content)
cfg.CONF.set_override('environment_dir', envdir.path) cfg.CONF.set_override('environment_dir', envdir.path,
enforce_type=True)
# 2. load global env # 2. load global env
g_env = environment.Environment({}, user_env=False) g_env = environment.Environment({}, user_env=False)

View File

@ -172,8 +172,8 @@ class EventTest(EventCommon):
self.assertEqual({'Foo': 'goo'}, loaded_e.resource_properties) self.assertEqual({'Foo': 'goo'}, loaded_e.resource_properties)
def test_store_caps_events(self): def test_store_caps_events(self):
cfg.CONF.set_override('event_purge_batch_size', 1) cfg.CONF.set_override('event_purge_batch_size', 1, enforce_type=True)
cfg.CONF.set_override('max_events_per_stack', 1) cfg.CONF.set_override('max_events_per_stack', 1, enforce_type=True)
self.resource.resource_id_set('resource_physical_id') self.resource.resource_id_set('resource_physical_id')
e = event.Event(self.ctx, self.stack, 'TEST', 'IN_PROGRESS', 'Testing', e = event.Event(self.ctx, self.stack, 'TEST', 'IN_PROGRESS', 'Testing',

View File

@ -95,7 +95,7 @@ class FaultMiddlewareTest(common.HeatTestCase):
def test_exception_with_non_ascii_chars(self): def test_exception_with_non_ascii_chars(self):
# We set debug to true to test the code path for serializing traces too # We set debug to true to test the code path for serializing traces too
cfg.CONF.set_override('debug', True) cfg.CONF.set_override('debug', True, enforce_type=True)
msg = u'Error with non-ascii chars \x80' msg = u'Error with non-ascii chars \x80'
class TestException(heat_exc.HeatException): class TestException(heat_exc.HeatException):
@ -115,7 +115,7 @@ class FaultMiddlewareTest(common.HeatTestCase):
def test_remote_exception(self): def test_remote_exception(self):
# We want tracebacks # We want tracebacks
cfg.CONF.set_override('debug', True) cfg.CONF.set_override('debug', True, enforce_type=True)
error = heat_exc.EntityNotFound(entity='Stack', name='a') error = heat_exc.EntityNotFound(entity='Stack', name='a')
exc_info = (type(error), error, None) exc_info = (type(error), error, None)
serialized = rpc_common.serialize_remote_exception(exc_info) serialized = rpc_common.serialize_remote_exception(exc_info)
@ -222,7 +222,7 @@ class FaultMiddlewareTest(common.HeatTestCase):
def test_should_not_ignore_parent_classes_even_for_remote_ones(self): def test_should_not_ignore_parent_classes_even_for_remote_ones(self):
# We want tracebacks # We want tracebacks
cfg.CONF.set_override('debug', True) cfg.CONF.set_override('debug', True, enforce_type=True)
error = StackNotFoundChild(entity='Stack', name='a') error = StackNotFoundChild(entity='Stack', name='a')
exc_info = (type(error), error, None) exc_info = (type(error), error, None)

View File

@ -440,7 +440,7 @@ class ResourceTest(common.HeatTestCase):
res, utmpl = self._setup_resource_for_update( res, utmpl = self._setup_resource_for_update(
res_name='test_update_rsrc_in_progress_raises_exception') res_name='test_update_rsrc_in_progress_raises_exception')
cfg.CONF.set_override('convergence_engine', False) cfg.CONF.set_override('convergence_engine', False, enforce_type=True)
res.action = res.UPDATE res.action = res.UPDATE
res.status = res.IN_PROGRESS res.status = res.IN_PROGRESS
@ -795,7 +795,7 @@ class ResourceTest(common.HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
def test_create_fail_retry_disabled(self): def test_create_fail_retry_disabled(self):
cfg.CONF.set_override('action_retry_limit', 0) cfg.CONF.set_override('action_retry_limit', 0, enforce_type=True)
tmpl = rsrc_defn.ResourceDefinition('test_resource', 'Foo', tmpl = rsrc_defn.ResourceDefinition('test_resource', 'Foo',
{'Foo': 'abc'}) {'Foo': 'abc'})
res = generic_rsrc.ResourceWithProps('test_resource', tmpl, self.stack) res = generic_rsrc.ResourceWithProps('test_resource', tmpl, self.stack)
@ -1597,7 +1597,8 @@ class ResourceTest(common.HeatTestCase):
self.assertEqual({'foo': 'res', 'Foo': 'res'}, res.FnGetAtts()) self.assertEqual({'foo': 'res', 'Foo': 'res'}, res.FnGetAtts())
def test_properties_data_stored_encrypted_decrypted_on_load(self): def test_properties_data_stored_encrypted_decrypted_on_load(self):
cfg.CONF.set_override('encrypt_parameters_and_properties', True) cfg.CONF.set_override('encrypt_parameters_and_properties', True,
enforce_type=True)
tmpl = rsrc_defn.ResourceDefinition('test_resource', 'Foo') tmpl = rsrc_defn.ResourceDefinition('test_resource', 'Foo')
stored_properties_data = {'prop1': 'string', stored_properties_data = {'prop1': 'string',
@ -1641,7 +1642,8 @@ class ResourceTest(common.HeatTestCase):
self.assertEqual('string', res_obj.properties_data['prop1']) self.assertEqual('string', res_obj.properties_data['prop1'])
def test_properties_data_no_encryption(self): def test_properties_data_no_encryption(self):
cfg.CONF.set_override('encrypt_parameters_and_properties', False) cfg.CONF.set_override('encrypt_parameters_and_properties', False,
enforce_type=True)
tmpl = rsrc_defn.ResourceDefinition('test_resource', 'Foo') tmpl = rsrc_defn.ResourceDefinition('test_resource', 'Foo')
stored_properties_data = {'prop1': 'string', stored_properties_data = {'prop1': 'string',
@ -3571,7 +3573,7 @@ class TestLiveStateUpdate(common.HeatTestCase):
res = self._prepare_resource_live_state() res = self._prepare_resource_live_state()
res.resource_id = self.resource_id res.resource_id = self.resource_id
cfg.CONF.set_override('observe_on_update', True) cfg.CONF.set_override('observe_on_update', True, enforce_type=True)
utmpl = rsrc_defn.ResourceDefinition('test_resource', utmpl = rsrc_defn.ResourceDefinition('test_resource',
'ResourceWithPropsType', 'ResourceWithPropsType',

View File

@ -94,7 +94,8 @@ class StackTest(common.HeatTestCase):
self.assertEqual('', self.stack.status_reason) self.assertEqual('', self.stack.status_reason)
def test_timeout_secs_default(self): def test_timeout_secs_default(self):
cfg.CONF.set_override('stack_action_timeout', 1000) cfg.CONF.set_override('stack_action_timeout', 1000,
enforce_type=True)
self.stack = stack.Stack(self.ctx, 'test_stack', self.tmpl) self.stack = stack.Stack(self.ctx, 'test_stack', self.tmpl)
self.assertIsNone(self.stack.timeout_mins) self.assertIsNone(self.stack.timeout_mins)
self.assertEqual(1000, self.stack.timeout_secs()) self.assertEqual(1000, self.stack.timeout_secs())
@ -1332,7 +1333,8 @@ class StackTest(common.HeatTestCase):
def test_store_saves_creds_trust(self): def test_store_saves_creds_trust(self):
"""A user_creds entry is created on first stack store.""" """A user_creds entry is created on first stack store."""
cfg.CONF.set_override('deferred_auth_method', 'trusts') cfg.CONF.set_override('deferred_auth_method', 'trusts',
enforce_type=True)
self.m.StubOutWithMock(keystone.KeystoneClientPlugin, '_create') self.m.StubOutWithMock(keystone.KeystoneClientPlugin, '_create')
keystone.KeystoneClientPlugin._create().AndReturn( keystone.KeystoneClientPlugin._create().AndReturn(
@ -2294,7 +2296,8 @@ class StackTest(common.HeatTestCase):
env1 = environment.Environment({'param1': 'foo', 'param2': 'bar'}) env1 = environment.Environment({'param1': 'foo', 'param2': 'bar'})
self.stack = stack.Stack(self.ctx, 'test', self.stack = stack.Stack(self.ctx, 'test',
template.Template(tmpl, env=env1)) template.Template(tmpl, env=env1))
cfg.CONF.set_override('encrypt_parameters_and_properties', False) cfg.CONF.set_override('encrypt_parameters_and_properties', False,
enforce_type=True)
# Verify that hidden parameters stored in plain text # Verify that hidden parameters stored in plain text
self.stack.store() self.stack.store()
@ -2322,7 +2325,8 @@ class StackTest(common.HeatTestCase):
env1 = environment.Environment({'param1': 'foo', 'param2': 'bar'}) env1 = environment.Environment({'param1': 'foo', 'param2': 'bar'})
self.stack = stack.Stack(self.ctx, 'test', self.stack = stack.Stack(self.ctx, 'test',
template.Template(tmpl, env=env1)) template.Template(tmpl, env=env1))
cfg.CONF.set_override('encrypt_parameters_and_properties', True) cfg.CONF.set_override('encrypt_parameters_and_properties', True,
enforce_type=True)
# Verify that hidden parameters are stored encrypted # Verify that hidden parameters are stored encrypted
self.stack.store() self.stack.store()
@ -2378,7 +2382,8 @@ class StackTest(common.HeatTestCase):
env1 = environment.Environment({'param1': 'foo', 'param2': 'bar'}) env1 = environment.Environment({'param1': 'foo', 'param2': 'bar'})
self.stack = stack.Stack(self.ctx, 'test', self.stack = stack.Stack(self.ctx, 'test',
template.Template(tmpl, env=env1)) template.Template(tmpl, env=env1))
cfg.CONF.set_override('encrypt_parameters_and_properties', False) cfg.CONF.set_override('encrypt_parameters_and_properties', False,
enforce_type=True)
# Verify that hidden parameters are stored decrypted # Verify that hidden parameters are stored decrypted
self.stack.store() self.stack.store()

View File

@ -455,7 +455,8 @@ class StackResourceTest(StackResourceBaseTest):
self.assertEqual(4, rsrc.FnGetAtt(rsrc.CURRENT_SIZE)) self.assertEqual(4, rsrc.FnGetAtt(rsrc.CURRENT_SIZE))
def test__validate_nested_resources_checks_num_of_resources(self): def test__validate_nested_resources_checks_num_of_resources(self):
stack_resource.cfg.CONF.set_override('max_resources_per_stack', 2) stack_resource.cfg.CONF.set_override('max_resources_per_stack', 2,
enforce_type=True)
tmpl = {'HeatTemplateFormatVersion': '2012-12-12', tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
'Resources': [1]} 'Resources': [1]}
template = stack_resource.template.Template(tmpl) template = stack_resource.template.Template(tmpl)

View File

@ -97,7 +97,8 @@ class YamlMinimalTest(common.HeatTestCase):
def test_long_yaml(self): def test_long_yaml(self):
template = {'HeatTemplateFormatVersion': '2012-12-12'} template = {'HeatTemplateFormatVersion': '2012-12-12'}
config.cfg.CONF.set_override('max_template_size', 10) config.cfg.CONF.set_override('max_template_size', 10,
enforce_type=True)
template['Resources'] = ['a'] * int( template['Resources'] = ['a'] * int(
config.cfg.CONF.max_template_size / 3) config.cfg.CONF.max_template_size / 3)
limit = config.cfg.CONF.max_template_size limit = config.cfg.CONF.max_template_size

View File

@ -113,7 +113,7 @@ class UrlFetchTest(common.HeatTestCase):
url = 'http://example.com/template' url = 'http://example.com/template'
data = b'{ "foo": "bar" }' data = b'{ "foo": "bar" }'
response = Response(data) response = Response(data)
cfg.CONF.set_override('max_template_size', 500) cfg.CONF.set_override('max_template_size', 500, enforce_type=True)
requests.get(url, stream=True).AndReturn(response) requests.get(url, stream=True).AndReturn(response)
self.m.ReplayAll() self.m.ReplayAll()
urlfetch.get(url) urlfetch.get(url)
@ -123,7 +123,7 @@ class UrlFetchTest(common.HeatTestCase):
url = 'http://example.com/template' url = 'http://example.com/template'
data = b'{ "foo": "bar" }' data = b'{ "foo": "bar" }'
response = Response(data) response = Response(data)
cfg.CONF.set_override('max_template_size', 5) cfg.CONF.set_override('max_template_size', 5, enforce_type=True)
requests.get(url, stream=True).AndReturn(response) requests.get(url, stream=True).AndReturn(response)
self.m.ReplayAll() self.m.ReplayAll()
exception = self.assertRaises(urlfetch.URLFetchError, exception = self.assertRaises(urlfetch.URLFetchError,