Skip to content

Commit

Permalink
refactor: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
BorysTheDev committed Mar 7, 2024
1 parent aeda4fb commit d15d65c
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions tests/dragonfly/cluster_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,12 @@ async def list_counter(key, client: aioredis.RedisCluster):
for key, conn in zip(counter_keys, counter_connections)
]

seeder.stop()
await fill_task

# Generate capture, capture ignores counter keys
capture = await seeder.capture()

# Generate migration plan
for node_idx, node in enumerate(nodes):
random.shuffle(node.slots)
Expand Down Expand Up @@ -1071,9 +1077,6 @@ async def list_counter(key, client: aioredis.RedisCluster):
keeping = node.slots[num_outgoing:]
node.next_slots.extend(keeping)

seeder.stop()
await fill_task

iterations = 0
while True:
for node in nodes:
Expand All @@ -1089,23 +1092,18 @@ async def list_counter(key, client: aioredis.RedisCluster):

await asyncio.sleep(0.1)

# Generate capture, capture ignores counter keys
capture = await seeder.capture()

# Stop counters
for counter in counters:
counter.cancel()

# need this sleep to avoid race between finalize and config
await asyncio.sleep(0.5)
# Push new config
await push_config(json.dumps(await generate_config()), [node.admin_client for node in nodes])

# Transfer nodes
for node in nodes:
node.slots = node.next_slots
node.new_slots = []

# Push new config
await push_config(json.dumps(await generate_config()), [node.admin_client for node in nodes])

# Check counter consistency
cluster_client = aioredis.RedisCluster(host="localhost", port=nodes[0].instance.port)
for key in counter_keys:
Expand Down

0 comments on commit d15d65c

Please sign in to comment.