heat.tests.aws.*

partial blueprint heat-python34-support
Change-Id: Ib1ff24e1c8e1f37cb59d7bf9f22a3d7aed8f2ffa
This commit is contained in:
Sirushti Murugesan 2015-08-04 22:40:22 +05:30
parent 5fcec9b237
commit 12d535f3ba
6 changed files with 45 additions and 17 deletions

View File

@ -504,7 +504,7 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
LOG.warn(_LW('Instance (%(server)s) not found: %(ex)s'),
{'server': server, 'ex': ex})
else:
for n in server.networks:
for n in sorted(server.networks, reverse=True):
if len(server.networks[n]) > 0:
return server.networks[n][0]

View File

@ -358,7 +358,7 @@ class Instance(resource.Resource):
Read the server's IP address from a list of networks provided by Nova
'''
# Just record the first ipaddress
for n in networks:
for n in sorted(networks, reverse=True):
if len(networks[n]) > 0:
self.ipaddress = networks[n][0]
break

View File

@ -242,11 +242,10 @@ class InstancesTest(common.HeatTestCase):
resource_defns = tmpl.resource_definitions(stack)
instance = instances.Instance('validate_volumes',
resource_defns['WebServer'], stack)
self._mock_get_image_id_success('F17-x86_64-gold', 1)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
self.stub_ImageConstraint_validate()
self.stub_SnapshotConstraint_validate()
self.stub_FlavorConstraint_validate()
self.stub_KeypairConstraint_validate()
self.m.StubOutWithMock(cinder.CinderClientPlugin, 'get_volume')
ex = exception.EntityNotFound(entity='Volume', name='1234')
cinder.CinderClientPlugin.get_volume('1234').AndRaise(ex)
@ -345,10 +344,11 @@ class InstancesTest(common.HeatTestCase):
instance = instances.Instance('validate_without_DeviceName',
resource_defns['WebServer'], stack)
self._mock_get_image_id_success('F17-x86_64-gold', 1)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().MultipleTimes().AndReturn(self.fc)
self.stub_VolumeConstraint_validate()
self.stub_SnapshotConstraint_validate()
self.stub_ImageConstraint_validate()
self.stub_KeypairConstraint_validate()
self.stub_FlavorConstraint_validate()
self.m.ReplayAll()
exc = self.assertRaises(exception.StackValidationFailed,
@ -409,6 +409,10 @@ class InstancesTest(common.HeatTestCase):
self._mock_get_image_id_fail('Slackware',
exception.EntityNotFound(
entity='Image', name='Slackware'))
self.stub_VolumeConstraint_validate()
self.stub_FlavorConstraint_validate()
self.stub_KeypairConstraint_validate()
self.stub_SnapshotConstraint_validate()
self.m.ReplayAll()
create = scheduler.TaskRunner(instance.create)
@ -437,6 +441,10 @@ class InstancesTest(common.HeatTestCase):
exception.PhysicalResourceNameAmbiguity(
name='CentOS 5.2'))
self.stub_KeypairConstraint_validate()
self.stub_SnapshotConstraint_validate()
self.stub_VolumeConstraint_validate()
self.stub_FlavorConstraint_validate()
self.m.ReplayAll()
create = scheduler.TaskRunner(instance.create)
@ -462,6 +470,10 @@ class InstancesTest(common.HeatTestCase):
self._mock_get_image_id_fail('1', glance_exceptions.NotFound(404))
self.stub_VolumeConstraint_validate()
self.stub_FlavorConstraint_validate()
self.stub_KeypairConstraint_validate()
self.stub_SnapshotConstraint_validate()
self.m.ReplayAll()
create = scheduler.TaskRunner(instance.create)

View File

@ -18,6 +18,7 @@ import uuid
from oslo_utils import timeutils
import six
from six.moves.urllib import parse
from heat.common import exception
from heat.common import identifier
@ -249,7 +250,8 @@ class WaitConditionTest(common.HeatTestCase):
'Status': 'SUCCESS', 'UniqueId': '456'}
ret = handle.handle_signal(test_metadata)
wc_att = rsrc.FnGetAtt('Data')
self.assertEqual(u'{"123": "foo", "456": "dog"}', wc_att)
self.assertIsInstance(wc_att, six.string_types)
self.assertEqual({"123": "foo", "456": "dog"}, json.loads(wc_att))
self.assertEqual('status:SUCCESS reason:cat', ret)
self.m.VerifyAll()
@ -395,12 +397,14 @@ class WaitConditionHandleTest(common.HeatTestCase):
rsrc.created_time = created_time
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
expected_url = "".join([
connection_url = "".join([
'http://server.test:8000/v1/waitcondition/',
'arn%3Aopenstack%3Aheat%3A%3Atest_tenant%3Astacks%2F',
'test_stack2%2F', stack_id, '%2Fresources%2F',
'WaitHandle?',
'WaitHandle?'])
expected_url = "".join([
connection_url,
'Timestamp=2012-11-29T13%3A49%3A37Z&',
'SignatureMethod=HmacSHA256&',
'AWSAccessKeyId=4567&',
@ -408,7 +412,12 @@ class WaitConditionHandleTest(common.HeatTestCase):
'Signature=',
'fHyt3XFnHq8%2FSwYaVcHdJka1hz6jdK5mHtgbo8OOKbQ%3D'])
self.assertEqual(six.text_type(expected_url), rsrc.FnGetRefId())
actual_url = rsrc.FnGetRefId()
expected_params = parse.parse_qs(expected_url.split("?", 1)[1])
actual_params = parse.parse_qs(actual_url.split("?", 1)[1])
self.assertEqual(expected_params, actual_params)
self.assertTrue(connection_url.startswith(connection_url))
self.m.VerifyAll()
def test_handle_signal(self):
@ -505,7 +514,8 @@ class WaitConditionHandleTest(common.HeatTestCase):
test_metadata = {'Data': 'dog', 'Reason': 'cat',
'Status': 'SUCCESS', 'UniqueId': '456'}
ret = rsrc.handle_signal(test_metadata)
self.assertEqual(['bar', 'cat'], rsrc.get_status_reason('SUCCESS'))
self.assertEqual(
['bar', 'cat'], sorted(rsrc.get_status_reason('SUCCESS')))
self.assertEqual('status:SUCCESS reason:cat', ret)
test_metadata = {'Data': 'boo', 'Reason': 'hoo',

View File

@ -302,7 +302,7 @@ class FakeHTTPClient(base_client.HTTPClient):
if action in ['addFloatingIp',
'removeFloatingIp',
]:
assert body[action].keys() == ['address']
assert list(body[action].keys()) == ['address']
return (resp, _body)

View File

@ -3,6 +3,7 @@ heat.tests.api.middleware.test_ssl_middleware
heat.tests.api.middleware.test_version_negotiation_middleware
heat.tests.api.openstack_v1.test_stacks_view
heat.tests.api.openstack_v1.test_util
heat.tests.autoscaling
heat.tests.autoscaling.test_heat_scaling_group
heat.tests.autoscaling.test_heat_scaling_policy
heat.tests.autoscaling.test_launch_config
@ -10,6 +11,7 @@ heat.tests.autoscaling.test_lbutils
heat.tests.autoscaling.test_new_capacity
heat.tests.autoscaling.test_scaling_group
heat.tests.autoscaling.test_scaling_policy
heat.tests.aws
heat.tests.aws.test_instance_network
heat.tests.aws.test_loadbalancer
heat.tests.aws.test_network_interface
@ -34,6 +36,7 @@ heat.tests.clients.test_mistral_client
heat.tests.clients.test_neutron_client
heat.tests.clients.test_sahara_client
heat.tests.clients.test_zaqar_client
heat.tests.db
heat.tests.db.test_migrations
heat.tests.db.test_sqlalchemy_api
heat.tests.db.test_sqlalchemy_filters
@ -47,6 +50,7 @@ heat.tests.engine.test_stack_delete
heat.tests.engine.test_stack_events
heat.tests.engine.test_stack_snapshot
heat.tests.engine.test_threadgroup_mgr
heat.tests.keystone
heat.tests.keystone.test_endpoint
heat.tests.keystone.test_group
heat.tests.keystone.test_project
@ -59,6 +63,7 @@ heat.tests.manila.test_manila_share
heat.tests.manila.test_manila_share_type
heat.tests.manila.test_share_network
heat.tests.mistral.test_mistral_cron_trigger
heat.tests.neutron
heat.tests.neutron.test_extraroute
heat.tests.neutron.test_neutron
heat.tests.neutron.test_neutron_firewall
@ -72,6 +77,7 @@ heat.tests.neutron.test_neutron_router
heat.tests.neutron.test_neutron_security_group
heat.tests.neutron.test_neutron_subnet
heat.tests.neutron.test_neutron_vpnservice
heat.tests.nova
heat.tests.nova.test_nova_flavor
heat.tests.nova.test_nova_floatingip
heat.tests.nova.test_nova_keypair