Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(regression-test): Sentinel test stabilization #826

Merged
merged 16 commits into from
Feb 20, 2023
Merged
1 change: 0 additions & 1 deletion .github/workflows/regression-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ jobs:
export DRAGONFLY_PATH="${GITHUB_WORKSPACE}/build/dragonfly" # used by PyTests

pytest -sxvr dragonfly --ignore=dragonfly/replication_test.py

- name: Run PyTests replication test
timeout-minutes: 15
if: ${{ inputs.run_replication }}
Expand Down
2 changes: 1 addition & 1 deletion tests/dragonfly/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ tomli==2.0.1
wrapt==1.14.1
aioredis==2.0.1
pytest-asyncio==0.20.1

pytest-repeat==0.9.1
28 changes: 22 additions & 6 deletions tests/dragonfly/sentinel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ async def test_failover(df_local_factory, sentinel):

master_client = aioredis.Redis(port=master.port)
replica_client = aioredis.Redis(port=replica.port)
print("master: " + str(master.port) + " replica: " + str(replica.port), flush=True)

await replica_client.execute_command("REPLICAOF localhost " + str(master.port))

Expand All @@ -149,12 +150,27 @@ async def test_failover(df_local_factory, sentinel):
assert sentinel.slaves()[0]["port"] == str(master.port)

# Verify we can now write to replica and read replicated value from master.
await replica_client.set("key", "value")
await await_for(
lambda: master_client.get("key"),
lambda val: val == b"value",
10, "Timeout waiting for key to exist in replica."
)
assert await replica_client.set("key", "value"), "Failed to set key promoted replica."
try:
await await_for(
lambda: master_client.get("key"),
lambda val: val == b"value",
10, "Timeout waiting for key to exist in replica."
)
except AssertionError:
syncid, r_offset = await master_client.execute_command("DEBUG REPLICA OFFSET")
replicaoffset_cmd = "DFLY REPLICAOFFSET " + syncid.decode()
m_offset = await replica_client.execute_command(replicaoffset_cmd)
print(syncid.decode(), r_offset, m_offset)
print("replica client role:")
print(await replica_client.execute_command("role"))
print("master client role:")
print(await master_client.execute_command("role"))
print("replica client info:")
print(await replica_client.info())
print("master client info:")
print(await master_client.info())
raise


@pytest.mark.asyncio
Expand Down