Files
mongo/buildscripts/resmokelib/testing/hooks/reconfig_background.py
Pavi Vetriselvan f452856303 SERVER-45094 add disabled replica set reconfig passthroughs
SERVER-45094 add retryable read logic to network_error_and_txn_override.js

(cherry picked from commit f59f63db6c)

SERVER-45094 add replica_sets_reconfig_jscore_passthrough suite

(cherry picked from commit 4d91fac171)

SERVER-45094 use w:1 writes and remove causal consistency in reconfig passthrough

(cherry picked from commit a43cb23def)

SERVER-45094 add replica_sets_reconfig_jscore_stepdown_passthrough

(cherry picked from commit 81e0ad27c2)

SERVER-45094 add replica_sets_reconfig_kill_primary_jscore_passthrough

(cherry picked from commit 2debab7987)

SERVER-47678 stepdown and kill primary reconfig passthroughs should ignore ReplicaSetMonitorErrors

(cherry picked from commit 91672e58f1)

SERVER-47544 always increase election timeout to 24 hours in passthrough suites

(cherry picked from commit 81d53a715f)
2020-05-14 12:42:24 +00:00

72 lines
3.1 KiB
Python

"""Test hook for running safe reconfigs against the primary of a replica set.
This hook runs continously in a background thread while the test is running.
"""
import os.path
from buildscripts.resmokelib import errors
from buildscripts.resmokelib.testing.hooks import jsfile
from buildscripts.resmokelib.testing.testcases import interface as testcase
from buildscripts.resmokelib.testing.hooks.background_job import _BackgroundJob, _ContinuousDynamicJSTestCase
class DoReconfigInBackground(jsfile.JSHook):
"""A hook for running a safe reconfig against a replica set while a test is running."""
def __init__(self, hook_logger, fixture, shell_options=None):
"""Initialize DoReconfigInBackground."""
description = "Run reconfigs against the primary while the test is running."
js_filename = os.path.join("jstests", "hooks", "run_reconfig_background.js")
jsfile.JSHook.__init__(self, hook_logger, fixture, js_filename, description,
shell_options=shell_options)
self._background_job = None
def before_suite(self, test_report):
"""Start the background thread."""
self._background_job = _BackgroundJob("ReconfigInBackground")
self.logger.info("Starting the background reconfig thread.")
self._background_job.start()
def after_suite(self, test_report):
"""Signal the background thread to exit, and wait until it does."""
if self._background_job is None:
return
self.logger.info("Stopping the background reconfig thread.")
self._background_job.stop()
def before_test(self, test, test_report):
"""Instruct the background thread to run reconfigs while 'test' is also running."""
if self._background_job is None:
return
hook_test_case = _ContinuousDynamicJSTestCase.create_before_test(
self.logger.test_case_logger, test, self, self._js_filename, self._shell_options)
hook_test_case.configure(self.fixture)
self.logger.info("Resuming the background reconfig thread.")
self._background_job.resume(hook_test_case, test_report)
def after_test(self, test, test_report): # noqa: D205,D400
"""Instruct the background thread to stop running reconfigs now that 'test' has
finished running.
"""
if self._background_job is None:
return
self.logger.info("Pausing the background reconfig thread.")
self._background_job.pause()
if self._background_job.exc_info is not None:
if isinstance(self._background_job.exc_info[1], errors.TestFailure):
# If the mongo shell process running the JavaScript file exited with a non-zero
# return code, then we raise an errors.ServerFailure exception to cause resmoke.py's
# test execution to stop.
raise errors.ServerFailure(self._background_job.exc_info[1].args[0])
else:
self.logger.error("Encountered an error inside the background reconfig thread.",
exc_info=self._background_job.exc_info)
raise self._background_job.exc_info[1]