Skip to content

Commit

Permalink
add a new --use-module-command flag and --allow-unsafe command that s…
Browse files Browse the repository at this point in the history
…ets all the unsafe flags togather
  • Loading branch information
alonre24 committed Nov 20, 2023
1 parent d411b89 commit 4cccdc8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 324 deletions.
6 changes: 6 additions & 0 deletions RLTest/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ def do_normal_conn(self, line):
'--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 @@ -459,6 +463,8 @@ def __init__(self):
Defaults.enable_debug_command = self.args.enable_debug_command
Defaults.enable_protected_configs = self.args.enable_protected_configs
Defaults.enable_module_command = self.args.enable_module_command
Defaults.allow_unsafe = self.args.allow_unsafe

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

Expand Down
7 changes: 5 additions & 2 deletions RLTest/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class Defaults:
enable_debug_command=False
enable_protected_configs=False
enable_module_command=False
allow_unsafe = False
terminate_retries=None
terminate_retry_secs=None
protocol=2
Expand Down Expand Up @@ -182,7 +183,7 @@ class Env:
RTestInstance = None
EnvCompareParams = ['module', 'moduleArgs', 'env', 'useSlaves', 'shardsCount', 'useAof',
'useRdbPreamble', 'forceTcp', 'enableDebugCommand', 'enableProtectedConfigs',
'enableModuleCommand', 'protocol']
'enableModuleCommand', 'protocol', 'allowUnsafe']

def compareEnvs(self, env):
if env is None:
Expand All @@ -198,7 +199,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, allowUnsafe=None):

self.testName = testName if testName else Defaults.curr_test_name
if self.testName is None:
Expand Down Expand Up @@ -239,6 +240,7 @@ def __init__(self, testName=None, testDescription=None, module=None,
self.enableProtectedConfigs = enableProtectedConfigs if enableProtectedConfigs\
else Defaults.enable_protected_configs
self.enableModuleCommand = enableModuleCommand if enableModuleCommand else Defaults.enable_module_command
self.allowUnsafe = allowUnsafe if allowUnsafe else Defaults.allow_unsafe
self.terminateRetries = terminateRetries
self.terminateRetrySecs = terminateRetrySecs

Expand Down Expand Up @@ -357,6 +359,7 @@ def getEnvKwargs(self):
'enableDebugCommand': self.enableDebugCommand,
'enableProtectedConfigs': self.enableProtectedConfigs,
'enableModuleCommand': self.enableModuleCommand,
'allowUnsafe': self.allowUnsafe,
'protocol': self.protocol,
'terminateRetries': self.terminateRetries,
'terminateRetrySecs': self.terminateRetrySecs,
Expand Down
19 changes: 12 additions & 7 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, enableModuleCommand=False, loglevel=None):
terminateRetries=None, terminateRetrySecs=None, enableProtectedConfigs=False, enableModuleCommand=False, loglevel=None, allowUnsafe=False):
self.uuid = uuid.uuid4().hex
self.redisBinaryPath = os.path.expanduser(redisBinaryPath) if redisBinaryPath.startswith(
'~/') else redisBinaryPath
Expand Down Expand Up @@ -65,6 +65,7 @@ def __init__(self, redisBinaryPath, port=6379, modulePath=None, moduleArgs=None,
self.enableDebugCommand = enableDebugCommand
self.enableModuleCommand = enableModuleCommand
self.enableProtectedConfigs = enableProtectedConfigs
self.allowUnsafe = allowUnsafe
self.protocol = protocol
self.terminateRetries = terminateRetries
self.terminateRetrySecs = terminateRetrySecs
Expand Down Expand Up @@ -242,12 +243,16 @@ def createCmdArgs(self, role):
cmdArgs += ['--tls-replication', 'yes']

if self._getRedisVersion() > 70000:
if self.enableDebugCommand:
cmdArgs += ['--enable-debug-command', 'yes', '--enable-module-command', 'yes']
if self.enableProtectedConfigs:
cmdArgs += ['--enable-protected-configs', 'yes']
if self.enableModuleCommand:
cmdArgs += ['--enable-module-command', 'yes']
if self.allowUnsafe:
cmdArgs += ['--enable-debug-command', 'yes', '--enable-protected-configs', 'yes',
'--enable-module-command', 'yes']
else:
if self.enableDebugCommand:
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
Loading

0 comments on commit 4cccdc8

Please sign in to comment.