Skip to content

Commit 707d7f0

Browse files
authored
test: add check for removing readonly replica (#4963)
1 parent 2ca5bf1 commit 707d7f0

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/dragonfly/cluster_test.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3163,7 +3163,7 @@ async def test_readonly_replication(
31633163
await m1_node.client.execute_command("SET X 1")
31643164

31653165
logging.debug("start replication")
3166-
await r1_node.admin_client.execute_command(f"replicaof localhost {m1_node.instance.port}")
3166+
await r1_node.admin_client.execute_command(f"replicaof localhost {m1_node.instance.admin_port}")
31673167

31683168
await wait_available_async(r1_node.admin_client)
31693169

@@ -3174,6 +3174,23 @@ async def test_readonly_replication(
31743174
# This behavior can be changed in the future
31753175
assert await r1_node.client.execute_command("GET Y") == None
31763176

3177+
m1_node.replicas = []
3178+
3179+
logging.debug("Push config without replica")
3180+
await push_config(
3181+
json.dumps(generate_config(master_nodes)), [node.admin_client for node in nodes]
3182+
)
3183+
3184+
with pytest.raises(redis.exceptions.ResponseError) as moved_error:
3185+
await r1_node.client.execute_command("GET X")
3186+
3187+
assert str(moved_error.value) == f"MOVED 7165 127.0.0.1:{instances[0].port}"
3188+
3189+
with pytest.raises(redis.exceptions.ResponseError) as moved_error:
3190+
await r1_node.client.execute_command("GET Y")
3191+
3192+
assert str(moved_error.value) == f"MOVED 3036 127.0.0.1:{instances[0].port}"
3193+
31773194

31783195
@dfly_args({"proactor_threads": 2, "cluster_mode": "yes"})
31793196
async def test_cancel_blocking_cmd_during_mygration_finalization(df_factory: DflyInstanceFactory):

0 commit comments

Comments
 (0)