const std::string &remote_mirror_uuid,
const std::string &local_image_name,
librbd::MockTestImageCtx &mock_remote_image_ctx,
+ std::string *local_image_id,
Context *on_finish) {
return new MockCreateImageRequest(m_local_io_ctx, m_threads->work_queue,
global_image_id, remote_mirror_uuid,
local_image_name, &mock_remote_image_ctx,
- on_finish);
+ local_image_id, on_finish);
}
librbd::ImageCtx *m_remote_image_ctx;
expect_create_image(mock_create_request, m_local_io_ctx, 0);
C_SaferCond ctx;
+ std::string local_image_id;
MockCreateImageRequest *request = create_request("global uuid", "remote uuid",
"image name",
- mock_remote_image_ctx, &ctx);
+ mock_remote_image_ctx,
+ &local_image_id, &ctx);
request->send();
ASSERT_EQ(0, ctx.wait());
+ ASSERT_FALSE(local_image_id.empty());
}
TEST_F(TestMockImageReplayerCreateImageRequest, CreateError) {
expect_create_image(mock_create_request, m_local_io_ctx, -EINVAL);
C_SaferCond ctx;
+ std::string local_image_id;
MockCreateImageRequest *request = create_request("global uuid", "remote uuid",
"image name",
- mock_remote_image_ctx, &ctx);
+ mock_remote_image_ctx,
+ &local_image_id, &ctx);
request->send();
ASSERT_EQ(-EINVAL, ctx.wait());
}
expect_close_image(mock_close_image_request, mock_remote_parent_image_ctx, 0);
C_SaferCond ctx;
+ std::string local_image_id;
MockCreateImageRequest *request = create_request("global uuid", "remote uuid",
"image name",
mock_remote_clone_image_ctx,
- &ctx);
+ &local_image_id, &ctx);
request->send();
ASSERT_EQ(0, ctx.wait());
+ ASSERT_FALSE(local_image_id.empty());
}
TEST_F(TestMockImageReplayerCreateImageRequest, CloneGetGlobalImageIdError) {
expect_get_parent_global_image_id(m_remote_io_ctx, "global uuid", -ENOENT);
C_SaferCond ctx;
+ std::string local_image_id;
MockCreateImageRequest *request = create_request("global uuid", "remote uuid",
"image name",
mock_remote_clone_image_ctx,
- &ctx);
+ &local_image_id, &ctx);
request->send();
ASSERT_EQ(-ENOENT, ctx.wait());
}
expect_mirror_image_get_image_id(m_local_io_ctx, "local parent id", -ENOENT);
C_SaferCond ctx;
+ std::string local_image_id;
MockCreateImageRequest *request = create_request("global uuid", "remote uuid",
"image name",
mock_remote_clone_image_ctx,
- &ctx);
+ &local_image_id, &ctx);
request->send();
ASSERT_EQ(-ENOENT, ctx.wait());
}
m_remote_image_ctx->id, mock_remote_parent_image_ctx, -ENOENT);
C_SaferCond ctx;
+ std::string local_image_id;
MockCreateImageRequest *request = create_request("global uuid", "remote uuid",
"image name",
mock_remote_clone_image_ctx,
- &ctx);
+ &local_image_id, &ctx);
request->send();
ASSERT_EQ(-ENOENT, ctx.wait());
}
expect_close_image(mock_close_image_request, mock_remote_parent_image_ctx, 0);
C_SaferCond ctx;
+ std::string local_image_id;
MockCreateImageRequest *request = create_request("global uuid", "remote uuid",
"image name",
mock_remote_clone_image_ctx,
- &ctx);
+ &local_image_id, &ctx);
request->send();
ASSERT_EQ(-ENOENT, ctx.wait());
}
expect_close_image(mock_close_image_request, mock_remote_parent_image_ctx, 0);
C_SaferCond ctx;
+ std::string local_image_id;
MockCreateImageRequest *request = create_request("global uuid", "remote uuid",
"image name",
mock_remote_clone_image_ctx,
- &ctx);
+ &local_image_id, &ctx);
request->send();
ASSERT_EQ(-ENOENT, ctx.wait());
}
expect_close_image(mock_close_image_request, mock_remote_parent_image_ctx, 0);
C_SaferCond ctx;
+ std::string local_image_id;
MockCreateImageRequest *request = create_request("global uuid", "remote uuid",
"image name",
mock_remote_clone_image_ctx,
- &ctx);
+ &local_image_id, &ctx);
request->send();
ASSERT_EQ(-EINVAL, ctx.wait());
}
expect_close_image(mock_close_image_request, mock_remote_parent_image_ctx, 0);
C_SaferCond ctx;
+ std::string local_image_id;
MockCreateImageRequest *request = create_request("global uuid", "remote uuid",
"image name",
mock_remote_clone_image_ctx,
- &ctx);
+ &local_image_id, &ctx);
request->send();
ASSERT_EQ(0, ctx.wait());
+ ASSERT_FALSE(local_image_id.empty());
}
TEST_F(TestMockImageReplayerCreateImageRequest, CloneRemoteParentCloseError) {
expect_close_image(mock_close_image_request, mock_remote_parent_image_ctx, -EINVAL);
C_SaferCond ctx;
+ std::string local_image_id;
MockCreateImageRequest *request = create_request("global uuid", "remote uuid",
"image name",
mock_remote_clone_image_ctx,
- &ctx);
+ &local_image_id, &ctx);
request->send();
ASSERT_EQ(0, ctx.wait());
+ ASSERT_FALSE(local_image_id.empty());
}
} // namespace image_replayer
const std::string &remote_mirror_uuid,
const std::string &local_image_name,
I *remote_image_ctx,
+ std::string *local_image_id,
Context *on_finish)
: m_local_io_ctx(local_io_ctx), m_work_queue(work_queue),
m_global_image_id(global_image_id),
m_remote_mirror_uuid(remote_mirror_uuid),
m_local_image_name(local_image_name), m_remote_image_ctx(remote_image_ctx),
- m_on_finish(on_finish) {
+ m_local_image_id(local_image_id), m_on_finish(on_finish) {
}
template <typename I>
image_options.set(RBD_IMAGE_OPTION_STRIPE_COUNT,
m_remote_image_ctx->stripe_count);
- std::string id = librbd::util::generate_image_id(m_local_io_ctx);
+ *m_local_image_id = librbd::util::generate_image_id(m_local_io_ctx);;
librbd::image::CreateRequest<I> *req = librbd::image::CreateRequest<I>::create(
- m_local_io_ctx, m_local_image_name, id, m_remote_image_ctx->size,
- image_options, m_global_image_id, m_remote_mirror_uuid, false,
- m_remote_image_ctx->op_work_queue, ctx);
+ m_local_io_ctx, m_local_image_name, *m_local_image_id,
+ m_remote_image_ctx->size, image_options, m_global_image_id,
+ m_remote_mirror_uuid, false, m_remote_image_ctx->op_work_queue, ctx);
req->send();
}
opts.set(RBD_IMAGE_OPTION_STRIPE_UNIT, m_remote_image_ctx->stripe_unit);
opts.set(RBD_IMAGE_OPTION_STRIPE_COUNT, m_remote_image_ctx->stripe_count);
- std::string id = librbd::util::generate_image_id(m_local_io_ctx);
+ *m_local_image_id = librbd::util::generate_image_id(m_local_io_ctx);;
using klass = CreateImageRequest<I>;
Context *ctx = create_context_callback<klass, &klass::handle_clone_image>(this);
librbd::image::CloneRequest<I> *req = librbd::image::CloneRequest<I>::create(
- m_local_parent_image_ctx, m_local_io_ctx, m_local_image_name, id, opts,
- m_global_image_id, m_remote_mirror_uuid,
+ m_local_parent_image_ctx, m_local_io_ctx, m_local_image_name,
+ *m_local_image_id, opts, m_global_image_id, m_remote_mirror_uuid,
m_remote_image_ctx->op_work_queue, ctx);
req->send();
}