ad104c51bf
This is a merge of 4 reviews: I52f1611d34def3474acba0e5eee054e11c5fc5ad Ic374a38c9d76763be341d3a80f53fa396c9c2256 Iecd21ccb4392369f66fa1b3a0cf55aad754aeac4 I77b81097d2dcf01efa540237ed5ae14896ed1670 - make sure sender is a tuple (otherwise the serialization function in sync_point breaks.) - Update updated_time on any lifecycle operation(CREATE/UPDATE/DELETE) over a stack. - adjust sync_point logic to account for deletes Done by having only a single stack sync point for both updates and deletes. - Serialize/deserialize input_data for RPC - Make GraphKey's the norm in convergence worker - move temp_update_requires functionality to tests During intial stages of convergence to simulate the entire cycle some part of worker code was written in stack.py. Now that the convergence worker is implemented, this code needs to be executed only in tests. - Fix dictionary structure that's passed to resoure.(create/update) - Temporarily disable loading cache_data for stack to help fix other issues. Change-Id: Iecd21ccb4392369f66fa1b3a0cf55aad754aeac4 Co-Authored-by: Sirushti Murugesan <sirushti.murugesan@hp.com> Co-Authored-by: Rakesh H S <rh-s@hp.com>
69 lines
2.8 KiB
Python
69 lines
2.8 KiB
Python
#
|
|
# 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 mock
|
|
|
|
from heat.engine import sync_point
|
|
from heat.tests import common
|
|
from heat.tests.engine import tools
|
|
from heat.tests import utils
|
|
|
|
|
|
class SyncPointTestCase(common.HeatTestCase):
|
|
def test_sync_waiting(self):
|
|
ctx = utils.dummy_context()
|
|
stack = tools.get_stack('test_stack', utils.dummy_context(),
|
|
template=tools.string_template_five,
|
|
convergence=True)
|
|
stack.converge_stack(stack.t, action=stack.CREATE)
|
|
resource = stack['C']
|
|
graph = stack.convergence_dependencies.graph()
|
|
|
|
sender = (4, True)
|
|
mock_callback = mock.Mock()
|
|
sync_point.sync(ctx, resource.id, stack.current_traversal, True,
|
|
mock_callback, set(graph[(resource.id, True)]),
|
|
{sender: None})
|
|
updated_sync_point = sync_point.get(ctx, resource.id,
|
|
stack.current_traversal, True)
|
|
input_data = sync_point.deserialize_input_data(
|
|
updated_sync_point.input_data)
|
|
self.assertEqual({sender: None}, input_data)
|
|
self.assertFalse(mock_callback.called)
|
|
|
|
def test_sync_non_waiting(self):
|
|
ctx = utils.dummy_context()
|
|
stack = tools.get_stack('test_stack', utils.dummy_context(),
|
|
template=tools.string_template_five,
|
|
convergence=True)
|
|
stack.converge_stack(stack.t, action=stack.CREATE)
|
|
resource = stack['A']
|
|
graph = stack.convergence_dependencies.graph()
|
|
|
|
sender = (3, True)
|
|
mock_callback = mock.Mock()
|
|
sync_point.sync(ctx, resource.id, stack.current_traversal, True,
|
|
mock_callback, set(graph[(resource.id, True)]),
|
|
{sender: None})
|
|
updated_sync_point = sync_point.get(ctx, resource.id,
|
|
stack.current_traversal, True)
|
|
input_data = sync_point.deserialize_input_data(
|
|
updated_sync_point.input_data)
|
|
self.assertEqual({sender: None}, input_data)
|
|
self.assertTrue(mock_callback.called)
|
|
|
|
def test_serialize_input_data(self):
|
|
res = sync_point.serialize_input_data({(3L, 8): None})
|
|
self.assertEqual({'input_data': [[[3L, 8], None]]}, res)
|