Repository: kudu Updated Branches: refs/heads/master c5b07fa8f -> e14bb60cc
[client-test] one more test for AUTO_FLUSH_BACKGROUND An additional test for the AUTO_FLUSH_BACKGROUND flush mode: verify that it's safe to perform synchronous and/or asynchronous flush while having the auto-flusher thread running in the background. Change-Id: I3bd5d248d4d44393689c8da81ed669395c393257 Reviewed-on: http://gerrit.cloudera.org:8080/4492 Tested-by: Kudu Jenkins Reviewed-by: David Ribeiro Alves <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/799e067b Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/799e067b Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/799e067b Branch: refs/heads/master Commit: 799e067b4ad9446d22a4c00796ccda909a69a91b Parents: c5b07fa Author: Alexey Serbin <[email protected]> Authored: Tue Sep 20 22:03:25 2016 -0700 Committer: Alexey Serbin <[email protected]> Committed: Fri Sep 23 19:11:18 2016 +0000 ---------------------------------------------------------------------- src/kudu/client/client-test.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/799e067b/src/kudu/client/client-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/client/client-test.cc b/src/kudu/client/client-test.cc index 8da6d88..25b141a 100644 --- a/src/kudu/client/client-test.cc +++ b/src/kudu/client/client-test.cc @@ -2429,6 +2429,28 @@ TEST_F(ClientTest, TestFlushModesCompareOpRatesRandomSize) { EXPECT_GT(t_afs.wall, t_afb.wall); } +// A test to verify that it's safe to perform synchronous and/or asynchronous +// flush while having the auto-flusher thread running in the background. +TEST_F(ClientTest, TestAutoFlushBackgroundAndExplicitFlush) { + const size_t kIterNum = AllowSlowTests() ? 8192 : 1024; + shared_ptr<KuduSession> session(client_->NewSession()); + // The background flush interval is short to have more contention. + ASSERT_OK(session->SetMutationBufferFlushInterval(3)); + ASSERT_OK(session->SetFlushMode(KuduSession::AUTO_FLUSH_BACKGROUND)); + for (size_t i = 0; i < kIterNum; i += 2) { + ASSERT_OK(ApplyInsertToSession(session.get(), client_table_, i, i, "x")); + SleepFor(MonoDelta::FromMilliseconds(1)); + session->FlushAsync(nullptr); + ASSERT_OK(ApplyInsertToSession(session.get(), client_table_, i + 1, i + 1, "y")); + SleepFor(MonoDelta::FromMilliseconds(1)); + ASSERT_OK(session->Flush()); + } + EXPECT_EQ(0, session->CountPendingErrors()); + EXPECT_FALSE(session->HasPendingOperations()); + // Check that all rows have reached the table. + EXPECT_EQ(kIterNum, CountRowsFromClient(client_table_.get())); +} + // A test which verifies that a session in AUTO_FLUSH_BACKGROUND mode can // be safely abandoned: its pending data should not be flushed. // This test also checks that the reference to a session stored by the
