summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Hardy <shardy@redhat.com>2013-10-11 12:01:05 +0100
committerSteven Hardy <shardy@redhat.com>2013-10-12 08:04:45 +0100
commit5f089b6a76a7a1d16964279b53f7313676f56674 (patch)
tree41d80491ebacd99df23d493b11f1d8806da2f3a2
parentb14f780a7822c24e6ed5d73d8b39c8bc28d099c2 (diff)
downloadheat-5f089b6a76a7a1d16964279b53f7313676f56674.tar.gz
Raise error if instances are created with names > 63 chars
The maximum hostname on Linux is 64 characters. DHCP is limited to this host maximum. Unfortunately Nova allows the creation of servers with names > 63 characters in length. This patch is a short-term solution to improve the failure condition, so we draw attention to the problem, enabling the user to work around with shorter names. A subsequent patch will be required which mangles names such that we truncate or compact names automatically. Closes-Bug: 1238272 Change-Id: I2114135b7f4b649a906c3adaea1869d1a1290a3b
-rw-r--r--heat/engine/resources/instance.py13
-rw-r--r--heat/engine/resources/server.py12
-rw-r--r--heat/tests/test_engine_service.py4
-rw-r--r--heat/tests/test_instance.py95
-rw-r--r--heat/tests/test_instance_network.py8
-rw-r--r--heat/tests/test_nokey.py2
-rw-r--r--heat/tests/test_server.py123
7 files changed, 156 insertions, 101 deletions
diff --git a/heat/engine/resources/instance.py b/heat/engine/resources/instance.py
index 10b9159d5..c4226f8e2 100644
--- a/heat/engine/resources/instance.py
+++ b/heat/engine/resources/instance.py
@@ -335,6 +335,19 @@ class Instance(resource.Resource):
security_groups=security_groups,
subnet_id=self.properties['SubnetId'])
server = None
+
+ # TODO(sdake/shardy) ensure physical_resource_name() never returns a
+ # string longer than 63 characters, as this is pretty inconvenient
+ # behavior for autoscaling groups and nested stacks where instance
+ # names can easily become quite long even with terse names.
+ physical_resource_name_len = len(self.physical_resource_name())
+ if physical_resource_name_len > 63:
+ raise exception.Error(_('Server %(server)s length %(length)d > 63'
+ ' characters, please reduce the length of'
+ ' stack or resource names') %
+ dict(server=self.physical_resource_name(),
+ length=physical_resource_name_len))
+
try:
server = self.nova().servers.create(
name=self.physical_resource_name(),
diff --git a/heat/engine/resources/server.py b/heat/engine/resources/server.py
index e2cc46e27..0b9981291 100644
--- a/heat/engine/resources/server.py
+++ b/heat/engine/resources/server.py
@@ -206,6 +206,18 @@ class Server(resource.Resource):
config_drive = self.properties.get('config_drive')
disk_config = self.properties.get('diskConfig')
+ # TODO(sdake/shardy) ensure physical_resource_name() never returns a
+ # string longer than 63 characters, as this is pretty inconvenient
+ # behavior for autoscaling groups and nested stacks where instance
+ # names can easily become quite long even with terse names.
+ physical_resource_name_len = len(self.physical_resource_name())
+ if physical_resource_name_len > 63:
+ raise exception.Error(_('Server %(server)s length %(length)d > 63'
+ ' characters, please reduce the length of'
+ ' stack or resource names') %
+ dict(server=self.physical_resource_name(),
+ length=physical_resource_name_len))
+
server = None
try:
server = self.nova().servers.create(
diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py
index 42e17163c..a617e248f 100644
--- a/heat/tests/test_engine_service.py
+++ b/heat/tests/test_engine_service.py
@@ -951,7 +951,7 @@ class StackServiceTest(HeatTestCase):
self.m.VerifyAll()
- @stack_context('service_event_list_deleted_resource_test_stack')
+ @stack_context('event_list_deleted_stack')
def test_stack_event_list_deleted_resource(self):
rsrs._register_class('GenericResourceType',
generic_rsrc.GenericResource)
@@ -1351,7 +1351,7 @@ class StackServiceTest(HeatTestCase):
self.eng.describe_stack_resources,
self.ctx, non_exist_identifier, 'WebServer')
- @stack_context('service_find_physical_resource_test_stack')
+ @stack_context('find_phys_res_stack')
def test_find_physical_resource(self):
resources = self.eng.describe_stack_resources(self.ctx,
self.stack.identifier(),
diff --git a/heat/tests/test_instance.py b/heat/tests/test_instance.py
index 1ce8564c8..9d3b29674 100644
--- a/heat/tests/test_instance.py
+++ b/heat/tests/test_instance.py
@@ -73,40 +73,42 @@ class InstancesTest(HeatTestCase):
stack_id=uuidutils.generate_uuid())
return (t, stack)
- def _setup_test_instance(self, return_server, name, image_id=None):
- stack_name = '%s_stack' % name
+ def _setup_test_instance(self, return_server, name, image_id=None,
+ stub_create=True):
+ stack_name = '%s_s' % name
(t, stack) = self._setup_test_stack(stack_name)
t['Resources']['WebServer']['Properties']['ImageId'] = \
image_id or 'CentOS 5.2'
t['Resources']['WebServer']['Properties']['InstanceType'] = \
'256 MB Server'
- instance = instances.Instance('%s_name' % name,
- t['Resources']['WebServer'], stack)
+ instance = instances.Instance(name, t['Resources']['WebServer'], stack)
self.m.StubOutWithMock(instance, 'nova')
instance.nova().MultipleTimes().AndReturn(self.fc)
instance.t = instance.stack.resolve_runtime_data(instance.t)
- # need to resolve the template functions
- server_userdata = nova_utils.build_userdata(
- instance,
- instance.t['Properties']['UserData'])
- instance.mime_string = server_userdata
- self.m.StubOutWithMock(self.fc.servers, 'create')
- self.fc.servers.create(
- image=1, flavor=1, key_name='test',
- name=utils.PhysName(stack_name, instance.name),
- security_groups=None,
- userdata=server_userdata, scheduler_hints=None,
- meta=None, nics=None, availability_zone=None).AndReturn(
- return_server)
+ if stub_create:
+ # need to resolve the template functions
+ server_userdata = nova_utils.build_userdata(
+ instance,
+ instance.t['Properties']['UserData'])
+ instance.mime_string = server_userdata
+ self.m.StubOutWithMock(self.fc.servers, 'create')
+ self.fc.servers.create(
+ image=1, flavor=1, key_name='test',
+ name=utils.PhysName(stack_name, instance.name),
+ security_groups=None,
+ userdata=server_userdata, scheduler_hints=None,
+ meta=None, nics=None, availability_zone=None).AndReturn(
+ return_server)
return instance
- def _create_test_instance(self, return_server, name):
- instance = self._setup_test_instance(return_server, name)
+ def _create_test_instance(self, return_server, name, stub_create=True):
+ instance = self._setup_test_instance(return_server, name,
+ stub_create=stub_create)
self.m.ReplayAll()
scheduler.TaskRunner(instance.create)()
return instance
@@ -114,7 +116,7 @@ class InstancesTest(HeatTestCase):
def test_instance_create(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
- 'test_instance_create')
+ 'in_create')
# this makes sure the auto increment worked on instance creation
self.assertTrue(instance.id > 0)
@@ -129,7 +131,7 @@ class InstancesTest(HeatTestCase):
def test_instance_create_with_image_id(self):
return_server = self.fc.servers.list()[1]
instance = self._setup_test_instance(return_server,
- 'test_instance_create_image_id',
+ 'in_create_imgid',
image_id='1')
self.m.StubOutWithMock(uuidutils, "is_uuid_like")
uuidutils.is_uuid_like('1').AndReturn(True)
@@ -245,7 +247,7 @@ class InstancesTest(HeatTestCase):
def test_instance_create_error_no_fault(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
- 'test_instance_create')
+ 'in_create')
return_server.status = 'ERROR'
self.m.StubOutWithMock(return_server, 'get')
@@ -264,6 +266,21 @@ class InstancesTest(HeatTestCase):
self.m.VerifyAll()
+ def test_instance_create_err_toolong(self):
+ # Attempt to create a server with a 64 character name should fail
+ # instance name is name_s-name-xxxxxxxxxxxx, so 24 characters gives
+ # a 64 character physical_resource_name
+ return_server = self.fc.servers.list()[1]
+ name = 'e' * 24
+ error = self.assertRaises(exception.ResourceFailure,
+ self._create_test_instance,
+ return_server,
+ name, stub_create=False)
+ substr = ('length 64 > 63 characters, '
+ 'please reduce the length of stack or resource names')
+ self.assertIn(substr, str(error))
+ self.m.VerifyAll()
+
def test_instance_validate(self):
stack_name = 'test_instance_validate_stack'
(t, stack) = self._setup_test_stack(stack_name)
@@ -287,7 +304,7 @@ class InstancesTest(HeatTestCase):
def test_instance_create_delete(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
- 'test_instance_create_delete')
+ 'in_cr_del')
instance.resource_id = 1234
# this makes sure the auto increment worked on instance creation
@@ -306,7 +323,7 @@ class InstancesTest(HeatTestCase):
def test_instance_update_metadata(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
- 'test_instance_update')
+ 'ud_md')
update_template = copy.deepcopy(instance.t)
update_template['Metadata'] = {'test': 123}
@@ -321,7 +338,7 @@ class InstancesTest(HeatTestCase):
return_server = self.fc.servers.list()[1]
return_server.id = 1234
instance = self._create_test_instance(return_server,
- 'test_instance_update')
+ 'ud_type')
update_template = copy.deepcopy(instance.t)
update_template['Properties']['InstanceType'] = 'm1.small'
@@ -352,7 +369,7 @@ class InstancesTest(HeatTestCase):
return_server = self.fc.servers.list()[1]
return_server.id = 1234
instance = self._create_test_instance(return_server,
- 'test_instance_update')
+ 'ud_type_f')
update_template = copy.deepcopy(instance.t)
update_template['Properties']['InstanceType'] = 'm1.small'
@@ -380,7 +397,7 @@ class InstancesTest(HeatTestCase):
def test_instance_update_replace(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
- 'test_instance_update')
+ 'in_update1')
update_template = copy.deepcopy(instance.t)
update_template['Notallowed'] = {'test': 123}
@@ -390,7 +407,7 @@ class InstancesTest(HeatTestCase):
def test_instance_update_properties(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
- 'test_instance_update')
+ 'in_update2')
update_template = copy.deepcopy(instance.t)
update_template['Properties']['KeyName'] = 'mustreplace'
@@ -400,7 +417,7 @@ class InstancesTest(HeatTestCase):
def test_instance_status_build(self):
return_server = self.fc.servers.list()[0]
instance = self._setup_test_instance(return_server,
- 'test_instance_status_build')
+ 'in_sts_build')
instance.resource_id = 1234
# Bind fake get method which Instance.check_create_complete will call
@@ -415,7 +432,7 @@ class InstancesTest(HeatTestCase):
def test_instance_status_suspend_immediate(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
- 'test_instance_suspend')
+ 'in_suspend')
instance.resource_id = 1234
self.m.ReplayAll()
@@ -436,7 +453,7 @@ class InstancesTest(HeatTestCase):
def test_instance_status_resume_immediate(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
- 'test_instance_resume')
+ 'in_resume')
instance.resource_id = 1234
self.m.ReplayAll()
@@ -458,7 +475,7 @@ class InstancesTest(HeatTestCase):
def test_instance_status_suspend_wait(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
- 'test_instance_suspend')
+ 'in_suspend_wait')
instance.resource_id = 1234
self.m.ReplayAll()
@@ -484,7 +501,7 @@ class InstancesTest(HeatTestCase):
def test_instance_status_resume_wait(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
- 'test_instance_resume')
+ 'in_resume_wait')
instance.resource_id = 1234
self.m.ReplayAll()
@@ -512,7 +529,7 @@ class InstancesTest(HeatTestCase):
def test_instance_suspend_volumes_step(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
- 'test_instance_suspend')
+ 'in_suspend_vol')
instance.resource_id = 1234
self.m.ReplayAll()
@@ -541,7 +558,7 @@ class InstancesTest(HeatTestCase):
def test_instance_resume_volumes_step(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
- 'test_instance_resume')
+ 'in_resume_vol')
instance.resource_id = 1234
self.m.ReplayAll()
@@ -603,7 +620,7 @@ class InstancesTest(HeatTestCase):
def _test_instance_status_not_build_active(self, uncommon_status):
return_server = self.fc.servers.list()[0]
instance = self._setup_test_instance(return_server,
- 'test_instance_status_build')
+ 'in_sts_bld')
instance.resource_id = 1234
# Bind fake get method which Instance.check_create_complete will call
@@ -627,7 +644,7 @@ class InstancesTest(HeatTestCase):
def test_build_nics(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
- 'test_build_nics')
+ 'build_nics')
self.assertEqual(None, instance._build_nics([]))
self.assertEqual(None, instance._build_nics(None))
@@ -664,7 +681,7 @@ class InstancesTest(HeatTestCase):
"""
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
- 'test_build_nics')
+ 'build_nics2')
security_groups = ['security_group_1']
self._test_security_groups(instance, security_groups)
@@ -770,6 +787,6 @@ class InstancesTest(HeatTestCase):
def test_instance_without_ip_address(self):
return_server = self.fc.servers.list()[3]
instance = self._create_test_instance(return_server,
- 'test_without_ip_address')
+ 'wo_ipaddr')
self.assertEqual(instance.FnGetAtt('PrivateIp'), '0.0.0.0')
diff --git a/heat/tests/test_instance_network.py b/heat/tests/test_instance_network.py
index b0f681cb2..2cea63e07 100644
--- a/heat/tests/test_instance_network.py
+++ b/heat/tests/test_instance_network.py
@@ -151,7 +151,7 @@ class instancesTest(HeatTestCase):
utils.setup_dummy_db()
def _create_test_instance(self, return_server, name):
- stack_name = '%s_stack' % name
+ stack_name = '%s_s' % name
t = template_format.parse(wp_template)
template = parser.Template(t)
kwargs = {'KeyName': 'test',
@@ -193,7 +193,7 @@ class instancesTest(HeatTestCase):
return instance
def _create_test_instance_with_nic(self, return_server, name):
- stack_name = '%s_stack' % name
+ stack_name = '%s_s' % name
t = template_format.parse(wp_template_with_nic)
template = parser.Template(t)
kwargs = {'KeyName': 'test',
@@ -247,7 +247,7 @@ class instancesTest(HeatTestCase):
def test_instance_create(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
- 'test_instance_create')
+ 'in_create')
# this makes sure the auto increment worked on instance creation
self.assertTrue(instance.id > 0)
@@ -262,7 +262,7 @@ class instancesTest(HeatTestCase):
def test_instance_create_with_nic(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance_with_nic(
- return_server, 'test_instance_create_with_network_interface')
+ return_server, 'in_create_wnic')
# this makes sure the auto increment worked on instance creation
self.assertTrue(instance.id > 0)
diff --git a/heat/tests/test_nokey.py b/heat/tests/test_nokey.py
index 790e5075d..450538077 100644
--- a/heat/tests/test_nokey.py
+++ b/heat/tests/test_nokey.py
@@ -48,7 +48,7 @@ class nokeyTest(HeatTestCase):
def test_nokey_create(self):
- stack_name = 'instance_create_test_nokey_stack'
+ stack_name = 's_nokey'
t = template_format.parse(nokey_template)
stack = utils.parse_stack(t, stack_name=stack_name)
diff --git a/heat/tests/test_server.py b/heat/tests/test_server.py
index 388181985..cae806615 100644
--- a/heat/tests/test_server.py
+++ b/heat/tests/test_server.py
@@ -70,8 +70,8 @@ class ServersTest(HeatTestCase):
return (t, stack)
def _setup_test_server(self, return_server, name, image_id=None,
- override_name=False):
- stack_name = '%s_stack' % name
+ override_name=False, stub_create=True):
+ stack_name = '%s_s' % name
(t, stack) = self._setup_test_stack(stack_name)
t['Resources']['WebServer']['Properties']['image'] = \
@@ -79,7 +79,7 @@ class ServersTest(HeatTestCase):
t['Resources']['WebServer']['Properties']['flavor'] = \
'256 MB Server'
- server_name = '%s_name' % name
+ server_name = '%s' % name
if override_name:
t['Resources']['WebServer']['Properties']['name'] = \
server_name
@@ -92,27 +92,25 @@ class ServersTest(HeatTestCase):
server.t = server.stack.resolve_runtime_data(server.t)
- # need to resolve the template functions
- #server_userdata = nova_utils.build_userdata(
- # server,
- # server.t['Properties']['user_data'])
- #server.mime_string = server_userdata
- self.m.StubOutWithMock(self.fc.servers, 'create')
- self.fc.servers.create(
- image=1, flavor=1, key_name='test',
- name=override_name and server.name or utils.PhysName(
- stack_name, server.name),
- security_groups=None,
- userdata=mox.IgnoreArg(), scheduler_hints=None,
- meta=None, nics=None, availability_zone=None,
- block_device_mapping=None, config_drive=None,
- disk_config=None, reservation_id=None).AndReturn(
- return_server)
+ if stub_create:
+ self.m.StubOutWithMock(self.fc.servers, 'create')
+ self.fc.servers.create(
+ image=1, flavor=1, key_name='test',
+ name=override_name and server.name or utils.PhysName(
+ stack_name, server.name),
+ security_groups=None,
+ userdata=mox.IgnoreArg(), scheduler_hints=None,
+ meta=None, nics=None, availability_zone=None,
+ block_device_mapping=None, config_drive=None,
+ disk_config=None, reservation_id=None).AndReturn(
+ return_server)
return server
- def _create_test_server(self, return_server, name, override_name=False):
- server = self._setup_test_server(return_server, name)
+ def _create_test_server(self, return_server, name, override_name=False,
+ stub_create=True):
+ server = self._setup_test_server(return_server, name,
+ stub_create=stub_create)
self.m.ReplayAll()
scheduler.TaskRunner(server.create)()
return server
@@ -144,6 +142,21 @@ class ServersTest(HeatTestCase):
self.assertEqual('::babe:4317:0A83', server.FnGetAtt('accessIPv6'))
self.m.VerifyAll()
+ def test_server_create_err_toolong(self):
+ # Attempt to create a server with a 64 character name should fail
+ # instance name is name_s-name-xxxxxxxxxxxx, so 24 characters gives
+ # a 64 character physical_resource_name
+ return_server = self.fc.servers.list()[1]
+ name = 'e' * 24
+ error = self.assertRaises(exception.ResourceFailure,
+ self._create_test_server,
+ return_server,
+ name, stub_create=False)
+ substr = ('length 64 > 63 characters, '
+ 'please reduce the length of stack or resource names')
+ self.assertIn(substr, str(error))
+ self.m.VerifyAll()
+
def test_server_create_with_image_id(self):
return_server = self.fc.servers.list()[1]
server = self._setup_test_server(return_server,
@@ -176,7 +189,7 @@ class ServersTest(HeatTestCase):
self.m.VerifyAll()
def test_server_create_image_name_err(self):
- stack_name = 'test_server_create_image_name_err_stack'
+ stack_name = 'img_name_err'
(t, stack) = self._setup_test_stack(stack_name)
# create an server with non exist image name
@@ -193,7 +206,7 @@ class ServersTest(HeatTestCase):
self.m.VerifyAll()
def test_server_create_duplicate_image_name_err(self):
- stack_name = 'test_server_create_image_name_err_stack'
+ stack_name = 'img_dup_err'
(t, stack) = self._setup_test_stack(stack_name)
# create an server with a non unique image name
@@ -214,7 +227,7 @@ class ServersTest(HeatTestCase):
self.m.VerifyAll()
def test_server_create_image_id_err(self):
- stack_name = 'test_server_create_image_id_err_stack'
+ stack_name = 'img_id_err'
(t, stack) = self._setup_test_stack(stack_name)
# create an server with non exist image Id
@@ -238,7 +251,7 @@ class ServersTest(HeatTestCase):
def test_server_create_unexpected_status(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_create')
+ 'cr_unexp_sts')
return_server.get = lambda: None
return_server.status = 'BOGUS'
self.assertRaises(exception.Error,
@@ -248,7 +261,7 @@ class ServersTest(HeatTestCase):
def test_server_create_error_status(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_create')
+ 'cr_err_sts')
return_server.status = 'ERROR'
return_server.fault = {
'message': 'NoValidHost',
@@ -266,7 +279,7 @@ class ServersTest(HeatTestCase):
self.m.VerifyAll()
def test_server_validate(self):
- stack_name = 'test_server_validate_stack'
+ stack_name = 'srv_val'
(t, stack) = self._setup_test_stack(stack_name)
# create an server with non exist image Id
@@ -286,7 +299,7 @@ class ServersTest(HeatTestCase):
self.m.VerifyAll()
def test_server_validate_with_bootable_vol(self):
- stack_name = 'test_server_validate_stack'
+ stack_name = 'srv_val_bootvol'
(t, stack) = self._setup_test_stack(stack_name)
# create an server with bootable volume
@@ -318,7 +331,7 @@ class ServersTest(HeatTestCase):
self.m.VerifyAll()
def test_server_validate_delete_policy(self):
- stack_name = 'test_server_validate_stack'
+ stack_name = 'srv_val_delpol'
(t, stack) = self._setup_test_stack(stack_name)
# create an server with non exist image Id
@@ -338,7 +351,7 @@ class ServersTest(HeatTestCase):
def test_server_delete(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_create_delete')
+ 'create_delete')
server.resource_id = 1234
# this makes sure the auto increment worked on server creation
@@ -360,7 +373,7 @@ class ServersTest(HeatTestCase):
def test_server_delete_notfound(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_create_delete')
+ 'create_delete2')
server.resource_id = 1234
# this makes sure the auto increment worked on server creation
@@ -384,7 +397,7 @@ class ServersTest(HeatTestCase):
def test_server_update_metadata(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_update')
+ 'md_update')
update_template = copy.deepcopy(server.t)
update_template['Metadata'] = {'test': 123}
@@ -403,7 +416,7 @@ class ServersTest(HeatTestCase):
return_server = self.fc.servers.list()[1]
return_server.id = 1234
server = self._create_test_server(return_server,
- 'test_server_update')
+ 'srv_update')
update_template = copy.deepcopy(server.t)
update_template['Properties']['flavor'] = 'm1.small'
@@ -434,7 +447,7 @@ class ServersTest(HeatTestCase):
return_server = self.fc.servers.list()[1]
return_server.id = 1234
server = self._create_test_server(return_server,
- 'test_server_update')
+ 'srv_update2')
update_template = copy.deepcopy(server.t)
update_template['Properties']['flavor'] = 'm1.small'
@@ -460,7 +473,7 @@ class ServersTest(HeatTestCase):
self.m.VerifyAll()
def test_server_update_server_flavor_replace(self):
- stack_name = 'test_server_update_flavor_replace'
+ stack_name = 'update_flvrep'
(t, stack) = self._setup_test_stack(stack_name)
t['Resources']['WebServer']['Properties'][
@@ -474,7 +487,7 @@ class ServersTest(HeatTestCase):
self.assertRaises(resource.UpdateReplace, updater)
def test_server_update_server_flavor_policy_update(self):
- stack_name = 'test_server_update_flavor_replace'
+ stack_name = 'update_flvpol'
(t, stack) = self._setup_test_stack(stack_name)
server = servers.Server('server_server_update_flavor_replace',
@@ -492,7 +505,7 @@ class ServersTest(HeatTestCase):
def test_server_update_replace(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_update')
+ 'update_rep')
update_template = copy.deepcopy(server.t)
update_template['Notallowed'] = {'test': 123}
@@ -502,7 +515,7 @@ class ServersTest(HeatTestCase):
def test_server_update_properties(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_update')
+ 'update_prop')
update_template = copy.deepcopy(server.t)
update_template['Properties']['key_name'] = 'mustreplace'
@@ -512,7 +525,7 @@ class ServersTest(HeatTestCase):
def test_server_status_build(self):
return_server = self.fc.servers.list()[0]
server = self._setup_test_server(return_server,
- 'test_server_status_build')
+ 'sts_build')
server.resource_id = 1234
# Bind fake get method which Server.check_create_complete will call
@@ -527,14 +540,14 @@ class ServersTest(HeatTestCase):
def test_server_status_suspend_no_resource_id(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_suspend')
+ 'srv_sus1')
server.resource_id = None
self.m.ReplayAll()
ex = self.assertRaises(exception.ResourceFailure,
scheduler.TaskRunner(server.suspend))
- self.assertEqual('Error: Cannot suspend test_server_suspend_name, '
+ self.assertEqual('Error: Cannot suspend srv_sus1, '
'resource_id not set',
str(ex))
self.assertEqual(server.state, (server.SUSPEND, server.FAILED))
@@ -544,7 +557,7 @@ class ServersTest(HeatTestCase):
def test_server_status_suspend_not_found(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_suspend')
+ 'srv_sus2')
server.resource_id = 1234
self.m.StubOutWithMock(self.fc.client, 'get_servers_1234')
@@ -564,7 +577,7 @@ class ServersTest(HeatTestCase):
def test_server_status_suspend_immediate(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_suspend')
+ 'srv_suspend3')
server.resource_id = 1234
self.m.ReplayAll()
@@ -585,7 +598,7 @@ class ServersTest(HeatTestCase):
def test_server_status_resume_immediate(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_resume')
+ 'srv_resume1')
server.resource_id = 1234
self.m.ReplayAll()
@@ -607,7 +620,7 @@ class ServersTest(HeatTestCase):
def test_server_status_suspend_wait(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_suspend')
+ 'srv_susp_w')
server.resource_id = 1234
self.m.ReplayAll()
@@ -633,7 +646,7 @@ class ServersTest(HeatTestCase):
def test_server_status_suspend_unknown_status(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_suspend')
+ 'srv_susp_uk')
server.resource_id = 1234
self.m.ReplayAll()
@@ -663,7 +676,7 @@ class ServersTest(HeatTestCase):
def test_server_status_resume_wait(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_resume')
+ 'srv_res_w')
server.resource_id = 1234
self.m.ReplayAll()
@@ -691,7 +704,7 @@ class ServersTest(HeatTestCase):
def test_server_status_resume_no_resource_id(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_suspend')
+ 'srv_susp_norid')
server.resource_id = None
self.m.ReplayAll()
@@ -699,7 +712,7 @@ class ServersTest(HeatTestCase):
server.state_set(server.SUSPEND, server.COMPLETE)
ex = self.assertRaises(exception.ResourceFailure,
scheduler.TaskRunner(server.resume))
- self.assertEqual('Error: Cannot resume test_server_suspend_name, '
+ self.assertEqual('Error: Cannot resume srv_susp_norid, '
'resource_id not set',
str(ex))
self.assertEqual(server.state, (server.RESUME, server.FAILED))
@@ -709,7 +722,7 @@ class ServersTest(HeatTestCase):
def test_server_status_resume_not_found(self):
return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server,
- 'test_server_resume')
+ 'srv_res_nf')
server.resource_id = 1234
self.m.ReplayAll()
@@ -764,7 +777,7 @@ class ServersTest(HeatTestCase):
def _test_server_status_not_build_active(self, uncommon_status):
return_server = self.fc.servers.list()[0]
server = self._setup_test_server(return_server,
- 'test_server_status_build')
+ 'srv_sts_bld')
server.resource_id = 1234
check_iterations = [0]
@@ -800,7 +813,7 @@ class ServersTest(HeatTestCase):
def test_server_without_ip_address(self):
return_server = self.fc.servers.list()[3]
server = self._create_test_server(return_server,
- 'test_without_ip_address')
+ 'wo_ipaddr')
self.assertEqual(server.FnGetAtt('addresses'), {'empty_net': []})
self.assertEqual(server.FnGetAtt('networks'), {'empty_net': []})
@@ -837,7 +850,7 @@ class ServersTest(HeatTestCase):
]))
def test_validate_conflict_block_device_mapping_props(self):
- stack_name = 'test_validate_conflict_block_device_mapping_props'
+ stack_name = 'val_blkdev1'
(t, stack) = self._setup_test_stack(stack_name)
bdm = [{'device_name': 'vdb', 'snapshot_id': '1234',
@@ -853,7 +866,7 @@ class ServersTest(HeatTestCase):
self.m.VerifyAll()
def test_validate_insufficient_block_device_mapping_props(self):
- stack_name = 'test_validate_insufficient_block_device_mapping_props'
+ stack_name = 'val_blkdev2'
(t, stack) = self._setup_test_stack(stack_name)
bdm = [{'device_name': 'vdb', 'volume_size': '1',
@@ -874,7 +887,7 @@ class ServersTest(HeatTestCase):
self.m.VerifyAll()
def test_validate_without_image_or_bootable_volume(self):
- stack_name = 'test_validate_without_image_or_bootable_volume'
+ stack_name = 'val_imgvol'
(t, stack) = self._setup_test_stack(stack_name)
del t['Resources']['WebServer']['Properties']['image']