2
# Licensed under the Apache License, Version 2.0 (the "License");
3
# you may not use this file except in compliance with the License.
4
# You may obtain a copy of the License at
6
# http://www.apache.org/licenses/LICENSE-2.0
8
# Unless required by applicable law or agreed to in writing, software
9
# distributed under the License is distributed on an "AS IS" BASIS,
10
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
17
from heat.engine import sync_point
18
from heat.tests import common
19
from heat.tests.engine import tools
20
from heat.tests import utils
23
class SyncPointTestCase(common.HeatTestCase):
24
def test_sync_waiting(self):
25
ctx = utils.dummy_context()
26
stack = tools.get_stack('test_stack', utils.dummy_context(),
27
template=tools.string_template_five,
29
stack.converge_stack(stack.t, action=stack.CREATE)
31
graph = stack.convergence_dependencies.graph()
34
mock_callback = mock.Mock()
35
sync_point.sync(ctx, resource.id, stack.current_traversal, True,
36
mock_callback, set(graph[(resource.id, True)]),
38
updated_sync_point = sync_point.get(ctx, resource.id,
39
stack.current_traversal, True)
40
input_data = sync_point.deserialize_input_data(
41
updated_sync_point.input_data)
42
self.assertEqual({sender: None}, input_data)
43
self.assertFalse(mock_callback.called)
45
def test_sync_non_waiting(self):
46
ctx = utils.dummy_context()
47
stack = tools.get_stack('test_stack', utils.dummy_context(),
48
template=tools.string_template_five,
50
stack.converge_stack(stack.t, action=stack.CREATE)
52
graph = stack.convergence_dependencies.graph()
55
mock_callback = mock.Mock()
56
sync_point.sync(ctx, resource.id, stack.current_traversal, True,
57
mock_callback, set(graph[(resource.id, True)]),
59
updated_sync_point = sync_point.get(ctx, resource.id,
60
stack.current_traversal, True)
61
input_data = sync_point.deserialize_input_data(
62
updated_sync_point.input_data)
63
self.assertEqual({sender: None}, input_data)
64
self.assertTrue(mock_callback.called)
66
def test_serialize_input_data(self):
67
res = sync_point.serialize_input_data({(3, 8): None})
68
self.assertEqual({'input_data': [[[3, 8], None]]}, res)