From 871a2cb292a53ab7d30273c9d36e1e5bc0bcafb9 Mon Sep 17 00:00:00 2001 From: sdong Date: Wed, 19 May 2021 10:58:13 -0700 Subject: [PATCH] Fix test issue in new env_test tests (#8319) Summary: The two new tests added to env_test don't clear sync points, so if tests are run in continuous mode, rather than parallel mode, the next test will trigger previous sync point and fail. Fix it. Pull Request resolved: https://github.com/facebook/rocksdb/pull/8319 Test Plan: Run the tests in continuous mode which used to fail and see them passing. Reviewed By: pdillinger Differential Revision: D28542562 fbshipit-source-id: 4052d487635188fe68a2a9df4b03d97b23f96720 --- env/env_test.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/env/env_test.cc b/env/env_test.cc index 1dd3c0449..c72390473 100644 --- a/env/env_test.cc +++ b/env/env_test.cc @@ -96,6 +96,11 @@ class EnvPosixTest : public testing::Test { Env* env_; bool direct_io_; EnvPosixTest() : env_(Env::Default()), direct_io_(false) {} + ~EnvPosixTest() { + SyncPoint::GetInstance()->DisableProcessing(); + SyncPoint::GetInstance()->LoadDependency({}); + SyncPoint::GetInstance()->ClearAllCallBacks(); + } }; class EnvPosixTestWithParam @@ -1414,7 +1419,7 @@ TEST_F(EnvPosixTest, MultiReadIOUringError) { ASSERT_OK(env_->NewRandomAccessFile(fname, &file, soptions)); bool io_uring_wait_cqe_called = false; - ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack( + SyncPoint::GetInstance()->SetCallBack( "PosixRandomAccessFile::MultiRead:io_uring_wait_cqe:return", [&](void* arg) { if (!io_uring_wait_cqe_called) { @@ -1423,7 +1428,7 @@ TEST_F(EnvPosixTest, MultiReadIOUringError) { ret = 1; } }); - ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing(); + SyncPoint::GetInstance()->EnableProcessing(); Status s = file->MultiRead(reqs.data(), reqs.size()); if (io_uring_wait_cqe_called) { @@ -1432,7 +1437,8 @@ TEST_F(EnvPosixTest, MultiReadIOUringError) { s.PermitUncheckedError(); } - ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing(); + SyncPoint::GetInstance()->DisableProcessing(); + SyncPoint::GetInstance()->ClearAllCallBacks(); } TEST_F(EnvPosixTest, MultiReadIOUringError2) { @@ -1449,14 +1455,14 @@ TEST_F(EnvPosixTest, MultiReadIOUringError2) { ASSERT_OK(env_->NewRandomAccessFile(fname, &file, soptions)); bool io_uring_submit_and_wait_called = false; - ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack( + SyncPoint::GetInstance()->SetCallBack( "PosixRandomAccessFile::MultiRead:io_uring_submit_and_wait:return1", [&](void* arg) { io_uring_submit_and_wait_called = true; ssize_t* ret = static_cast(arg); (*ret)--; }); - ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack( + SyncPoint::GetInstance()->SetCallBack( "PosixRandomAccessFile::MultiRead:io_uring_submit_and_wait:return2", [&](void* arg) { struct io_uring* iu = static_cast(arg); @@ -1464,7 +1470,7 @@ TEST_F(EnvPosixTest, MultiReadIOUringError2) { assert(io_uring_wait_cqe(iu, &cqe) == 0); io_uring_cqe_seen(iu, cqe); }); - ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing(); + SyncPoint::GetInstance()->EnableProcessing(); Status s = file->MultiRead(reqs.data(), reqs.size()); if (io_uring_submit_and_wait_called) { @@ -1473,7 +1479,8 @@ TEST_F(EnvPosixTest, MultiReadIOUringError2) { s.PermitUncheckedError(); } - ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing(); + SyncPoint::GetInstance()->DisableProcessing(); + SyncPoint::GetInstance()->ClearAllCallBacks(); } #endif // ROCKSDB_IOURING_PRESENT