Skip to content

Commit

Permalink
CR - remove allow unsafe from env members, allow using it only as glo…
Browse files Browse the repository at this point in the history
…bal arg.
  • Loading branch information
alonre24 committed Nov 21, 2023
1 parent 4cccdc8 commit 4ab64d3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 31 deletions.
7 changes: 3 additions & 4 deletions RLTest/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,9 @@ 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_module_command = self.args.enable_module_command
Defaults.allow_unsafe = self.args.allow_unsafe
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
28 changes: 13 additions & 15 deletions RLTest/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +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
enable_module_command=False
allow_unsafe = 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 @@ -183,7 +182,7 @@ class Env:
RTestInstance = None
EnvCompareParams = ['module', 'moduleArgs', 'env', 'useSlaves', 'shardsCount', 'useAof',
'useRdbPreamble', 'forceTcp', 'enableDebugCommand', 'enableProtectedConfigs',
'enableModuleCommand', 'protocol', 'allowUnsafe']
'enableModuleCommand', 'protocol']

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

self.testName = testName if testName else Defaults.curr_test_name
if self.testName is None:
Expand Down Expand Up @@ -236,11 +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 is not None 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.enableModuleCommand = enableModuleCommand if enableModuleCommand is not None else Defaults.enable_module_command

self.terminateRetries = terminateRetries
self.terminateRetrySecs = terminateRetrySecs

Expand Down Expand Up @@ -359,7 +358,6 @@ 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: 7 additions & 12 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, allowUnsafe=False):
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 @@ -65,7 +65,6 @@ 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 @@ -243,16 +242,12 @@ def createCmdArgs(self, role):
cmdArgs += ['--tls-replication', 'yes']

if self._getRedisVersion() > 70000:
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']
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

0 comments on commit 4ab64d3

Please sign in to comment.