summaryrefslogtreecommitdiffstats
path: root/src/test/librbd/test_mock_Journal.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/librbd/test_mock_Journal.cc')
-rw-r--r--src/test/librbd/test_mock_Journal.cc44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/test/librbd/test_mock_Journal.cc b/src/test/librbd/test_mock_Journal.cc
index 727d0db8381..86e31f905d7 100644
--- a/src/test/librbd/test_mock_Journal.cc
+++ b/src/test/librbd/test_mock_Journal.cc
@@ -396,7 +396,16 @@ public:
}
void expect_start_append(::journal::MockJournaler &mock_journaler) {
- EXPECT_CALL(mock_journaler, start_append(_, _, _, _));
+ EXPECT_CALL(mock_journaler, start_append(_));
+ }
+
+ void expect_set_append_batch_options(MockJournalImageCtx &mock_image_ctx,
+ ::journal::MockJournaler &mock_journaler,
+ bool user_flushed) {
+ if (mock_image_ctx.image_ctx->config.get_val<bool>("rbd_journal_object_writethrough_until_flush") ==
+ user_flushed) {
+ EXPECT_CALL(mock_journaler, set_append_batch_options(_, _, _));
+ }
}
void expect_stop_append(::journal::MockJournaler &mock_journaler, int r) {
@@ -518,6 +527,7 @@ public:
expect_committed(mock_journaler, 0);
expect_flush_commit_position(mock_journaler);
expect_start_append(mock_journaler);
+ expect_set_append_batch_options(mock_image_ctx, mock_journaler, false);
ASSERT_EQ(0, when_open(mock_journal));
}
@@ -585,6 +595,7 @@ TEST_F(TestMockJournal, StateTransitions) {
expect_flush_commit_position(mock_journaler);
expect_start_append(mock_journaler);
+ expect_set_append_batch_options(mock_image_ctx, mock_journaler, false);
ASSERT_EQ(0, when_open(mock_journal));
@@ -662,6 +673,7 @@ TEST_F(TestMockJournal, ReplayCompleteError) {
expect_shut_down_replay(mock_image_ctx, mock_journal_replay, 0);
expect_flush_commit_position(mock_journaler);
expect_start_append(mock_journaler);
+ expect_set_append_batch_options(mock_image_ctx, mock_journaler, false);
ASSERT_EQ(0, when_open(mock_journal));
expect_stop_append(mock_journaler, 0);
@@ -719,6 +731,7 @@ TEST_F(TestMockJournal, FlushReplayError) {
expect_shut_down_replay(mock_image_ctx, mock_journal_replay, 0);
expect_flush_commit_position(mock_journaler);
expect_start_append(mock_journaler);
+ expect_set_append_batch_options(mock_image_ctx, mock_journaler, false);
ASSERT_EQ(0, when_open(mock_journal));
expect_stop_append(mock_journaler, 0);
@@ -773,6 +786,7 @@ TEST_F(TestMockJournal, CorruptEntry) {
expect_shut_down_replay(mock_image_ctx, mock_journal_replay, 0);
expect_flush_commit_position(mock_journaler);
expect_start_append(mock_journaler);
+ expect_set_append_batch_options(mock_image_ctx, mock_journaler, false);
ASSERT_EQ(0, when_open(mock_journal));
expect_stop_append(mock_journaler, -EINVAL);
@@ -811,6 +825,7 @@ TEST_F(TestMockJournal, StopError) {
expect_shut_down_replay(mock_image_ctx, mock_journal_replay, 0);
expect_flush_commit_position(mock_journaler);
expect_start_append(mock_journaler);
+ expect_set_append_batch_options(mock_image_ctx, mock_journaler, false);
ASSERT_EQ(0, when_open(mock_journal));
expect_stop_append(mock_journaler, -EINVAL);
@@ -876,6 +891,7 @@ TEST_F(TestMockJournal, ReplayOnDiskPreFlushError) {
expect_shut_down_replay(mock_image_ctx, mock_journal_replay, 0);
expect_flush_commit_position(mock_journaler);
expect_start_append(mock_journaler);
+ expect_set_append_batch_options(mock_image_ctx, mock_journaler, false);
C_SaferCond ctx;
mock_journal.open(&ctx);
@@ -958,6 +974,7 @@ TEST_F(TestMockJournal, ReplayOnDiskPostFlushError) {
expect_shut_down_replay(mock_image_ctx, mock_journal_replay, 0);
expect_flush_commit_position(mock_journaler);
expect_start_append(mock_journaler);
+ expect_set_append_batch_options(mock_image_ctx, mock_journaler, false);
C_SaferCond ctx;
mock_journal.open(&ctx);
@@ -1272,6 +1289,7 @@ TEST_F(TestMockJournal, ExternalReplay) {
InSequence seq;
expect_stop_append(mock_journaler, 0);
expect_start_append(mock_journaler);
+ expect_set_append_batch_options(mock_image_ctx, mock_journaler, false);
expect_shut_down_journaler(mock_journaler);
C_SaferCond start_ctx;
@@ -1303,6 +1321,7 @@ TEST_F(TestMockJournal, ExternalReplayFailure) {
InSequence seq;
expect_stop_append(mock_journaler, -EINVAL);
expect_start_append(mock_journaler);
+ expect_set_append_batch_options(mock_image_ctx, mock_journaler, false);
expect_shut_down_journaler(mock_journaler);
C_SaferCond start_ctx;
@@ -1486,4 +1505,27 @@ TEST_F(TestMockJournal, ForcePromoted) {
ASSERT_EQ(0, listener.ctx.wait());
}
+TEST_F(TestMockJournal, UserFlushed) {
+ REQUIRE_FEATURE(RBD_FEATURE_JOURNALING);
+
+ librbd::ImageCtx *ictx;
+ ASSERT_EQ(0, open_image(m_image_name, &ictx));
+
+ MockJournalImageCtx mock_image_ctx(*ictx);
+ MockJournal mock_journal(mock_image_ctx);
+ MockObjectDispatch mock_object_dispatch;
+ ::journal::MockJournaler mock_journaler;
+ MockJournalOpenRequest mock_open_request;
+ open_journal(mock_image_ctx, mock_journal, mock_object_dispatch,
+ mock_journaler, mock_open_request);
+ BOOST_SCOPE_EXIT_ALL(&) {
+ close_journal(mock_image_ctx, mock_journal, mock_journaler);
+ };
+
+ expect_set_append_batch_options(mock_image_ctx, mock_journaler, true);
+ mock_journal.user_flushed();
+
+ expect_shut_down_journaler(mock_journaler);
+}
+
} // namespace librbd