Skip to content

Commit aab408d

Browse files
authored
Merge pull request #118 from RedisLabsModules/add_rdb_preamble_flag
Add use rdb preamble flag Fix caching in CI (use different keys for different platforms)
2 parents a727b81 + 98768e5 commit aab408d

File tree

7 files changed

+49
-19
lines changed

7 files changed

+49
-19
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: CI
22

33
on:
44
push:
5+
branches:
6+
- master
57
pull_request:
68
schedule:
79
- cron: "0 0 * * *"
@@ -10,7 +12,7 @@ jobs:
1012
build-ubuntu:
1113
name: Test on ${{ matrix.platform }} with Python ${{ matrix.python }}
1214
runs-on: ${{ matrix.platform }}
13-
timeout-minutes: 10
15+
timeout-minutes: 40
1416
strategy:
1517
matrix:
1618
platform: ['ubuntu-20.04', 'ubuntu-18.04', 'ubuntu-16.04']
@@ -37,23 +39,26 @@ jobs:
3739
with:
3840
path: ~/.cache/pip # This path is specific to Ubuntu
3941
# Look to see if there is a cache hit for the corresponding requirements file
40-
key: ${{ runner.os }}-${{ matrix.python }}-pip-${{ hashFiles('requirements.txt') }}
42+
key: ${{ matrix.platform }}-${{ matrix.python }}-pyproject.toml-${{ hashFiles('pyproject.toml') }}
4143
restore-keys: |
42-
${{ runner.os }}-${{ matrix.python }}-pip-
43-
${{ runner.os }}-${{ matrix.python }}-
44+
${{ matrix.platform }}-${{ matrix.python }}-pyproject.toml-${{hashFiles('pyproject.toml')}}}
4445
4546
- name: Install Python dependencies
4647
run: |
4748
sudo apt-get install -y python-setuptools python3-setuptools
4849
pip install poetry
49-
poetry install
50+
poetry config virtualenvs.create false
51+
poetry export --dev --without-hashes -o requirements-${{matrix.platform}}-${{matrix.python}}.txt
52+
pip install -r requirements-${{matrix.platform}}-${{matrix.python}}.txt
5053
5154
- name: Cache Redis
5255
id: cache-redis
5356
uses: actions/cache@v1
5457
with:
5558
path: redis
56-
key: ${{ runner.os }}-redis
59+
key: ${{ matrix.platform }}-${{ matrix.python }}-redis
60+
restore-keys: |
61+
${{ matrix.platform }}-${{ matrix.python }}-redis
5762
5863
- name: Install Redis Server test dependencies
5964
if: steps.cache-redis.outputs.cache-hit != 'true'
@@ -70,7 +75,7 @@ jobs:
7075
./utils/gen-test-certs.sh
7176
7277
- name: Unit Test with pytest
73-
timeout-minutes: 5
78+
timeout-minutes: 10
7479
run: |
7580
TLS_CERT=./redis/tests/tls/redis.crt \
7681
TLS_KEY=./redis/tests/tls/redis.key \

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ usage: RLTest [-h] [--version] [--module MODULE] [--module-args MODULE_ARGS]
3939
[--env-only] [--clear-logs] [--log-dir LOG_DIR] [--use-slaves]
4040
[--shards-count SHARDS_COUNT] [--download-enterprise-binaries]
4141
[--proxy-binary-path PROXY_BINARY_PATH]
42-
[--enterprise-lib-path ENTERPRISE_LIB_PATH] [-r] [--use-aof]
42+
[--enterprise-lib-path ENTERPRISE_LIB_PATH] [-r]
43+
[--use-aof] [--use-rdb-preamble]
4344
[--debug-print] [-V] [--vg-suppressions VG_SUPPRESSIONS]
4445
[--vg-options VG_OPTIONS] [--vg-no-leakcheck] [--vg-verbose]
4546
[--vg-no-fail-on-errors] [-i] [--debugger DEBUGGER] [-s]
@@ -120,6 +121,7 @@ optional arguments:
120121
efforts, if the env can not be reused then it will be
121122
taken down. (default: False)
122123
--use-aof use aof instead of rdb (default: False)
124+
--use-rdb-preamble use rdb preamble when rewriting aof file (default: True)
123125
--debug-print print debug messages (default: False)
124126
-V, --vg, --use-valgrind
125127
running redis under valgrind (assuming valgrind is

RLTest/__main__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ def do_normal_conn(self, line):
208208
'--use-aof', action='store_const', const=True, default=False,
209209
help='use aof instead of rdb')
210210

