Skip to content

Commit

Permalink
test: move ReplicaofRejectOnLoad test from pytest into unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BorysTheDev committed Jan 6, 2025
1 parent 6e9409c commit a21a118
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 29 deletions.
8 changes: 8 additions & 0 deletions src/server/dragonfly_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,14 @@ TEST_F(DflyEngineTest, StreamMemInfo) {
EXPECT_GT(stream_mem_second, 0);
}

TEST_F(DflyEngineTest, ReplicaofRejectOnLoad) {
service_->SwitchState(GlobalState::ACTIVE, GlobalState::LOADING);

RespExpr res = Run({"REPLICAOF", "localhost", "3779"});

ASSERT_THAT(res, ErrArg("LOADING Dragonfly is loading the dataset in memory"));
}

// TODO: to test transactions with a single shard since then all transactions become local.
// To consider having a parameter in dragonfly engine controlling number of shards
// unconditionally from number of cpus. TO TEST BLPOP under multi for single/multi argument case.
Expand Down
29 changes: 0 additions & 29 deletions tests/dragonfly/replication_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1965,35 +1965,6 @@ async def test_client_pause_with_replica(df_factory, df_seeder_factory):
assert await seeder.compare(capture, port=replica.port)


async def test_replicaof_reject_on_load(df_factory, df_seeder_factory):
master = df_factory.create()
replica = df_factory.create(dbfilename=f"dump_{tmp_file_name()}")
df_factory.start_all([master, replica])

c_replica = replica.client()
await c_replica.execute_command(f"DEBUG POPULATE 8000000")

replica.stop()
replica.start()
c_replica = replica.client()
# Check replica of not alowed while loading snapshot
try:
# If this fails adjust `keys` and the `assert dbsize >= 30000` above.
# Keep in mind that if the assert False is triggered below, it doesn't mean
# that there is a bug because it could be the case that while executing
# INFO PERSISTENCE df is in loading state but when we call REPLICAOF df
# is no longer in loading state and the assertion false is triggered.
assert "loading:1" in (await c_replica.execute_command("INFO PERSISTENCE"))
await c_replica.execute_command(f"REPLICAOF localhost {master.port}")
assert False
except aioredis.BusyLoadingError as e:
assert "Dragonfly is loading the dataset in memory" in str(e)

# Check one we finish loading snapshot replicaof success
await wait_available_async(c_replica, timeout=180)
await c_replica.execute_command(f"REPLICAOF localhost {master.port}")


async def test_heartbeat_eviction_propagation(df_factory):
master = df_factory.create(
proactor_threads=1, cache_mode="true", maxmemory="256mb", enable_heartbeat_eviction="false"
Expand Down

0 comments on commit a21a118

Please sign in to comment.