diff options
author | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2018-03-28 20:09:39 -0400 |
---|---|---|
committer | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2018-03-29 11:49:08 -0400 |
commit | b0f022596c6b80e5d2d331f8fe3172c28954c027 (patch) | |
tree | 785440bf886ac62e082c146fdddc0e42c3e22250 /buildscripts | |
parent | 788a26e18135321927bbe0b2bdbff12efc467954 (diff) | |
download | mongo-b0f022596c6b80e5d2d331f8fe3172c28954c027.tar.gz |
SERVER-34185 Introduce DataConsistencyHook for raising ServerFailures.
Diffstat (limited to 'buildscripts')
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/dbhash.py | 2 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/jsfile.py | 22 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/oplog.py | 2 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/validate.py | 2 |
4 files changed, 24 insertions, 4 deletions
diff --git a/buildscripts/resmokelib/testing/hooks/dbhash.py b/buildscripts/resmokelib/testing/hooks/dbhash.py index 70516b500db..fdee7bb9f63 100644 --- a/buildscripts/resmokelib/testing/hooks/dbhash.py +++ b/buildscripts/resmokelib/testing/hooks/dbhash.py @@ -9,7 +9,7 @@ import os.path from . import jsfile -class CheckReplDBHash(jsfile.JSHook): +class CheckReplDBHash(jsfile.DataConsistencyHook): """ Checks that the dbhashes of all non-local databases and non-replicated system collections match on the primary and secondaries. diff --git a/buildscripts/resmokelib/testing/hooks/jsfile.py b/buildscripts/resmokelib/testing/hooks/jsfile.py index 65398efd0bf..76b2de31313 100644 --- a/buildscripts/resmokelib/testing/hooks/jsfile.py +++ b/buildscripts/resmokelib/testing/hooks/jsfile.py @@ -7,10 +7,13 @@ from __future__ import absolute_import from . import interface from ..testcases import jstest +from ... import errors from ...utils import registry class JSHook(interface.Hook): + """A hook with a static JavaScript file to execute.""" + REGISTERED_NAME = registry.LEAVE_UNREGISTERED def __init__(self, hook_logger, fixture, js_filename, description, shell_options=None): @@ -21,7 +24,7 @@ class JSHook(interface.Hook): def _should_run_after_test(self): # pylint: disable=no-self-use """ Callback that can be overrided by subclasses to indicate if the JavaScript file should be - executed after the current test. + executed after the current test. """ return True @@ -35,6 +38,23 @@ class JSHook(interface.Hook): hook_test_case.run_dynamic_test(test_report) +class DataConsistencyHook(JSHook): + """ + A hook for running a static JavaScript file that checks data consistency of the server. + + If the mongo shell process running the JavaScript file exits with a non-zero return code, then + an errors.ServerFailure exception is raised to cause resmoke.py's test execution to stop. + """ + + REGISTERED_NAME = registry.LEAVE_UNREGISTERED + + def after_test(self, test, test_report): + try: + JSHook.after_test(self, test, test_report) + except errors.TestFailure as err: + raise errors.ServerFailure(err.args[0]) + + class DynamicJSTestCase(interface.DynamicTestCase): """A dynamic TestCase that runs a JavaScript file.""" diff --git a/buildscripts/resmokelib/testing/hooks/oplog.py b/buildscripts/resmokelib/testing/hooks/oplog.py index 225634ce084..ca9e8d58228 100644 --- a/buildscripts/resmokelib/testing/hooks/oplog.py +++ b/buildscripts/resmokelib/testing/hooks/oplog.py @@ -10,7 +10,7 @@ import os.path from . import jsfile -class CheckReplOplogs(jsfile.JSHook): +class CheckReplOplogs(jsfile.DataConsistencyHook): """ Checks that local.oplog.rs matches on the primary and secondaries. """ diff --git a/buildscripts/resmokelib/testing/hooks/validate.py b/buildscripts/resmokelib/testing/hooks/validate.py index 24c9323342f..20cf99c1158 100644 --- a/buildscripts/resmokelib/testing/hooks/validate.py +++ b/buildscripts/resmokelib/testing/hooks/validate.py @@ -10,7 +10,7 @@ import os.path from . import jsfile -class ValidateCollections(jsfile.JSHook): +class ValidateCollections(jsfile.DataConsistencyHook): """ Runs full validation on all collections in all databases on every stand-alone node, primary replica-set node, or primary shard node. |