Skip to content

Commit

Permalink
Add redis-config-file argument
Browse files Browse the repository at this point in the history
  • Loading branch information
nafraf committed Nov 13, 2024
1 parent fb892b3 commit 1594ba4
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ optional arguments:
--oss-redis-path OSS_REDIS_PATH
path to the oss redis binary (default: redis-server)
--enterprise-redis-path ENTERPRISE_REDIS_PATH
path to the entrprise redis binary (default:
path to the enterprise redis binary (default:
~/.RLTest/opt/redislabs/bin/redis-server)
--redis-config-file REDIS_CONFIG_FILE
path to the redis configuration file (default: None)
--stop-on-failure stop running on failure (default: False)
-x, --exit-on-failure
Stop test execution and exit on first assertion
Expand Down
7 changes: 6 additions & 1 deletion RLTest/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ def do_normal_conn(self, line):

parser.add_argument(
'--enterprise-redis-path', default=os.path.join(binaryrepo.REPO_ROOT, 'opt/redislabs/bin/redis-server'),
help='path to the entrprise redis binary')
help='path to the enterprise redis binary')

parser.add_argument(
'--redis-config-file', default=None,
help='path to the redis configuration file')

parser.add_argument(
'--stop-on-failure', action='store_const', const=True, default=False,
Expand Down Expand Up @@ -537,6 +541,7 @@ def __init__(self):
Defaults.enable_debug_command = True if self.args.allow_unsafe else self.args.enable_debug_command
Defaults.enable_protected_configs = True if self.args.allow_unsafe else self.args.enable_protected_configs
Defaults.enable_module_command = True if self.args.allow_unsafe else self.args.enable_module_command
Defaults.redis_config_file = self.args.redis_config_file if self.args.redis_config_file else None

if Defaults.use_unix and Defaults.use_slaves:
raise Exception('Cannot use unix sockets with slaves')
Expand Down
7 changes: 6 additions & 1 deletion RLTest/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class Defaults:
terminate_retries = None
terminate_retry_secs = None
protocol = 2
redis_config_file = None

def getKwargs(self):
kwargs = {
Expand All @@ -174,6 +175,7 @@ def getKwargs(self):
'password': self.oss_password,
'terminateRetries': self.terminate_retries,
'terminateRetrySecs': self.terminate_retry_secs,
'redisConfigFile': self.redis_config_file,
}
return kwargs

Expand All @@ -198,7 +200,7 @@ def __init__(self, testName=None, testDescription=None, module=None,
tlsCaCertFile=None, tlsPassphrase=None, logDir=None, redisBinaryPath=None, dmcBinaryPath=None,
redisEnterpriseBinaryPath=None, noDefaultModuleArgs=False, clusterNodeTimeout = None,
freshEnv=False, enableDebugCommand=None, enableModuleCommand=None, enableProtectedConfigs=None, protocol=None,
terminateRetries=None, terminateRetrySecs=None):
terminateRetries=None, terminateRetrySecs=None, redisConfigFile=None):

self.testName = testName if testName else Defaults.curr_test_name
if self.testName is None:
Expand Down Expand Up @@ -246,6 +248,8 @@ def __init__(self, testName=None, testDescription=None, module=None,

self.protocol = protocol if protocol is not None else Defaults.protocol

self.redisConfigFile = redisConfigFile if redisConfigFile != None else Defaults.redis_config_file

self.assertionFailedSummary = []

if not freshEnv and Env.RTestInstance and Env.RTestInstance.currEnv and self.compareEnvs(Env.RTestInstance.currEnv):
Expand Down Expand Up @@ -362,6 +366,7 @@ def getEnvKwargs(self):
'protocol': self.protocol,
'terminateRetries': self.terminateRetries,
'terminateRetrySecs': self.terminateRetrySecs,
'redisConfigFile': self.redisConfigFile,
}
return kwargs

Expand Down
8 changes: 7 additions & 1 deletion RLTest/redis_std.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def __init__(self, redisBinaryPath, port=6379, modulePath=None, moduleArgs=None,
dbDirPath=None, useSlaves=False, serverId=1, password=None, libPath=None, clusterEnabled=False, decodeResponses=False,
useAof=False, useRdbPreamble=True, debugger=None, sanitizer=None, noCatch=False, noLog=False, unix=False, verbose=False, useTLS=False,
tlsCertFile=None, tlsKeyFile=None, tlsCaCertFile=None, clusterNodeTimeout=None, tlsPassphrase=None, enableDebugCommand=False, protocol=2,
terminateRetries=None, terminateRetrySecs=None, enableProtectedConfigs=False, enableModuleCommand=False, loglevel=None):
terminateRetries=None, terminateRetrySecs=None, enableProtectedConfigs=False, enableModuleCommand=False, loglevel=None,
redisConfigFile=None
):
self.uuid = uuid.uuid4().hex
self.redisBinaryPath = os.path.expanduser(redisBinaryPath) if redisBinaryPath.startswith(
'~/') else redisBinaryPath
Expand Down Expand Up @@ -68,6 +70,7 @@ def __init__(self, redisBinaryPath, port=6379, modulePath=None, moduleArgs=None,
self.protocol = protocol
self.terminateRetries = terminateRetries
self.terminateRetrySecs = terminateRetrySecs
self.redisConfigFile = redisConfigFile

if port > 0:
self.port = port
Expand Down Expand Up @@ -179,6 +182,9 @@ def createCmdArgs(self, role):

cmdArgs += [self.redisBinaryPath]

if self.redisConfigFile:
cmdArgs += [self.redisConfigFile]

if self.port > -1:
if self.useTLS:
cmdArgs += ['--port', str(0), '--tls-port', str(self.getPort(role))]
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_redis_std.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ def test_create_cmd_args_default(self):
cmd_args = std_env.createCmdArgs(role)
assert [REDIS_BINARY, '--port', '6379', '--logfile', std_env._getFileName(role, '.log'), '--dbfilename',
std_env._getFileName(role, '.rdb')] == cmd_args

def test_create_cmd_args_config_file(self):
std_env = StandardEnv(redisBinaryPath=REDIS_BINARY, outputFilesFormat='%s-test',
redisConfigFile='redis.conf')
role = 'master'
cmd_args = std_env.createCmdArgs(role)
assert [REDIS_BINARY, 'redis.conf','--port', '6379', '--logfile', std_env._getFileName(role, '.log'), '--dbfilename',
std_env._getFileName(role, '.rdb')] == cmd_args

def test_create_cmd_args_tls(self):
port = 8000
Expand Down

0 comments on commit 1594ba4

Please sign in to comment.