redis in fedora 36

This commit is contained in:
Emmanuel Garette 2022-07-08 13:23:01 +02:00
parent ee2822e46f
commit 1f6fddc729
5 changed files with 79 additions and 2 deletions

View file

@ -1,5 +1,5 @@
format: '0.1' format: '0.1'
description: Redis description: Redis
depends: depends:
- base-fedora-35 - base-fedora-36
provider: Redis provider: Redis

View file

@ -9,6 +9,7 @@
<file>/etc/pki/ca-trust/source/anchors/ca_Redis.crt</file> <file>/etc/pki/ca-trust/source/anchors/ca_Redis.crt</file>
<file>/etc/pki/tls/certs/redis.crt</file> <file>/etc/pki/tls/certs/redis.crt</file>
<file owner="root" group="redis" mode="440">/etc/pki/tls/private/redis.key</file> <file owner="root" group="redis" mode="440">/etc/pki/tls/private/redis.key</file>
<file>/tests/redis.yml</file>
</service> </service>
</services> </services>
<variables> <variables>

View file

@ -180,7 +180,9 @@ tcp-keepalive %%redis_tcp_keepalive
# #
# tls-client-key-file-pass secret # tls-client-key-file-pass secret
# Configure a DH parameters file to enable Diffie-Hellman (DH) key exchange: # Configure a DH parameters file to enable Diffie-Hellman (DH) key exchange,
# required by older versions of OpenSSL (<3.0). Newer versions do not require
# this configuration and recommend against it.
# #
# tls-dh-params-file redis.dh # tls-dh-params-file redis.dh
@ -485,7 +487,10 @@ rdb-del-sync-files no
# The Append Only File will also be created inside this directory. # The Append Only File will also be created inside this directory.
# #
# Note that you must specify a directory here, not a file name. # Note that you must specify a directory here, not a file name.
#>GNUNUX
#dir /var/lib/redis
dir /srv/redis dir /srv/redis
#<GNUNUX
################################# REPLICATION ################################# ################################# REPLICATION #################################

View file

@ -0,0 +1,3 @@
address: %%ip_eth0
username: %%normalize_family(%%account.remote)
password: %%account.password

View file

@ -0,0 +1,68 @@
from yaml import load, SafeLoader
from os import environ
from datetime import timedelta
from time import sleep
from pytest import raises
from redis import Redis
from redis.exceptions import AuthenticationError, ResponseError
def test_redis_no_password():
conf_file = f'{environ["MACHINE_TEST_DIR"]}/redis.yml'
with open(conf_file) as yaml:
data = load(yaml, Loader=SafeLoader)
r = Redis(data['address'], db=15)
with raises(AuthenticationError):
r.get("Persistent")
def test_redis_wrong_password():
conf_file = f'{environ["MACHINE_TEST_DIR"]}/redis.yml'
with open(conf_file) as yaml:
data = load(yaml, Loader=SafeLoader)
r = Redis(data['address'], db=15, username=data['username'], password='a')
with raises(ResponseError):
r.get("Persistent")
def test_redis_wrong_user():
conf_file = f'{environ["MACHINE_TEST_DIR"]}/redis.yml'
with open(conf_file) as yaml:
data = load(yaml, Loader=SafeLoader)
r = Redis(data['address'], db=15, username="a", password=data['password'])
with raises(ResponseError):
r.get("Persistent")
# FIXME
# FIXME
# FIXMEdef test_redis_no_user():
# FIXME conf_file = f'{environ["MACHINE_TEST_DIR"]}/redis.yml'
# FIXME with open(conf_file) as yaml:
# FIXME data = load(yaml, Loader=SafeLoader)
# FIXME r = Redis(data['address'], db=15, password=data['password'])
# FIXME with raises(ResponseError):
# FIXME r.get("Persistent")
def test_redis_migration():
conf_file = f'{environ["MACHINE_TEST_DIR"]}/redis.yml'
with open(conf_file) as yaml:
data = load(yaml, Loader=SafeLoader)
r = Redis(data['address'], db=15, username=data['username'], password=data['password'])
if 'FIRST_RUN' in environ:
assert r.mset({"Persistent": "yes!"})
assert r.get("Persistent") == b'yes!'
def test_redis_set_get():
conf_file = f'{environ["MACHINE_TEST_DIR"]}/redis.yml'
with open(conf_file) as yaml:
data = load(yaml, Loader=SafeLoader)
r = Redis(data['address'], db=15, username=data['username'], password=data['password'])
r.setex("runner",
timedelta(seconds=1),
value="now you see me, now you don't"
)
assert r.exists("runner")
sleep(1)
assert not r.exists("runner")