2024-03-27 07:31:19 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import redis
|
2024-05-06 15:38:13 +00:00
|
|
|
import time
|
2024-03-27 07:31:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
max_unaccounted = 200 * 1024 * 1024 # 200mb
|
|
|
|
|
|
|
|
client = redis.Redis(decode_responses=True)
|
|
|
|
info = client.info("memory")
|
|
|
|
print(f'Used memory {info["used_memory"]}, rss {info["used_memory_rss"]}')
|
|
|
|
assert info["used_memory_rss"] - info["used_memory"] < max_unaccounted
|
|
|
|
|
|
|
|
info = client.info("replication")
|
|
|
|
assert info["role"] == "master"
|
|
|
|
replication_state = info["slave0"]
|
|
|
|
assert replication_state["state"] == "stable_sync"
|
|
|
|
|
2024-05-06 15:38:13 +00:00
|
|
|
def is_zero_lag(replication_state):
|
|
|
|
return replication_state["lag"] == 0
|
|
|
|
|
|
|
|
# Wait for 10 seconds for lag to be zero
|
|
|
|
for _ in range(10):
|
|
|
|
if is_zero_lag(replication_state):
|
|
|
|
break
|
|
|
|
time.sleep(1)
|
|
|
|
replication_state = client.info("replication")["slave0"]
|
|
|
|
|
|
|
|
assert replication_state["lag"] == 0, f"Lag is bad, expected 0, got {replication_state['lag']}"
|
|
|
|
|
2024-03-27 07:31:19 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|