From db9cbddc6fbf95d9baee7c51ff0bda3e9d36982d Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Tue, 22 Nov 2022 13:07:17 -0800 Subject: [PATCH] Deflake DBTest2.TraceAndReplay by relaxing latency checks (#10979) Summary: Since the latency measurement uses real time it is possible for the operation to complete in zero microseconds and then fail these checks. We saw this with the operation that invokes Get() on an invalid CF. This PR relaxes the assertions to allow for operations completing in zero microseconds. Pull Request resolved: https://github.com/facebook/rocksdb/pull/10979 Reviewed By: riversand963 Differential Revision: D41478300 Pulled By: ajkr fbshipit-source-id: 50ef096bd8f0162b31adb46f54ae6ddc337d0a5e --- db/db_test2.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/db/db_test2.cc b/db/db_test2.cc index dd4742e78..97d671c14 100644 --- a/db/db_test2.cc +++ b/db/db_test2.cc @@ -4523,7 +4523,7 @@ TEST_F(DBTest2, TraceAndReplay) { ASSERT_OK(replayer->Prepare()); // Replay using 1 thread, 1x speed. ASSERT_OK(replayer->Replay(ReplayOptions(1, 1.0), res_cb)); - ASSERT_GT(res_handler.GetAvgLatency(), 0.0); + ASSERT_GE(res_handler.GetAvgLatency(), 0.0); ASSERT_EQ(res_handler.GetNumWrites(), 8); ASSERT_EQ(res_handler.GetNumGets(), 3); ASSERT_EQ(res_handler.GetNumIterSeeks(), 2); @@ -4549,7 +4549,7 @@ TEST_F(DBTest2, TraceAndReplay) { // Re-replay using 2 threads, 2x speed. ASSERT_OK(replayer->Prepare()); ASSERT_OK(replayer->Replay(ReplayOptions(2, 2.0), res_cb)); - ASSERT_GT(res_handler.GetAvgLatency(), 0.0); + ASSERT_GE(res_handler.GetAvgLatency(), 0.0); ASSERT_EQ(res_handler.GetNumWrites(), 8); ASSERT_EQ(res_handler.GetNumGets(), 3); ASSERT_EQ(res_handler.GetNumIterSeeks(), 2); @@ -4559,7 +4559,7 @@ TEST_F(DBTest2, TraceAndReplay) { // Re-replay using 2 threads, 1/2 speed. ASSERT_OK(replayer->Prepare()); ASSERT_OK(replayer->Replay(ReplayOptions(2, 0.5), res_cb)); - ASSERT_GT(res_handler.GetAvgLatency(), 0.0); + ASSERT_GE(res_handler.GetAvgLatency(), 0.0); ASSERT_EQ(res_handler.GetNumWrites(), 8); ASSERT_EQ(res_handler.GetNumGets(), 3); ASSERT_EQ(res_handler.GetNumIterSeeks(), 2); @@ -4757,7 +4757,7 @@ TEST_F(DBTest2, TraceAndManualReplay) { // end, or Prepare() was not called. ASSERT_TRUE(s.IsIncomplete()); ASSERT_TRUE(replayer->Next(nullptr).IsIncomplete()); - ASSERT_GT(res_handler.GetAvgLatency(), 0.0); + ASSERT_GE(res_handler.GetAvgLatency(), 0.0); ASSERT_EQ(res_handler.GetNumWrites(), 9); ASSERT_EQ(res_handler.GetNumGets(), 3); ASSERT_EQ(res_handler.GetNumIterSeeks(), 8); @@ -4791,7 +4791,7 @@ TEST_F(DBTest2, TraceAndManualReplay) { ASSERT_EQ("write1", value); ASSERT_OK(db2->Get(ro, handles[0], "trace-record-write2", &value)); ASSERT_EQ("write2", value); - ASSERT_GT(res_handler.GetAvgLatency(), 0.0); + ASSERT_GE(res_handler.GetAvgLatency(), 0.0); ASSERT_EQ(res_handler.GetNumWrites(), 1); ASSERT_EQ(res_handler.GetNumGets(), 0); ASSERT_EQ(res_handler.GetNumIterSeeks(), 0); @@ -4816,7 +4816,7 @@ TEST_F(DBTest2, TraceAndManualReplay) { record.reset(new GetQueryTraceRecord(invalid_cf_id, "whatever", fake_ts++)); ASSERT_TRUE(replayer->Execute(record, &result).IsCorruption()); ASSERT_TRUE(result == nullptr); - ASSERT_GT(res_handler.GetAvgLatency(), 0.0); + ASSERT_GE(res_handler.GetAvgLatency(), 0.0); ASSERT_EQ(res_handler.GetNumWrites(), 0); ASSERT_EQ(res_handler.GetNumGets(), 2); ASSERT_EQ(res_handler.GetNumIterSeeks(), 0); @@ -4845,7 +4845,7 @@ TEST_F(DBTest2, TraceAndManualReplay) { ASSERT_TRUE(replayer->Execute(record, &result).IsCorruption()); ASSERT_TRUE(result == nullptr); } - ASSERT_GT(res_handler.GetAvgLatency(), 0.0); + ASSERT_GE(res_handler.GetAvgLatency(), 0.0); ASSERT_EQ(res_handler.GetNumWrites(), 0); ASSERT_EQ(res_handler.GetNumGets(), 0); ASSERT_EQ(res_handler.GetNumIterSeeks(), 4); // Seek x 2 in two iterations @@ -4900,7 +4900,7 @@ TEST_F(DBTest2, TraceAndManualReplay) { std::vector({"a"}), fake_ts++)); ASSERT_TRUE(replayer->Execute(record, &result).IsInvalidArgument()); ASSERT_TRUE(result == nullptr); - ASSERT_GT(res_handler.GetAvgLatency(), 0.0); + ASSERT_GE(res_handler.GetAvgLatency(), 0.0); ASSERT_EQ(res_handler.GetNumWrites(), 0); ASSERT_EQ(res_handler.GetNumGets(), 0); ASSERT_EQ(res_handler.GetNumIterSeeks(), 0);