diff options
author | Yves Duhem <yves.duhem@mongodb.com> | 2018-02-27 11:29:41 -0500 |
---|---|---|
committer | Yves Duhem <yves.duhem@mongodb.com> | 2018-02-27 11:29:46 -0500 |
commit | 4a69dcaf78f29cf440ada961c7e59de6b5dde111 (patch) | |
tree | aceb8f015e234f940c94e67b5a756e1a7f8baab3 /buildscripts/resmokelib | |
parent | a77297dbe34d5cd838a4da55e9d83dc70c510bba (diff) | |
download | mongo-4a69dcaf78f29cf440ada961c7e59de6b5dde111.tar.gz |
SERVER-33476 Rename CustomBehavior to Hook
Diffstat (limited to 'buildscripts/resmokelib')
-rw-r--r-- | buildscripts/resmokelib/logging/loggers.py | 10 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/executor.py | 24 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/__init__.py | 4 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/check_primary.py | 8 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/cleanup.py | 10 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/dbhash.py | 14 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/initialsync.py | 11 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/interface.py | 14 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/jsfile.py | 6 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/oplog.py | 14 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/periodic_kill_secondaries.py | 6 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/stepdown.py | 6 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/hooks/validate.py | 14 | ||||
-rw-r--r-- | buildscripts/resmokelib/testing/job.py | 3 |
14 files changed, 71 insertions, 73 deletions
diff --git a/buildscripts/resmokelib/logging/loggers.py b/buildscripts/resmokelib/logging/loggers.py index bc26174081b..28da3b9744c 100644 --- a/buildscripts/resmokelib/logging/loggers.py +++ b/buildscripts/resmokelib/logging/loggers.py @@ -149,9 +149,9 @@ class ExecutorRootLogger(RootLogger): """Create a new TestQueueLogger that will be a child of the "tests" root logger.""" return TestQueueLogger(test_kind, self.tests_root_logger) - def new_hook_logger(self, behavior_class, fixture_logger): + def new_hook_logger(self, hook_class, fixture_logger): """Create a new child hook logger.""" - return HookLogger(behavior_class, fixture_logger, self.tests_root_logger) + return HookLogger(hook_class, fixture_logger, self.tests_root_logger) class JobLogger(BaseLogger): @@ -315,14 +315,14 @@ class TestQueueLogger(BaseLogger): class HookLogger(BaseLogger): - def __init__(self, behavior_class, fixture_logger, tests_root_logger): + def __init__(self, hook_class, fixture_logger, tests_root_logger): """Initialize a HookLogger. - :param behavior_class: the hook's name (e.g. CheckReplDBHash, ValidateCollections, etc.). + :param hook_class: the hook's name (e.g. CheckReplDBHash, ValidateCollections, etc.). :param fixture_logger: the logger for the fixtures logs. :param tests_root_logger: the root logger for the tests logs. """ - logger_name = "{}:job{:d}".format(behavior_class, fixture_logger.job_num) + logger_name = "{}:job{:d}".format(hook_class, fixture_logger.job_num) BaseLogger.__init__(self, logger_name, parent=fixture_logger) self.test_case_logger = BaseLogger(logger_name, parent=tests_root_logger) diff --git a/buildscripts/resmokelib/testing/executor.py b/buildscripts/resmokelib/testing/executor.py index 49df64ae2ef..8cf7f6b6643 100644 --- a/buildscripts/resmokelib/testing/executor.py +++ b/buildscripts/resmokelib/testing/executor.py @@ -247,23 +247,23 @@ class TestSuiteExecutor(object): def _make_hooks(self, job_num, fixture): """ - Creates the custom behaviors for the job's fixture. + Creates the hooks for the job's fixture. """ - behaviors = [] + hooks = [] - for behavior_config in self.hooks_config: - behavior_config = behavior_config.copy() - behavior_class = behavior_config.pop("class") + for hook_config in self.hooks_config: + hook_config = hook_config.copy() + hook_class = hook_config.pop("class") - hook_logger = self.logger.new_hook_logger(behavior_class, fixture.logger) - behavior = _hooks.make_custom_behavior(behavior_class, - hook_logger, - fixture, - **behavior_config) - behaviors.append(behavior) + hook_logger = self.logger.new_hook_logger(hook_class, fixture.logger) + hook = _hooks.make_hook(hook_class, + hook_logger, + fixture, + **hook_config) + hooks.append(hook) - return behaviors + return hooks def _make_job(self, job_num): """ diff --git a/buildscripts/resmokelib/testing/hooks/__init__.py b/buildscripts/resmokelib/testing/hooks/__init__.py index f1d6ec5970c..40cc09c78cc 100644 --- a/buildscripts/resmokelib/testing/hooks/__init__.py +++ b/buildscripts/resmokelib/testing/hooks/__init__.py @@ -6,10 +6,10 @@ before or after each suite. from __future__ import absolute_import -from .interface import make_custom_behavior +from .interface import make_hook from ...utils import autoloader as _autoloader -# We dynamically load all modules in the hooks/ package so that any CustomBehavior classes declared +# We dynamically load all modules in the hooks/ package so that any Hook classes declared # within them are automatically registered. _autoloader.load_all_modules(name=__name__, path=__path__) diff --git a/buildscripts/resmokelib/testing/hooks/check_primary.py b/buildscripts/resmokelib/testing/hooks/check_primary.py index 8af5fde200d..3c2d128145b 100644 --- a/buildscripts/resmokelib/testing/hooks/check_primary.py +++ b/buildscripts/resmokelib/testing/hooks/check_primary.py @@ -8,18 +8,19 @@ from . import interface from ..fixtures import replicaset from ... import errors -import pymongo +import pymongo.errors -class CheckPrimary(interface.CustomBehavior): +class CheckPrimary(interface.Hook): def __init__(self, hook_logger, rs_fixture): description = "Verify that the primary has not stepped down or changed" - interface.CustomBehavior.__init__(self, hook_logger, rs_fixture, description) + interface.Hook.__init__(self, hook_logger, rs_fixture, description) if not isinstance(rs_fixture, replicaset.ReplicaSetFixture): raise TypeError("{} is not a replica set".format(rs_fixture.__class__.__name__)) self._rs_fixture = rs_fixture + self._primary_url = None def _get_primary_url(self): no_primary_err = errors.ServerFailure("No primary found") @@ -35,7 +36,6 @@ class CheckPrimary(interface.CustomBehavior): raise no_primary_err - def before_test(self, test, test_report): self._primary_url = self._get_primary_url() diff --git a/buildscripts/resmokelib/testing/hooks/cleanup.py b/buildscripts/resmokelib/testing/hooks/cleanup.py index d0b73105ddd..8b5ff6e0401 100644 --- a/buildscripts/resmokelib/testing/hooks/cleanup.py +++ b/buildscripts/resmokelib/testing/hooks/cleanup.py @@ -12,7 +12,7 @@ from ..testcases import interface as testcase from ... import errors -class CleanEveryN(interface.CustomBehavior): +class CleanEveryN(interface.Hook): """ Restarts the fixture after it has ran 'n' tests. On mongod-related fixtures, this will clear the dbpath. @@ -22,7 +22,7 @@ class CleanEveryN(interface.CustomBehavior): def __init__(self, hook_logger, fixture, n=DEFAULT_N): description = "CleanEveryN (restarts the fixture after running `n` tests)" - interface.CustomBehavior.__init__(self, hook_logger, fixture, description) + interface.Hook.__init__(self, hook_logger, fixture, description) # Try to isolate what test triggers the leak by restarting the fixture each time. if "detect_leaks=1" in os.getenv("ASAN_OPTIONS", ""): @@ -38,10 +38,10 @@ class CleanEveryN(interface.CustomBehavior): if self.tests_run < self.n: return - test_name = "{}:{}".format(test.short_name(), self.__class__.__name__) + test_name = "{}:{}".format(test.short_name(), self.__class__.__name__) self.hook_test_case = self.make_dynamic_test(testcase.TestCase, "Hook", test_name) - interface.CustomBehavior.start_dynamic_test(self.hook_test_case, test_report) + interface.Hook.start_dynamic_test(self.hook_test_case, test_report) try: self.hook_test_case.logger.info( "%d tests have been run against the fixture, stopping it...", @@ -49,7 +49,7 @@ class CleanEveryN(interface.CustomBehavior): self.tests_run = 0 if not self.fixture.teardown(): - raise errors.ServerFailure("%s did not exit cleanly" % (self.fixture)) + raise errors.ServerFailure("%s did not exit cleanly" % self.fixture) self.hook_test_case.logger.info("Starting the fixture back up again...") self.fixture.setup() diff --git a/buildscripts/resmokelib/testing/hooks/dbhash.py b/buildscripts/resmokelib/testing/hooks/dbhash.py index 02b7b18acac..f5081fd5e7d 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.JsCustomBehavior): +class CheckReplDBHash(jsfile.JSHook): """ Checks that the dbhashes of all non-local databases and non-replicated system collections match on the primary and secondaries. @@ -17,9 +17,9 @@ class CheckReplDBHash(jsfile.JsCustomBehavior): def __init__(self, hook_logger, fixture, shell_options=None): description = "Check dbhashes of all replica set or master/slave members" js_filename = os.path.join("jstests", "hooks", "run_check_repl_dbhash.js") - jsfile.JsCustomBehavior.__init__(self, - hook_logger, - fixture, - js_filename, - description, - shell_options=shell_options) + jsfile.JSHook.__init__(self, + hook_logger, + fixture, + js_filename, + description, + shell_options=shell_options) diff --git a/buildscripts/resmokelib/testing/hooks/initialsync.py b/buildscripts/resmokelib/testing/hooks/initialsync.py index 20b422bccb3..c13aafe4bdc 100644 --- a/buildscripts/resmokelib/testing/hooks/initialsync.py +++ b/buildscripts/resmokelib/testing/hooks/initialsync.py @@ -15,10 +15,9 @@ from . import cleanup from . import jsfile from ..fixtures import replicaset from ... import errors -from ... import utils -class BackgroundInitialSync(jsfile.JsCustomBehavior): +class BackgroundInitialSync(jsfile.JSHook): """ After every test, this hook checks if a background node has finished initial sync and if so, validates it, tears it down, and restarts it. @@ -42,8 +41,8 @@ class BackgroundInitialSync(jsfile.JsCustomBehavior): description = "Background Initial Sync" js_filename = os.path.join("jstests", "hooks", "run_initial_sync_node_validation.js") - jsfile.JsCustomBehavior.__init__(self, hook_logger, fixture, js_filename, - description, shell_options) + jsfile.JSHook.__init__(self, hook_logger, fixture, js_filename, + description, shell_options) self.use_resync = use_resync self.n = n @@ -126,7 +125,7 @@ class BackgroundInitialSync(jsfile.JsCustomBehavior): self.__restart_init_sync(test_report, sync_node, sync_node_conn) -class IntermediateInitialSync(jsfile.JsCustomBehavior): +class IntermediateInitialSync(jsfile.JSHook): """ This hook accepts a parameter 'n' that specifies a number of tests after which it will start up a node to initial sync, wait for replication to finish, and then validate the data. It also @@ -145,7 +144,7 @@ class IntermediateInitialSync(jsfile.JsCustomBehavior): description = "Intermediate Initial Sync" js_filename = os.path.join("jstests", "hooks", "run_initial_sync_node_validation.js") - jsfile.JsCustomBehavior.__init__(self, hook_logger, fixture, js_filename, description) + jsfile.JSHook.__init__(self, hook_logger, fixture, js_filename, description) self.use_resync = use_resync self.n = n diff --git a/buildscripts/resmokelib/testing/hooks/interface.py b/buildscripts/resmokelib/testing/hooks/interface.py index cd5200764fc..75f222bbdd1 100644 --- a/buildscripts/resmokelib/testing/hooks/interface.py +++ b/buildscripts/resmokelib/testing/hooks/interface.py @@ -11,20 +11,20 @@ from ...utils import registry _HOOKS = {} -def make_custom_behavior(class_name, *args, **kwargs): +def make_hook(class_name, *args, **kwargs): """ - Factory function for creating CustomBehavior instances. + Factory function for creating Hook instances. """ if class_name not in _HOOKS: - raise ValueError("Unknown custom behavior class '%s'" % (class_name)) + raise ValueError("Unknown hook class '%s'" % class_name) return _HOOKS[class_name](*args, **kwargs) -class CustomBehavior(object): +class Hook(object): """ - The common interface all CustomBehaviors will inherit from. + The common interface all Hooks will inherit from. """ __metaclass__ = registry.make_registry_metaclass(_HOOKS) @@ -34,7 +34,7 @@ class CustomBehavior(object): @staticmethod def start_dynamic_test(hook_test_case, test_report): """ - If a CustomBehavior wants to add a test case that will show up + If a Hook wants to add a test case that will show up in the test report, it should use this method to add it to the report, since we will need to count it as a dynamic test to get the stats in the summary information right. @@ -43,7 +43,7 @@ class CustomBehavior(object): def __init__(self, hook_logger, fixture, description): """ - Initializes the CustomBehavior with the specified fixture. + Initializes the Hook with the specified fixture. """ if not isinstance(hook_logger, loggers.HookLogger): diff --git a/buildscripts/resmokelib/testing/hooks/jsfile.py b/buildscripts/resmokelib/testing/hooks/jsfile.py index 47da3bde623..fddfce1e710 100644 --- a/buildscripts/resmokelib/testing/hooks/jsfile.py +++ b/buildscripts/resmokelib/testing/hooks/jsfile.py @@ -16,11 +16,11 @@ from ... import errors from ...utils import registry -class JsCustomBehavior(interface.CustomBehavior): +class JSHook(interface.Hook): REGISTERED_NAME = registry.LEAVE_UNREGISTERED def __init__(self, hook_logger, fixture, js_filename, description, shell_options=None): - interface.CustomBehavior.__init__(self, hook_logger, fixture, description) + interface.Hook.__init__(self, hook_logger, fixture, description) self.hook_test_case = self.make_dynamic_test(jstest.JSTestCase, js_filename, shell_options=shell_options, @@ -48,7 +48,7 @@ class JsCustomBehavior(interface.CustomBehavior): test_name = "{}:{}".format(test.short_name(), self.__class__.__name__) self.hook_test_case.test_name = test_name - interface.CustomBehavior.start_dynamic_test(self.hook_test_case, test_report) + interface.Hook.start_dynamic_test(self.hook_test_case, test_report) try: self._after_test_impl(test, test_report, description) except pymongo.errors.OperationFailure as err: diff --git a/buildscripts/resmokelib/testing/hooks/oplog.py b/buildscripts/resmokelib/testing/hooks/oplog.py index 62fa24026fc..bb75b1bf501 100644 --- a/buildscripts/resmokelib/testing/hooks/oplog.py +++ b/buildscripts/resmokelib/testing/hooks/oplog.py @@ -10,16 +10,16 @@ import os.path from . import jsfile -class CheckReplOplogs(jsfile.JsCustomBehavior): +class CheckReplOplogs(jsfile.JSHook): """ Checks that local.oplog.rs matches on the primary and secondaries. """ def __init__(self, hook_logger, fixture, shell_options=None): description = "Check oplogs of all replica set members" js_filename = os.path.join("jstests", "hooks", "run_check_repl_oplogs.js") - jsfile.JsCustomBehavior.__init__(self, - hook_logger, - fixture, - js_filename, - description, - shell_options=shell_options) + jsfile.JSHook.__init__(self, + hook_logger, + fixture, + js_filename, + description, + shell_options=shell_options) diff --git a/buildscripts/resmokelib/testing/hooks/periodic_kill_secondaries.py b/buildscripts/resmokelib/testing/hooks/periodic_kill_secondaries.py index 897a3edcd8b..2fa33643e20 100644 --- a/buildscripts/resmokelib/testing/hooks/periodic_kill_secondaries.py +++ b/buildscripts/resmokelib/testing/hooks/periodic_kill_secondaries.py @@ -21,7 +21,7 @@ from ..testcases import interface as testcase from ... import errors -class PeriodicKillSecondaries(interface.CustomBehavior): +class PeriodicKillSecondaries(interface.Hook): """ Periodically kills the secondaries in a replica set and verifies that they can reach the SECONDARY state without having connectivity @@ -41,7 +41,7 @@ class PeriodicKillSecondaries(interface.CustomBehavior): description = ("PeriodicKillSecondaries (kills the secondary after running tests for a" " configurable period of time)") - interface.CustomBehavior.__init__(self, hook_logger, rs_fixture, description) + interface.Hook.__init__(self, hook_logger, rs_fixture, description) self._period_secs = period_secs self._start_time = None @@ -79,7 +79,7 @@ class PeriodicKillSecondaries(interface.CustomBehavior): test_name = "{}:{}".format(self._last_test_name, self.__class__.__name__) self.hook_test_case = self.make_dynamic_test(testcase.TestCase, "Hook", test_name) - interface.CustomBehavior.start_dynamic_test(self.hook_test_case, test_report) + interface.Hook.start_dynamic_test(self.hook_test_case, test_report) try: self._kill_secondaries() self._check_secondaries_and_restart_fixture() diff --git a/buildscripts/resmokelib/testing/hooks/stepdown.py b/buildscripts/resmokelib/testing/hooks/stepdown.py index 438f4208cad..6732316be8a 100644 --- a/buildscripts/resmokelib/testing/hooks/stepdown.py +++ b/buildscripts/resmokelib/testing/hooks/stepdown.py @@ -19,7 +19,7 @@ from buildscripts.resmokelib.testing.fixtures import replicaset from buildscripts.resmokelib.testing.fixtures import shardedcluster -class ContinuousStepdown(interface.CustomBehavior): +class ContinuousStepdown(interface.Hook): """The ContinuousStepdown hook regularly connects to replica sets and sends a replSetStepDown command. """ @@ -41,8 +41,8 @@ class ContinuousStepdown(interface.CustomBehavior): stepdown_duration_secs: the number of seconds to step down the primary. stepdown_interval_ms: the number of milliseconds between stepdowns. """ - interface.CustomBehavior.__init__(self, hook_logger, fixture, - ContinuousStepdown.DESCRIPTION) + interface.Hook.__init__(self, hook_logger, fixture, + ContinuousStepdown.DESCRIPTION) self._fixture = fixture self._config_stepdown = config_stepdown diff --git a/buildscripts/resmokelib/testing/hooks/validate.py b/buildscripts/resmokelib/testing/hooks/validate.py index 367b905d7ed..66a5d6ec6db 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.JsCustomBehavior): +class ValidateCollections(jsfile.JSHook): """ Runs full validation on all collections in all databases on every stand-alone node, primary replica-set node, or primary shard node. @@ -18,9 +18,9 @@ class ValidateCollections(jsfile.JsCustomBehavior): def __init__(self, hook_logger, fixture, shell_options=None): description = "Full collection validation" js_filename = os.path.join("jstests", "hooks", "run_validate_collections.js") - jsfile.JsCustomBehavior.__init__(self, - hook_logger, - fixture, - js_filename, - description, - shell_options=shell_options) + jsfile.JSHook.__init__(self, + hook_logger, + fixture, + js_filename, + description, + shell_options=shell_options) diff --git a/buildscripts/resmokelib/testing/job.py b/buildscripts/resmokelib/testing/job.py index a684ff24dc0..ccd535677b0 100644 --- a/buildscripts/resmokelib/testing/job.py +++ b/buildscripts/resmokelib/testing/job.py @@ -19,8 +19,7 @@ class Job(object): def __init__(self, logger, fixture, hooks, report, archival, suite_options): """ - Initializes the job with the specified fixture and custom - behaviors. + Initializes the job with the specified fixture and hooks. """ self.logger = logger |