211+
parser.add_argument(
212+
'--use-rdb-preamble', action='store_const', const=True, default=True,
213+
help='use rdb preamble when rewriting aof file')
214+
211215
parser.add_argument(
212216
'--debug-print', action='store_const', const=True, default=False,
213217
help='print debug messages')

RLTest/env.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class Defaults:
109109
re_libdir = None
110110
decode_responses = False
111111
use_aof = False
112+
use_rdb_preamble = True
112113
use_TLS = False
113114
tls_cert_file = None
114115
tls_key_file = None
@@ -133,6 +134,7 @@ def getKwargs(self):
133134
'moduleArgs': self.module_args,
134135
'useSlaves': self.use_slaves,
135136
'useAof': self.use_aof,
137+
'useRdbPreamble': self.use_rdb_preamble,
136138
'dbDirPath': self.logdir,
137139
'debugger': self.debugger,
138140
'noCatch': self.no_capture_output,
@@ -148,7 +150,8 @@ def getKwargs(self):
148150

149151
class Env:
150152
RTestInstance = None
151-
EnvCompareParams = ['module', 'moduleArgs', 'env', 'useSlaves', 'shardsCount', 'useAof', 'forceTcp']
153+
EnvCompareParams = ['module', 'moduleArgs', 'env', 'useSlaves', 'shardsCount', 'useAof',
154+
'udsRdbPreamble', 'forceTcp']
152155

153156
def compareEnvs(self, env):
154157
if env is None:
@@ -160,7 +163,7 @@ def compareEnvs(self, env):
160163

161164
def __init__(self, testName=None, testDescription=None, module=None,
162165
moduleArgs=None, env=None, useSlaves=None, shardsCount=None, decodeResponses=None,
163-
useAof=None, forceTcp=False, useTLS=False, tlsCertFile=None, tlsKeyFile=None,
166+
useAof=None, useRdbPreamble=None, forceTcp=False, useTLS=False, tlsCertFile=None, tlsKeyFile=None,
164167
tlsCaCertFile=None, logDir=None, redisBinaryPath=None, dmcBinaryPath=None,
165168
redisEnterpriseBinaryPath=None, noDefaultModuleArgs=False):
166169

