0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-26522 Made CleanEveryN into a TestCase

This commit is contained in:
Judah Schvimer 2017-01-10 09:53:58 -05:00
parent 166a9663a3
commit 585a8a9cb8

View File

@ -106,6 +106,7 @@ class CleanEveryN(CustomBehavior):
def __init__(self, logger, fixture, n=DEFAULT_N):
description = "CleanEveryN (restarts the fixture after running `n` tests)"
CustomBehavior.__init__(self, logger, fixture, description)
self.hook_test_case = testcases.TestCase(logger, "Hook", "CleanEveryN")
# Try to isolate what test triggers the leak by restarting the fixture each time.
if "detect_leaks=1" in os.getenv("ASAN_OPTIONS", ""):
@ -118,7 +119,12 @@ class CleanEveryN(CustomBehavior):
def after_test(self, test, test_report):
self.tests_run += 1
if self.tests_run >= self.n:
if self.tests_run < self.n:
return
self.hook_test_case.test_name = test.short_name() + ":" + self.logger_name
CustomBehavior.start_dynamic_test(self.hook_test_case, test_report)
try:
self.logger.info("%d tests have been run against the fixture, stopping it...",
self.tests_run)
self.tests_run = 0
@ -130,6 +136,11 @@ class CleanEveryN(CustomBehavior):
self.fixture.setup()
self.fixture.await_ready()
self.hook_test_case.return_code = 0
test_report.addSuccess(self.hook_test_case)
finally:
test_report.stopTest(self.hook_test_case)
class JsCustomBehavior(CustomBehavior):
def __init__(self, logger, fixture, js_filename, description, shell_options=None):