Skip to content

Commit

Permalink
Merge pull request #206 from RedisLabsModules/allow_creating_env_with…
Browse files Browse the repository at this point in the history
…out_modules

Allow setting no modules in env
  • Loading branch information
alonre24 authored Nov 21, 2023
2 parents 803b916 + 9a898e9 commit 26528b8
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 19 deletions.
14 changes: 12 additions & 2 deletions RLTest/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@ def do_normal_conn(self, line):
'--enable-protected-configs', action='store_const', const=True, default=False,
help='On Redis 7, this option needs to be enabled in order to change protected configuration in runtime.')

parser.add_argument(
'--enable-module-command', action='store_const', const=True, default=False,
help='On Redis 7, this option needs to be enabled in order to use module command (load/unload modules in runtime).')

parser.add_argument(
'--allow-unsafe', action='store_const', const=True, default=False,
help='On Redis 7, allow the three unsafe modes above (debug and module commands and protected configs)')

parser.add_argument('--check-exitcode', help='Check redis process exit code',
default=False, action='store_true')

Expand Down Expand Up @@ -452,8 +460,10 @@ def __init__(self):
Defaults.tls_passphrase = self.args.tls_passphrase
Defaults.oss_password = self.args.oss_password
Defaults.cluster_node_timeout = self.args.cluster_node_timeout
Defaults.enable_debug_command = self.args.enable_debug_command
Defaults.enable_protected_configs = self.args.enable_protected_configs
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

if Defaults.use_unix and Defaults.use_slaves:
raise Exception('Cannot use unix sockets with slaves')

Expand Down
25 changes: 15 additions & 10 deletions RLTest/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,13 @@ class Defaults:
oss_password = None
cluster_node_timeout = None
curr_test_name = None
port=6379
enable_debug_command=False
enable_protected_configs=False
terminate_retries=None
terminate_retry_secs=None
protocol=2
port = 6379
enable_debug_command = False
enable_protected_configs = False
enable_module_command = False
terminate_retries = None
terminate_retry_secs = None
protocol = 2

def getKwargs(self):
kwargs = {
Expand Down Expand Up @@ -180,7 +181,8 @@ def getKwargs(self):
class Env:
RTestInstance = None
EnvCompareParams = ['module', 'moduleArgs', 'env', 'useSlaves', 'shardsCount', 'useAof',
'useRdbPreamble', 'forceTcp', 'enableDebugCommand', 'enableProtectedConfigs', 'protocol']
'useRdbPreamble', 'forceTcp', 'enableDebugCommand', 'enableProtectedConfigs',
'enableModuleCommand', 'protocol']

def compareEnvs(self, env):
if env is None:
Expand All @@ -195,7 +197,7 @@ def __init__(self, testName=None, testDescription=None, module=None,
useAof=None, useRdbPreamble=None, forceTcp=False, useTLS=False, tlsCertFile=None, tlsKeyFile=None,
tlsCaCertFile=None, tlsPassphrase=None, logDir=None, redisBinaryPath=None, dmcBinaryPath=None,
redisEnterpriseBinaryPath=None, noDefaultModuleArgs=False, clusterNodeTimeout = None,
freshEnv=False, enableDebugCommand=None, enableProtectedConfigs=None, protocol=None,
freshEnv=False, enableDebugCommand=None, enableModuleCommand=None, enableProtectedConfigs=None, protocol=None,
terminateRetries=None, terminateRetrySecs=None):

self.testName = testName if testName else Defaults.curr_test_name
Expand Down Expand Up @@ -233,9 +235,11 @@ def __init__(self, testName=None, testDescription=None, module=None,
self.redisEnterpriseBinaryPath = expandBinary(redisEnterpriseBinaryPath) if redisEnterpriseBinaryPath else Defaults.re_binary
self.clusterNodeTimeout = clusterNodeTimeout if clusterNodeTimeout else Defaults.cluster_node_timeout
self.port = Defaults.port
self.enableDebugCommand = enableDebugCommand if enableDebugCommand else Defaults.enable_debug_command
self.enableProtectedConfigs = enableProtectedConfigs if enableProtectedConfigs\
self.enableDebugCommand = enableDebugCommand if enableDebugCommand is not None else Defaults.enable_debug_command
self.enableProtectedConfigs = enableProtectedConfigs if enableProtectedConfigs is not None\
else Defaults.enable_protected_configs
self.enableModuleCommand = enableModuleCommand if enableModuleCommand is not None else Defaults.enable_module_command

self.terminateRetries = terminateRetries
self.terminateRetrySecs = terminateRetrySecs

Expand Down Expand Up @@ -353,6 +357,7 @@ def getEnvKwargs(self):
'port': self.port,
'enableDebugCommand': self.enableDebugCommand,
'enableProtectedConfigs': self.enableProtectedConfigs,
'enableModuleCommand': self.enableModuleCommand,
'protocol': self.protocol,
'terminateRetries': self.terminateRetries,
'terminateRetrySecs': self.terminateRetrySecs,
Expand Down
6 changes: 4 additions & 2 deletions RLTest/redis_std.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ 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, loglevel=None):
terminateRetries=None, terminateRetrySecs=None, enableProtectedConfigs=False, enableModuleCommand=False, loglevel=None):
self.uuid = uuid.uuid4().hex
self.redisBinaryPath = os.path.expanduser(redisBinaryPath) if redisBinaryPath.startswith(
'~/') else redisBinaryPath
Expand Down Expand Up @@ -63,6 +63,7 @@ def __init__(self, redisBinaryPath, port=6379, modulePath=None, moduleArgs=None,
self.clusterNodeTimeout = clusterNodeTimeout
self.tlsPassphrase = tlsPassphrase
self.enableDebugCommand = enableDebugCommand
self.enableModuleCommand = enableModuleCommand
self.enableProtectedConfigs = enableProtectedConfigs
self.protocol = protocol
self.terminateRetries = terminateRetries
Expand Down Expand Up @@ -245,7 +246,8 @@ def createCmdArgs(self, role):
cmdArgs += ['--enable-debug-command', 'yes']
if self.enableProtectedConfigs:
cmdArgs += ['--enable-protected-configs', 'yes']

if self.enableModuleCommand:
cmdArgs += ['--enable-module-command', 'yes']
return cmdArgs

def createCmdOSEnv(self, role):
Expand Down
11 changes: 7 additions & 4 deletions RLTest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,13 @@ def Green(data):

def fix_modules(modules, defaultModules=None):
# modules is one of the following:
# None
# ['path',...]
if modules:
if not isinstance(modules, list):
# None - take the default modules
# ['path',...] - load module(s) from given path(s)
# Empty list - return None, meaning don't load any module.
if modules is not None:
if len(modules) == 0:
return None
elif not isinstance(modules, list):
modules = [modules]
modules = list(map(lambda p: os.path.abspath(p), modules))
else:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "RLTest"
version = "0.7.3"
version = "0.7.4"
description="Redis Modules Test Framework, allow to run tests on redis and modules on a variety of environments"
authors = ["Redis, Inc. <[email protected]>"]
license = "BSD-3-Clause"
Expand Down

0 comments on commit 26528b8

Please sign in to comment.