'Check that rollback still works with dynamic metadata.
This test fails the second instance.'

def test_create_failure_recovery(self):

    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)
    self.m.StubOutWithMock(generic_rsrc.ResourceWithFnGetRefIdType, 'handle_create')
    self.m.StubOutWithMock(generic_rsrc.ResourceWithFnGetRefIdType, 'handle_delete')
    generic_rsrc.ResourceWithFnGetRefIdType.handle_create().AndRaise(Exception)
    generic_rsrc.ResourceWithFnGetRefIdType.handle_delete()
    generic_rsrc.ResourceWithFnGetRefIdType.handle_create()
    self.m.ReplayAll()
    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'])
    self.m.VerifyAll()
