Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable unlock for all tests. #1185

Merged
merged 1 commit into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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