Skip to content

Commit

Permalink
fix(cluster): fix #2532 tests redis client close errors
Browse files Browse the repository at this point in the history
  • Loading branch information
BorysTheDev committed Feb 5, 2024
1 parent 5c00299 commit 3ceab2c
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions tests/dragonfly/cluster_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ async def test_cluster_slots_in_replicas(df_local_factory):
ip="127.0.0.1", port=master.port, answer=res[0], rep_ip="127.0.0.1", rep_port=replica.port
)

await c_master.close()
await c_replica.close()


@dfly_args({"cluster_mode": "emulated", "cluster_announce_ip": "127.0.0.2"})
async def test_cluster_info(async_client):
Expand Down Expand Up @@ -299,6 +302,11 @@ async def test_cluster_slot_ownership_changes(df_local_factory: DflyInstanceFact
assert (await c_nodes[0].get("KEY0")) == "value"
assert await c_nodes[1].execute_command("DBSIZE") == 0

for node in c_nodes:
await node.close()
for node in c_nodes_admin:
await node.close()


# Tests that master commands to the replica are applied regardless of slot ownership
@dfly_args({"proactor_threads": 4, "cluster_mode": "yes"})
Expand Down Expand Up @@ -408,6 +416,11 @@ async def test_cluster_replica_sets_non_owned_keys(df_local_factory):
assert await c_master.execute_command("dbsize") == 0
assert await c_replica.execute_command("dbsize") == 0

await c_master.close()
await c_master_admin.close()
await c_replica.close()
await c_replica_admin.close()


@dfly_args({"proactor_threads": 4, "cluster_mode": "yes"})
async def test_cluster_flush_slots_after_config_change(df_local_factory: DflyInstanceFactory):
Expand Down Expand Up @@ -515,6 +528,11 @@ async def test_cluster_flush_slots_after_config_change(df_local_factory: DflyIns
assert await c_master.execute_command("dbsize") == (100_000 - slot_0_size)
assert await c_replica.execute_command("dbsize") == (100_000 - slot_0_size)

await c_master.close()
await c_master_admin.close()
await c_replica.close()
await c_replica_admin.close()


@dfly_args({"proactor_threads": 4, "cluster_mode": "yes", "admin_port": 30001})
async def test_cluster_blocking_command(df_server):
Expand Down Expand Up @@ -559,6 +577,9 @@ async def test_cluster_blocking_command(df_server):
await v2
assert "MOVED" in str(e_info.value)

await c_master.close()
await c_master_admin.close()


@dfly_args({"proactor_threads": 4, "cluster_mode": "yes"})
async def test_cluster_native_client(
Expand Down Expand Up @@ -742,6 +763,14 @@ async def test_random_keys():

await test_random_keys()
await client.close()
for node in c_masters:
await node.close()
for node in c_masters_admin:
await node.close()
for node in c_replicas:
await node.close()
for node in c_replicas_admin:
await node.close()


@dfly_args({"proactor_threads": 4, "cluster_mode": "yes"})
Expand Down Expand Up @@ -823,8 +852,10 @@ async def test_cluster_slot_migration(df_local_factory: DflyInstanceFactory):
c_nodes_admin,
)

await c_nodes_admin[0].close()
await c_nodes_admin[1].close()
for node in c_nodes:
await node.close()
for node in c_nodes_admin:
await node.close()


@dfly_args({"proactor_threads": 4, "cluster_mode": "yes"})
Expand Down Expand Up @@ -943,5 +974,7 @@ async def test_cluster_data_migration(df_local_factory: DflyInstanceFactory):
assert await c_nodes[1].get("KEY19") == "value"
assert await c_nodes[1].execute_command("DBSIZE") == 17

await c_nodes_admin[0].close()
await c_nodes_admin[1].close()
for node in c_nodes:
await node.close()
for node in c_nodes_admin:
await node.close()

0 comments on commit 3ceab2c

Please sign in to comment.