Skip to content

Commit

Permalink
up redis versions in CI (#26)
Browse files Browse the repository at this point in the history
* add Redis 7.2 to CI

* fix aioredis tests for Redis 7.2 stdout

---------

Co-authored-by: Anton Ilyushenkov <[email protected]>
  • Loading branch information
DriverX and Anton Ilyushenkov authored Nov 29, 2023
1 parent c293324 commit d2b6977
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 37 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ jobs:
strategy:
matrix:
redis-version:
- '6.0.17'
- '6.2.10'
- '7.0.8'
- '6.0.20'
- '6.2.14'
- '7.0.14'
- '7.2.3'
with_aioredis:
- 'yes'
- 'no'
Expand Down Expand Up @@ -127,17 +128,18 @@ jobs:
- '3.2.13'
- '4.0.14'
- '5.0.9'
- '6.0.12'
- '6.2.6'
- '7.0.2'
- '6.0.20'
- '6.2.14'
- '7.0.14'
- '7.2.3'
steps:
- uses: actions/checkout@v3
- name: 'Set up Python'
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Build redis-server v${{ matrix.redis-version }}
uses: shogo82148/actions-setup-redis@v1.17.0
uses: shogo82148/actions-setup-redis@v1
with:
redis-version: '${{ matrix.redis-version }}'
auto-start: 'false'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Requirements
------------

* [Python](https://www.python.org) 3.8+
* [async_timeout](https://pypi.org/project/async_timeout/)
* [async_timeout](https://pypi.org/project/async_timeout/) (only for Python < 3.11)

Features
--------
Expand Down
5 changes: 0 additions & 5 deletions etc/redis/Dockerfile

This file was deleted.

10 changes: 0 additions & 10 deletions etc/redis/redis-cluster.tmpl

This file was deleted.

79 changes: 65 additions & 14 deletions tests/aioredis_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,16 @@ def format_version(srv):
return "redis_v{}".format(".".join(map(str, VERSIONS[srv])))


_ready_check_log_entries = [
"The server is now ready to accept connections ",
"Ready to accept connections tcp",
]
_slave_ready_check_log_entries = [
"sync: Finished with success",
"MASTER <-> REPLICA sync: Finished with success",
]


@pytest.fixture(scope="session")
def start_server(_proc, request, unused_port, server_bin):
"""Starts Redis server instance.
Expand Down Expand Up @@ -306,6 +316,8 @@ def maker(name, config_lines=None, *, slaveof=None, password=None):
write("dir ", data_dir)
write("dbfilename", dumpfile)
write("port", port)
if version >= (7, 2):
write("locale-collate", '"C"')
if unixsocket:
write("unixsocket", unixsocket)
tmp_files.append(unixsocket)
Expand Down Expand Up @@ -340,6 +352,12 @@ def maker(name, config_lines=None, *, slaveof=None, password=None):
str(port),
]

if version >= (7, 2):
args += [
"--locale-collate",
"C",
]

if password:
args += [
"--requirepass",
Expand Down Expand Up @@ -368,17 +386,25 @@ def maker(name, config_lines=None, *, slaveof=None, password=None):
"--unixsocket",
unixsocket,
]

if verbose:
print(f"stdout file: {stdout_file}")
print("Redis args: " + " ".join(args))

f = open(stdout_file, "w")
# f = open("redis.log", "w")
atexit.register(f.close)
proc = _proc(
*args,
shell=False,
stdout=f,
stderr=subprocess.STDOUT,
_clear_tmp_files=tmp_files,
)
with open(stdout_file, "r") as f_ro:
proc = _proc(
*args,
shell=False,
stdout=f,
stderr=subprocess.STDOUT,
_clear_tmp_files=tmp_files,
)

with open(stdout_file, "rt") as f_ro:
redis_is_ready = False
slave_is_ready = False
for _ in timeout(10):
if proc.poll() is not None and proc.returncode != 0:
f_ro.seek(0)
Expand All @@ -388,14 +414,23 @@ def maker(name, config_lines=None, *, slaveof=None, password=None):
log = f_ro.readline()
if log and verbose:
print(name, ":", log, end="")
if "The server is now ready to accept connections " in log:
for ready_check_entry in _ready_check_log_entries:
if ready_check_entry in log:
redis_is_ready = True
break
if redis_is_ready:
break

if slaveof is not None:
for _ in timeout(10):
log = f_ro.readline()
if log and verbose:
print(name, ":", log, end="")
if "sync: Finished with success" in log:
for ready_check_entry in _slave_ready_check_log_entries:
if ready_check_entry in log:
slave_is_ready = True
break
if slave_is_ready:
break
info = RedisServer(name, tcp_address, unixsocket, version, password)
servers.setdefault(name, info)
Expand Down Expand Up @@ -454,12 +489,28 @@ def maker(
write("sentinel failover-timeout", master.name, failover_timeout)
write("sentinel auth-pass", master.name, master.password)

f = open(stdout_file, "w")
atexit.register(f.close)
proc = _proc(
args = [
server_bin,
config,
"--sentinel",
]

if version >= (7, 2):
args += [
"--locale-collate",
"C",
]

if verbose:
print(f"stdout file: {stdout_file}")
print("Redis args: " + " ".join(args))

# sys.exit(1)

f = open(stdout_file, "w")
atexit.register(f.close)
proc = _proc(
*args,
stdout=f,
stderr=subprocess.STDOUT,
_clear_tmp_files=tmp_files,
Expand All @@ -470,7 +521,7 @@ def maker(
all_slaves = set()
else:
all_slaves = {m.name for m in masters}
with open(stdout_file, "rt") as f:
with open(stdout_file, "r") as f:
for _ in timeout(30):
assert proc.poll() is None, ("Process terminated", proc.returncode)
log = f.readline()
Expand Down

0 comments on commit d2b6977

Please sign in to comment.