diff --git a/heat/engine/resources/signal_responder.py b/heat/engine/resources/signal_responder.py index 55bcfccc8..c3a528b0d 100644 --- a/heat/engine/resources/signal_responder.py +++ b/heat/engine/resources/signal_responder.py @@ -290,8 +290,6 @@ class SignalResponder(stack_user.StackUser): self._create_user() queue_id = self.physical_resource_name() - zaqar = self.client('zaqar') - zaqar.queue(queue_id).ensure_exists() self.data_set('zaqar_signal_queue_id', queue_id) return queue_id @@ -299,8 +297,10 @@ class SignalResponder(stack_user.StackUser): queue_id = self.data().get('zaqar_signal_queue_id') if not queue_id: return - zaqar = self.client('zaqar') - with self.client_plugin('zaqar').ignore_not_found: + zaqar_plugin = self.client_plugin('zaqar') + zaqar = zaqar_plugin.create_for_tenant( + self.stack.stack_user_project_id, self._user_token()) + with zaqar_plugin.ignore_not_found: zaqar.queue(queue_id).delete() self.data_delete('zaqar_signal_queue_id') @@ -379,7 +379,9 @@ class SignalResponder(stack_user.StackUser): swift_client.delete_object(self.stack.id, object_name) def _service_zaqar_signal(self): - zaqar = self.client('zaqar') + zaqar_plugin = self.client_plugin('zaqar') + zaqar = zaqar_plugin.create_for_tenant( + self.stack.stack_user_project_id, self._user_token()) try: queue = zaqar.queue(self._get_zaqar_signal_queue_id()) except Exception as ex: diff --git a/heat/tests/openstack/heat/test_software_deployment.py b/heat/tests/openstack/heat/test_software_deployment.py index 7f0cf561f..bacef3b7c 100644 --- a/heat/tests/openstack/heat/test_software_deployment.py +++ b/heat/tests/openstack/heat/test_software_deployment.py @@ -1140,11 +1140,6 @@ class SoftwareDeploymentTest(common.HeatTestCase): def test_get_zaqar_queue(self): dep_data = {} - zc = mock.MagicMock() - zcc = self.patch( - 'heat.engine.clients.os.zaqar.ZaqarClientPlugin._create') - zcc.return_value = zc - self._create_stack(self.template_zaqar_signal) def data_set(key, value, redact=False): @@ -1158,16 +1153,16 @@ class SoftwareDeploymentTest(common.HeatTestCase): self.deployment.action = self.deployment.CREATE queue_id = self.deployment._get_zaqar_signal_queue_id() - self.assertEqual(2, len(zc.queue.mock_calls)) - self.assertEqual(queue_id, zc.queue.mock_calls[0][1][0]) self.assertEqual(queue_id, dep_data['zaqar_signal_queue_id']) self.assertEqual(queue_id, self.deployment._get_zaqar_signal_queue_id()) - def test_delete_zaqar_queue(self): + @mock.patch.object(zaqar.ZaqarClientPlugin, 'create_for_tenant') + def test_delete_zaqar_queue(self, zcc): queue_id = str(uuid.uuid4()) dep_data = { + 'password': 'password', 'zaqar_signal_queue_id': queue_id } self._create_stack(self.template_zaqar_signal) @@ -1176,8 +1171,6 @@ class SoftwareDeploymentTest(common.HeatTestCase): self.deployment.data = mock.Mock(return_value=dep_data) zc = mock.MagicMock() - zcc = self.patch( - 'heat.engine.clients.os.zaqar.ZaqarClientPlugin._create') zcc.return_value = zc self.deployment.id = 23 diff --git a/heat_integrationtests/functional/test_waitcondition.py b/heat_integrationtests/functional/test_waitcondition.py new file mode 100644 index 000000000..fd5399fad --- /dev/null +++ b/heat_integrationtests/functional/test_waitcondition.py @@ -0,0 +1,72 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import json + +from keystoneclient.v3 import client as keystoneclient +from zaqarclient.queues.v1 import client as zaqarclient + +from heat_integrationtests.functional import functional_base + + +class ZaqarWaitConditionTest(functional_base.FunctionalTestsBase): + template = ''' +heat_template_version: "2013-05-23" + +resources: + wait_condition: + type: OS::Heat::WaitCondition + properties: + handle: {get_resource: wait_handle} + timeout: 120 + wait_handle: + type: OS::Heat::WaitConditionHandle + properties: + signal_transport: ZAQAR_SIGNAL + +outputs: + wait_data: + value: {'Fn::Select': ['data_id', {get_attr: [wait_condition, data]}]} +''' + + def test_signal_queues(self): + stack_identifier = self.stack_create( + template=self.template, + expected_status=None) + self._wait_for_resource_status(stack_identifier, 'wait_handle', + 'CREATE_COMPLETE') + resource = self.client.resources.get(stack_identifier, 'wait_handle') + signal = json.loads(resource.attributes['signal']) + ks = keystoneclient.Client( + auth_url=signal['auth_url'], + user_id=signal['user_id'], + password=signal['password'], + project_id=signal['project_id']) + endpoint = ks.service_catalog.url_for( + service_type='messaging', endpoint_type='publicURL') + conf = { + 'auth_opts': { + 'backend': 'keystone', + 'options': { + 'os_auth_token': ks.auth_token, + 'os_project_id': signal['project_id'] + } + } + } + + zaqar = zaqarclient.Client(endpoint, conf=conf, version=1.1) + + queue = zaqar.queue(signal['queue_id']) + queue.post({'body': {'data': 'here!', 'id': 'data_id'}, 'ttl': 600}) + self._wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE') + stack = self.client.stacks.get(stack_identifier) + self.assertEqual('here!', stack.outputs[0]['output_value'])