Skip to content

Commit

Permalink
Enable unlock for all tests. (#1185)
Browse files Browse the repository at this point in the history
  • Loading branch information
chakaz committed May 6, 2023
1 parent db5d6a0 commit 5df0d92
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 13 deletions.
2 changes: 0 additions & 2 deletions src/server/dragonfly_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,6 @@ TEST_F(DflyEngineTest, LimitMemory) {
}

TEST_F(DflyEngineTest, FlushAll) {
DisableLockCheck();

auto fb0 = pp_->at(0)->LaunchFiber([&] { Run({"flushall"}); });

auto fb1 = pp_->at(1)->LaunchFiber([&] {
Expand Down
2 changes: 0 additions & 2 deletions src/server/multi_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ TEST_F(MultiTest, Multi) {
}

TEST_F(MultiTest, MultiGlobalCommands) {
DisableLockCheck();

ASSERT_THAT(Run({"set", "key", "val"}), "OK");

ASSERT_THAT(Run({"multi"}), "OK");
Expand Down
11 changes: 4 additions & 7 deletions src/server/test_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,21 @@ void BaseFamilyTest::SetUp() {
LOG(INFO) << "Starting " << test_info->name();
}

void BaseFamilyTest::DisableLockCheck() {
check_locks_ = false;
}

unsigned BaseFamilyTest::NumLocked() {
atomic_uint count = 0;
shard_set->RunBriefInParallel([&](EngineShard* shard) {
for (const auto& db : shard->db_slice().databases()) {
if (db == nullptr) {
continue;
}
count += db->trans_locks.size();
}
});
return count;
}

void BaseFamilyTest::TearDown() {
if (check_locks_) {
CHECK_EQ(NumLocked(), 0U);
}
CHECK_EQ(NumLocked(), 0U);

service_->Shutdown();
service_.reset();
Expand Down
2 changes: 0 additions & 2 deletions src/server/test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@ class BaseFamilyTest : public ::testing::Test {
const facade::Connection::PubMessage::MessageData& GetPublishedMessage(std::string_view conn_id,
size_t index) const;

void DisableLockCheck();
static unsigned NumLocked();

std::unique_ptr<util::ProactorPool> pp_;
std::unique_ptr<Service> service_;
unsigned num_threads_ = 3;
bool check_locks_ = true;

absl::flat_hash_map<std::string, std::unique_ptr<TestConnWrapper>> connections_;
Mutex mu_;
Expand Down

0 comments on commit 5df0d92

Please sign in to comment.