From a21a11872ded50c6a58e5fa2055353c884ae392d Mon Sep 17 00:00:00 2001 From: Borys Date: Mon, 6 Jan 2025 11:06:46 +0200 Subject: [PATCH] test: move ReplicaofRejectOnLoad test from pytest into unit tests --- src/server/dragonfly_test.cc | 8 ++++++++ tests/dragonfly/replication_test.py | 29 ----------------------------- 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/src/server/dragonfly_test.cc b/src/server/dragonfly_test.cc index 3d55802f7f93..18230fe62e13 100644 --- a/src/server/dragonfly_test.cc +++ b/src/server/dragonfly_test.cc @@ -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. diff --git a/tests/dragonfly/replication_test.py b/tests/dragonfly/replication_test.py index a2695e5b2e81..c625540f82e7 100644 --- a/tests/dragonfly/replication_test.py +++ b/tests/dragonfly/replication_test.py @@ -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"