Skip to content

Commit

Permalink
loglevel config (#194)
Browse files Browse the repository at this point in the history
* added log level configuration for the redis instance

* bump up RLTest version
  • Loading branch information
GuyAv46 authored Jul 31, 2023
1 parent 54d1b81 commit 6f22860
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
7 changes: 6 additions & 1 deletion RLTest/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ def do_normal_conn(self, line):
'--log-dir', default='./logs',
help='directory to write logs to')

parser.add_argument(
'--log-level', default=None, metavar='LEVEL', choices=['debug', 'verbose', 'notice', 'warning'],
help='sets the server log level')

parser.add_argument(
'--use-slaves', action='store_const', const=True, default=False,
help='run env with slaves enabled')
Expand Down Expand Up @@ -415,6 +419,7 @@ def __init__(self):
Defaults.binary = self.args.oss_redis_path
Defaults.verbose = self.args.verbose
Defaults.logdir = self.args.log_dir
Defaults.loglevel = self.args.log_level
Defaults.use_slaves = self.args.use_slaves
Defaults.num_shards = self.args.shards_count
Defaults.shards_ports = self.args.shards_ports.split(',') if self.args.shards_ports is not None else None
Expand Down Expand Up @@ -746,7 +751,7 @@ def run_jobs(jobs, results, port):
if failures > 0 and Defaults.print_verbose_information_on_failure:
lastEnv = self.currEnv
verboseInfo['before_dispose'] = lastEnv.getInformationBeforeDispose()

# here the env is down so lets collect more info and print it
if failures > 0 and Defaults.print_verbose_information_on_failure:
verboseInfo['after_dispose'] = lastEnv.getInformationAfterDispose()
Expand Down
6 changes: 4 additions & 2 deletions RLTest/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class Defaults:
exit_on_failure = False
verbose = 0
logdir = None
loglevel = None
use_slaves = False
num_shards = 1
external_addr = 'localhost:6379'
Expand Down Expand Up @@ -260,14 +261,14 @@ def __init__(self, testName=None, testDescription=None, module=None,

if Defaults.debug_pause:
input('\tenv is up, attach to any process with gdb and press any button to continue.')

def getInformationBeforeDispose(self):
return {
"env": self.env,
"test": self.testName,
"env_info": self.envRunner.getInformationBeforeDispose()
}

def getInformationAfterDispose(self):
return self.envRunner.getInformationAfterDispose()

Expand Down Expand Up @@ -333,6 +334,7 @@ def getEnvKwargs(self):
'useAof': self.useAof,
'useRdbPreamble': self.useRdbPreamble,
'dbDirPath': self.logDir,
'loglevel': Defaults.loglevel,
'debugger': Defaults.debugger,
'sanitizer': Defaults.sanitizer,
'noCatch': Defaults.no_capture_output,
Expand Down
5 changes: 4 additions & 1 deletion 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):
terminateRetries=None, terminateRetrySecs=None, loglevel=None):
self.uuid = uuid.uuid4().hex
self.redisBinaryPath = os.path.expanduser(redisBinaryPath) if redisBinaryPath.startswith(
'~/') else redisBinaryPath
Expand All @@ -42,6 +42,7 @@ def __init__(self, redisBinaryPath, port=6379, modulePath=None, moduleArgs=None,
self.sanitizer = sanitizer
self.noCatch = noCatch
self.noLog = noLog
self.loglevel = loglevel
self.environ = os.environ.copy()
self.useUnix = unix
self.dbDirPath = dbDirPath
Expand Down Expand Up @@ -205,6 +206,8 @@ def createCmdArgs(self, role):
cmdArgs += ['--logfile', '/dev/null']
elif self.outputFilesFormat is not None and not self.noCatch:
cmdArgs += ['--logfile', self._getFileName(role, '.log')]
if self.loglevel is not None:
cmdArgs += ['--loglevel', self.loglevel]
if self.outputFilesFormat is not None:
cmdArgs += ['--dbfilename', self._getFileName(role, '.rdb')]
if role == SLAVE:
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.1"
version = "0.7.2"
description="Redis Modules Test Framework, allow to run tests on redis and modules on a variety of environments"
authors = ["Redis, Inc. <oss@redis.com>"]
license = "BSD-3-Clause"
Expand Down

0 comments on commit 6f22860

Please sign in to comment.