diff --git a/RLTest/__main__.py b/RLTest/__main__.py index afad3e87..16af4c83 100644 --- a/RLTest/__main__.py +++ b/RLTest/__main__.py @@ -13,7 +13,7 @@ from RLTest.env import Env, TestAssertionFailure, Defaults from RLTest.utils import Colors -from RLTest.loader import TestLoader +from RLTest.loader import TestLoader, load_cleaner from RLTest.Enterprise import binaryrepo from RLTest import debuggers @@ -250,6 +250,11 @@ def do_normal_conn(self, line): '--collect-only', action='store_true', help='Collect the tests and exit') +parser.add_argument( + '--cleaner', + help='Path to function to be called in addition to any invocation of flush' +) + parser.add_argument('--tls', help='Enable TLS Support and disable the non-TLS port completely. TLS connections will be available at the default non-TLS ports.', default=False, action='store_true') @@ -323,7 +328,7 @@ def __init__(self): print(Colors.Bred('can not use valgrind with existing-env')) sys.exit(1) if self.args.vg_options is None: - self.args.vg_options = os.getenv('VG_OPTIONS', '--leak-check=full --errors-for-leak-kinds=definite') + self.args.vg_options = os.getenv('VG_OPTIONS', '') vg_debugger = debuggers.Valgrind(options=self.args.vg_options, suppressions=self.args.vg_suppressions, fail_on_errors=not(self.args.vg_no_fail_on_errors), @@ -376,11 +381,16 @@ def __init__(self): self.testsFailed = [] self.currEnv = None self.loader = TestLoader() + self.cleaner = None + if self.args.test: self.loader.load_spec(self.args.test) else: self.loader.scan_dir(os.getcwd()) + if self.args.cleaner: + self.cleaner = load_cleaner(self.args.cleaner) + if self.args.collect_only: self.loader.print_tests() sys.exit(0) @@ -392,6 +402,12 @@ def __init__(self): def _convertArgsType(self): pass + def _flush(self): + if self.currEnv.isUp(): + self.currEnv.flush() + if self.cleaner: + self.cleaner(self.currEnv) + def takeEnvDown(self, fullShutDown=False): if not self.currEnv: return @@ -399,7 +415,7 @@ def takeEnvDown(self, fullShutDown=False): needShutdown = True if self.args.env_reuse and not fullShutDown: try: - self.currEnv.flush() + self._flush() needShutdown = False except Exception as e: self.currEnv.stop() @@ -407,8 +423,7 @@ def takeEnvDown(self, fullShutDown=False): env=self.currEnv) if needShutdown: - if self.currEnv.isUp(): - self.currEnv.flush() + self._flush() self.currEnv.stop() if self.require_clean_exit and self.currEnv and not self.currEnv.checkExitCode(): print(Colors.Bred('\tRedis did not exit cleanly')) diff --git a/RLTest/debuggers.py b/RLTest/debuggers.py index d3a311c9..b8e79a73 100644 --- a/RLTest/debuggers.py +++ b/RLTest/debuggers.py @@ -5,7 +5,7 @@ class Valgrind(object): is_interactive = False - def __init__(self, options, suppressions=None, fail_on_errors=True, leakcheck=True ): + def __init__(self, options, suppressions=None, fail_on_errors=True, leakcheck=True): self.options = options self.suppressions = suppressions self.leakcheck = leakcheck @@ -44,8 +44,8 @@ def __init__(self, cmdline="gdb"): super(GDB, self).__init__(cmdline) def generate_command(self, *argc, **kw): - return ['gdb', '-ex', 'run', '--args'] - + # return ['gdb', '-ex', 'run', '--args'] + return ['gdb', '--args'] class CGDB(GenericInteractiveDebugger): def __init__(self, cmdline="cgdb"): diff --git a/RLTest/libexample_extension.dylib b/RLTest/libexample_extension.dylib new file mode 100755 index 00000000..71f3f4dc Binary files /dev/null and b/RLTest/libexample_extension.dylib differ diff --git a/RLTest/loader.py b/RLTest/loader.py index c307cbf1..0364864d 100644 --- a/RLTest/loader.py +++ b/RLTest/loader.py @@ -129,4 +129,23 @@ def print_tests(self): for m in t.methnames: print("\t\t", m) else: - print("\tFunction") \ No newline at end of file + print("\tFunction") + + +class _CleanerLoader(TestLoader): + def filter_modulevar(self, candidate): + return candidate == self.toplevel_filter + + def filter_method(self, candidate): + return False + + def __init__(self): + super(_CleanerLoader, self).__init__() + + +def load_cleaner(spec): + cl = _CleanerLoader() + cl.load_spec(spec) + if len(cl.tests) != 1: + raise ValueError("Bad cleaner for tests") + return cl.tests[0].target \ No newline at end of file diff --git a/RLTest/redis_std.py b/RLTest/redis_std.py index 9a57dc5a..fc827777 100644 --- a/RLTest/redis_std.py +++ b/RLTest/redis_std.py @@ -239,6 +239,7 @@ def startEnv(self): } self.masterProcess = subprocess.Popen(args=self.masterCmdArgs, **options) + print(self.masterCmdArgs) con = self.getConnection() self.waitForRedisToStart(con) if self.useSlaves: @@ -365,7 +366,8 @@ def dumpAndReload(self, restart=False, shardId=None): if self.useSlaves: conns.append(self.getSlaveConnection()) if restart: - [con.bgrewriteaof() for con in conns] + # [con.bgrewriteaof() for con in conns] + [con.save() for con in conns] self._waitForChild(conns) self.stopEnv()