Skip to content

Commit

Permalink
fix(tests): Wait for async in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
  • Loading branch information
dranikpg committed Feb 11, 2023
1 parent 88bde33 commit c953616
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/server/dragonfly_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ TEST_F(DflyEngineTest, Multi) {
ASSERT_THAT(resp.GetVec(), ElementsAre(ArgType(RespExpr::NIL), ArgType(RespExpr::NIL)));

atomic_bool tx_empty = true;

shard_set->RunBriefInParallel([&](EngineShard* shard) {
if (!shard->txq()->Empty())
tx_empty.store(false);
Expand Down Expand Up @@ -264,6 +263,7 @@ TEST_F(DflyEngineTest, MultiConsistent) {

mset_fb.Join();
fb.Join();

ASSERT_FALSE(service_->IsLocked(0, kKey1));
ASSERT_FALSE(service_->IsLocked(0, kKey4));
ASSERT_FALSE(service_->IsShardSetLocked());
Expand Down Expand Up @@ -865,6 +865,7 @@ TEST_F(DflyEngineTest, Bug468) {

resp = Run({"exec"});
ASSERT_THAT(resp, ErrArg("not an integer"));

ASSERT_FALSE(service_->IsLocked(0, "foo"));

resp = Run({"eval", "return redis.call('set', 'foo', 'bar', 'EX', 'moo')", "1", "foo"});
Expand Down
5 changes: 5 additions & 0 deletions src/server/test_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ RespExpr BaseFamilyTest::Run(std::string_view id, ArgSlice slice) {

DCHECK(context->transaction == nullptr);

auto cmd = absl::AsciiStrToUpper(slice.front());
if (cmd == "EVAL" || cmd == "EVALSHA" || cmd == "EXEC") {
shard_set->AwaitRunningOnShardQueue([](auto*) {}); // Wait for async UnlockMulti.
}

unique_lock lk(mu_);
last_cmd_dbg_info_ = context->last_command_debug;

Expand Down

0 comments on commit c953616

Please sign in to comment.