@@ -180,6 +183,7 @@ def __init__(self, testName=None, testDescription=None, module=None,
180183
self.shardsCount = shardsCount if shardsCount else Defaults.num_shards
181184
self.decodeResponses = decodeResponses if decodeResponses else Defaults.decode_responses
182185
self.useAof = useAof if useAof else Defaults.use_aof
186+
self.useRdbPreamble = useRdbPreamble if useRdbPreamble is not None else Defaults.use_rdb_preamble
183187
self.verbose = Defaults.verbose
184188
self.logDir = logDir if logDir else Defaults.logdir
185189
self.forceTcp = forceTcp
@@ -278,6 +282,7 @@ def getEnvKwargs(self):
278282
'useSlaves': self.useSlaves,
279283
'decodeResponses': self.decodeResponses,
280284
'useAof': self.useAof,
285+
'useRdbPreamble': self.useRdbPreamble,
281286
'dbDirPath': self.logDir,
282287
'debugger': Defaults.debugger,
283288
'noCatch': Defaults.no_capture_output,

RLTest/redis_std.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
class StandardEnv(object):
2121
def __init__(self, redisBinaryPath, port=6379, modulePath=None, moduleArgs=None, outputFilesFormat=None,
2222
dbDirPath=None, useSlaves=False, serverId=1, password=None, libPath=None, clusterEnabled=False, decodeResponses=False,
23-
useAof=False, debugger=None, noCatch=False, unix=False, verbose=False, useTLS=False, tlsCertFile=None,
23+
useAof=False, useRdbPreamble=True, debugger=None, noCatch=False, unix=False, verbose=False, useTLS=False, tlsCertFile=None,
2424
tlsKeyFile=None, tlsCaCertFile=None):
2525
self.uuid = uuid.uuid4().hex
2626
self.redisBinaryPath = os.path.expanduser(redisBinaryPath) if redisBinaryPath.startswith(
@@ -35,6 +35,7 @@ def __init__(self, redisBinaryPath, port=6379, modulePath=None, moduleArgs=None,
3535
self.clusterEnabled = clusterEnabled
3636
self.decodeResponses = decodeResponses
3737
self.useAof = useAof
38+
self.useRdbPreamble = useRdbPreamble
3839
self.envIsUp = False
3940
self.debugger = debugger
4041
self.noCatch = noCatch
@@ -187,9 +188,10 @@ def createCmdArgs(self, role):
187188
if self.useTLS:
188189
cmdArgs += ['--tls-cluster', 'yes']
189190
if self.useAof:
190-
cmdArgs += ['--appendonly yes']
191+
cmdArgs += ['--appendonly', 'yes']
191192
cmdArgs += ['--appendfilename', self._getFileName(role, '.aof')]
192-
cmdArgs += ['--aof-use-rdb-preamble', 'yes']
193+
if not self.useRdbPreamble:
194+
cmdArgs += ['--aof-use-rdb-preamble', 'no']
193195
if self.useTLS:
194196
cmdArgs += ['--tls-cert-file', self.getTLSCertFile()]
195197
cmdArgs += ['--tls-key-file', self.getTLSKeyFile()]

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@ classifiers = [
2323
]
2424

2525
[tool.poetry.dependencies]
26+
python = "^2.7,<2.8 || >= 3.5.0"
2627
distro = "^1.5.0"
2728
redis = "^3.5.3"
28-
redis-py-cluster = "^2.1.3"
29+
redis-py-cluster = "*"
2930
psutil = "^5.8.0"
31+
pytest-cov = "2.5"
3032

3133
[tool.poetry.urls]
3234
repository = "https://github.com/RedisLabsModules/RLTest"
3335

3436
[tool.poetry.scripts]
3537
RLTest = 'RLTest.__main__:main'
3638

37-
38-
3939
[tool.poetry.dev-dependencies]
40-
codecov = "^2.1.11"
41-
flake8 = "^3.9.2"
40+
codecov = "*"
41+
flake8 = "*"
4242
rmtest = "^0.7.0"
4343
nose = "^1.3.7"
4444
ml2rt = "^0.2.0"
4545
pytest = "4.6"
46-
pytest-cov = "^2.12.1"
46+
4747
[build-system]
4848
requires = ["poetry-core>=1.0.0"]
4949
build-backend = "poetry.core.masonry.api"

tests/unit/test_redis_std.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,18 @@ def test_create_cmd_args_modules_two_modules_array(self):
151151
'--dbfilename', module_std_env._getFileName(role, '.rdb')] == cmd_args
152152
shutil.rmtree(directory_name)
153153

154+
def test_create_cmd_args_aof_without_rdb_preamble(self):
155+
port = 8000
156+
aof_std_env = StandardEnv(redisBinaryPath=REDIS_BINARY, outputFilesFormat='%s-test',
157+
useAof=True, useRdbPreamble=False, port=8000)
158+
role = 'master'
159+
cmd_args = aof_std_env.createCmdArgs(role)
160+
assert [REDIS_BINARY, '--port', '{}'.format(port), '--logfile',
161+
aof_std_env._getFileName(role, '.log'), '--dbfilename',
162+
aof_std_env._getFileName(role, '.rdb'), '--appendonly', 'yes',
163+
'--appendfilename', aof_std_env._getFileName(role, '.aof'),
164+
'--aof-use-rdb-preamble', 'no'] == cmd_args
165+
154166
def test_wait_for_redis_to_start(self):
155167
pass
156168

0 commit comments

Comments
 (0)