'Test case for raising exception due to resize call failed.
If the status after a resize is not VERIFY_RESIZE, it means the resize
call failed, so we raise an explicit error.'

def test_instance_update_instance_type_failed(self):

    return_server = self.fc.servers.list()[1]
    return_server.id = '1234'
    instance = self._create_test_instance(return_server, 'ud_type_f')
    def side_effect(*args):
        return (2 if (args[0] == 'm1.small') else 1)
    self.patchobject(nova.NovaClientPlugin, 'find_flavor_by_name_or_id', side_effect=side_effect)
    self.patchobject(glance.GlanceClientPlugin, 'find_image_by_name_or_id', return_value=1)
    update_props = self.instance_props.copy()
    update_props['InstanceType'] = 'm1.small'
    update_template = instance.t.freeze(properties=update_props)
    self.m.StubOutWithMock(self.fc.servers, 'get')
    def status_resize(*args):
        return_server.status = 'RESIZE'
    def status_error(*args):
        return_server.status = 'ERROR'
    self.fc.servers.get('1234').AndReturn(return_server)
    self.fc.servers.get('1234').WithSideEffects(status_resize).AndReturn(return_server)
    self.fc.servers.get('1234').WithSideEffects(status_error).AndReturn(return_server)
    self.m.StubOutWithMock(self.fc.client, 'post_servers_1234_action')
    self.fc.client.post_servers_1234_action(body={'resize': {'flavorRef': 2}}).AndReturn((202, None))
    self.m.ReplayAll()
    updater = scheduler.TaskRunner(instance.update, update_template)
    error = self.assertRaises(exception.ResourceFailure, updater)
    self.assertEqual("Error:    resources.ud_type_f:    Resizing    to    '2'    failed,    status    'ERROR'", six.text_type(error))
    self.assertEqual((instance.UPDATE, instance.FAILED), instance.state)
    self.m.VerifyAll()
