summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pearson <luke.pearson@mongodb.com>2021-08-24 10:38:14 +1000
committerLuke Pearson <luke.pearson@mongodb.com>2021-08-24 10:38:14 +1000
commit0dd028372f71a40e422464add6687b557755e4ab (patch)
tree62c0059e6dc4e273b94ca83d33e1b429aa1179dd
parente870fd1c2e9e1e428c1bb1bd61ce50fa20f7bb83 (diff)
downloadmongo-0dd028372f71a40e422464add6687b557755e4ab.tar.gz
Applying validate failure code
-rw-r--r--buildscripts/resmokelib/testing/hooks/interface.py3
-rw-r--r--buildscripts/resmokelib/testing/hooks/simulate_crash.py20
2 files changed, 19 insertions, 4 deletions
diff --git a/buildscripts/resmokelib/testing/hooks/interface.py b/buildscripts/resmokelib/testing/hooks/interface.py
index d8ac37e159d..7a4413de936 100644
--- a/buildscripts/resmokelib/testing/hooks/interface.py
+++ b/buildscripts/resmokelib/testing/hooks/interface.py
@@ -34,6 +34,9 @@ class Hook(object, metaclass=registry.make_registry_metaclass(_HOOKS)):
self.fixture = fixture
self.description = description
+ def has_failed(self):
+ return False
+
def before_suite(self, test_report):
"""Test runner calls this exactly once before they start running the suite."""
pass
diff --git a/buildscripts/resmokelib/testing/hooks/simulate_crash.py b/buildscripts/resmokelib/testing/hooks/simulate_crash.py
index 5de15b28b06..1cb40a7ff2c 100644
--- a/buildscripts/resmokelib/testing/hooks/simulate_crash.py
+++ b/buildscripts/resmokelib/testing/hooks/simulate_crash.py
@@ -23,7 +23,8 @@ def validate(mdb, logger, orig_port):
logger.info("DBG. FAILURE!\nCmdLineOpts: {}\nValidate Response: {}",
pprint.pformat(mdb.admin.command("getCmdLineOpts")),
pprint.pformat(resp))
- raise "failed"
+ return False
+ return True
class BGJob(threading.Thread):
def __init__(self, hook):
@@ -33,6 +34,7 @@ class BGJob(threading.Thread):
self._lock = threading.Lock()
self._is_alive = True
self.backup_num = 0
+ self.found_error = False
def run(self):
while True:
@@ -41,7 +43,11 @@ class BGJob(threading.Thread):
break
self._hook.pause_and_copy(self.backup_num)
- self._hook.validate_all(self.backup_num)
+ if not self._hook.validate_all(self.backup_num):
+ self.found_error = True
+ self._hook.running_test.fixture.teardown()
+ self.is_alive = False
+ return
time.sleep(random.randint(1, 5))
self.backup_num += 1
@@ -57,6 +63,9 @@ class SimulateCrashHook(interface.Hook):
self.logger = hook_logger
self.last_validate_port = 19000
+ def has_failed(self):
+ return self.found_error
+
def before_suite(self, test_report):
"""Test runner calls this exactly once before they start running the suite."""
shutil.rmtree('./tmp', ignore_errors=True)
@@ -114,9 +123,12 @@ class SimulateCrashHook(interface.Hook):
'--logpath', 'tmp/validate.log'])
mdb.start()
client = pymongo.MongoClient('localhost:{}'.format(validate_port))
- validate(client, self.logger, node.port)
+ is_valid = validate(client, self.logger, node.port)
mdb.stop()
+ if not is_valid:
+ return False
shutil.rmtree(path, ignore_errors=True)
+ return True
def after_suite(self, test_report):
"""Invoke by test runner calls this exactly once after all tests have finished executing.
@@ -128,7 +140,7 @@ class SimulateCrashHook(interface.Hook):
def before_test(self, test, test_report):
"""Each test will call this before it executes."""
- pass
+ self.running_test = test
def after_test(self, test, test_report):
"""Each test will call this after it executes."""