def test_create_failure_recovery(self):
    'Check that rollback still works with dynamic metadata.\n\n        This test fails the second instance.\n        '
    tmpl = {'HeatTemplateFormatVersion': '2012-12-12', 'Resources': {'AResource': {'Type': 'OverwrittenFnGetRefIdType', 'Properties': {'Foo': 'abc'}}, 'BResource': {'Type': 'ResourceWithPropsType', 'Properties': {'Foo': {'Ref': 'AResource'}}}}}
    self.stack = stack.Stack(self.ctx, 'update_test_stack', template.Template(tmpl), disable_rollback=True)

    class FakeException(Exception):
        pass
    mock_create = self.patchobject(generic_rsrc.ResourceWithFnGetRefIdType, 'handle_create', side_effect=[FakeException, None])
    mock_delete = self.patchobject(generic_rsrc.ResourceWithFnGetRefIdType, 'handle_delete', return_value=None)
    self.stack.store()
    self.stack.create()
    self.assertEqual((stack.Stack.CREATE, stack.Stack.FAILED), self.stack.state)
    self.assertEqual('abc', self.stack['AResource'].properties['Foo'])
    updated_stack = stack.Stack(self.ctx, 'updated_stack', template.Template(tmpl), disable_rollback=True)
    self.stack.update(updated_stack)
    self.assertEqual((stack.Stack.UPDATE, stack.Stack.COMPLETE), self.stack.state)
    self.assertEqual('abc', self.stack['AResource']._stored_properties_data['Foo'])
    self.assertEqual('ID-AResource', self.stack['BResource']._stored_properties_data['Foo'])
    mock_delete.assert_called_once_with()
    self.assertEqual(2, mock_create.call_count)
Check that rollback still works with dynamic metadata.

This test fails the second instance.
def test_create_failure_recovery(self):
    'Check that rollback still works with dynamic metadata.\n\n        This test fails the second instance.\n        '
    tmpl = {'HeatTemplateFormatVersion': '2012-12-12', 'Resources': {'AResource': {'Type': 'OverwrittenFnGetRefIdType', 'Properties': {'Foo': 'abc'}}, 'BResource': {'Type': 'ResourceWithPropsType', 'Properties': {'Foo': {'Ref': 'AResource'}}}}}
    self.stack = stack.Stack(self.ctx, 'update_test_stack', template.Template(tmpl), disable_rollback=True)

    class FakeException(Exception):
        pass
    mock_create = self.patchobject(generic_rsrc.ResourceWithFnGetRefIdType, 'handle_create', side_effect=[FakeException, None])
    mock_delete = self.patchobject(generic_rsrc.ResourceWithFnGetRefIdType, 'handle_delete', return_value=None)
    self.stack.store()
    self.stack.create()
    self.assertEqual((stack.Stack.CREATE, stack.Stack.FAILED), self.stack.state)
    self.assertEqual('abc', self.stack['AResource'].properties['Foo'])
    updated_stack = stack.Stack(self.ctx, 'updated_stack', template.Template(tmpl), disable_rollback=True)
    self.stack.update(updated_stack)
    self.assertEqual((stack.Stack.UPDATE, stack.Stack.COMPLETE), self.stack.state)
    self.assertEqual('abc', self.stack['AResource']._stored_properties_data['Foo'])
    self.assertEqual('ID-AResource', self.stack['BResource']._stored_properties_data['Foo'])
    mock_delete.assert_called_once_with()
    self.assertEqual(2, mock_create.call_count)