From 707d7f02654cb9da73918f1d536eb36948e7e007 Mon Sep 17 00:00:00 2001 From: Borys Date: Sun, 20 Apr 2025 12:51:56 +0300 Subject: [PATCH] test: add check for removing readonly replica (#4963) --- tests/dragonfly/cluster_test.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/dragonfly/cluster_test.py b/tests/dragonfly/cluster_test.py index 716c2f239..f6d2bc5d4 100644 --- a/tests/dragonfly/cluster_test.py +++ b/tests/dragonfly/cluster_test.py @@ -3163,7 +3163,7 @@ async def test_readonly_replication( await m1_node.client.execute_command("SET X 1") logging.debug("start replication") - await r1_node.admin_client.execute_command(f"replicaof localhost {m1_node.instance.port}") + await r1_node.admin_client.execute_command(f"replicaof localhost {m1_node.instance.admin_port}") await wait_available_async(r1_node.admin_client) @@ -3174,6 +3174,23 @@ async def test_readonly_replication( # This behavior can be changed in the future assert await r1_node.client.execute_command("GET Y") == None + m1_node.replicas = [] + + logging.debug("Push config without replica") + await push_config( + json.dumps(generate_config(master_nodes)), [node.admin_client for node in nodes] + ) + + with pytest.raises(redis.exceptions.ResponseError) as moved_error: + await r1_node.client.execute_command("GET X") + + assert str(moved_error.value) == f"MOVED 7165 127.0.0.1:{instances[0].port}" + + with pytest.raises(redis.exceptions.ResponseError) as moved_error: + await r1_node.client.execute_command("GET Y") + + assert str(moved_error.value) == f"MOVED 3036 127.0.0.1:{instances[0].port}" + @dfly_args({"proactor_threads": 2, "cluster_mode": "yes"}) async def test_cancel_blocking_cmd_during_mygration_finalization(df_factory: DflyInstanceFactory):