Files
mongo/buildscripts/resmokelib/testing/hooks/enable_spurious_write_conflicts.py
Steve McClure b4b23946cd SERVER-90570: Enable formatting checks for buildscripts directory, excluding idl (#22254)
GitOrigin-RevId: 9d997a9f44cd43a8dec7c2a17fa2dbcd875e92f6
2024-05-16 22:07:36 +00:00

40 lines
1.6 KiB
Python

"""Test hook for enabling and disabling write conflict failpoints.
The main use case is to ensure that other hooks that will run against the server will not
encounter unexpected failures.
"""
import os.path
from buildscripts.resmokelib.testing.hooks import interface
from buildscripts.resmokelib.testing.hooks import jsfile
class EnableSpuriousWriteConflicts(interface.Hook):
"""Toggles write conflicts."""
IS_BACKGROUND = False
def __init__(self, hook_logger, fixture, shell_options=None):
"""Initialize ToggleWriteConflicts."""
super().__init__(hook_logger, fixture, "TogglesWTWriteConflictExceptions")
self._enable_js_filename = os.path.join("jstests", "hooks", "enable_write_conflicts.js")
self._disable_js_filename = os.path.join("jstests", "hooks", "disable_write_conflicts.js")
self._shell_options = shell_options
def before_test(self, test, test_report):
"""Enable WTWriteConflictExceptions."""
hook_test_case = jsfile.DynamicJSTestCase.create_after_test(
test.logger, test, self, self._enable_js_filename, self._shell_options
)
hook_test_case.configure(self.fixture)
hook_test_case.run_dynamic_test(test_report)
def after_test(self, test, test_report):
"""Disable WTWriteConflictExceptions."""
hook_test_case = jsfile.DynamicJSTestCase.create_after_test(
test.logger, test, self, self._disable_js_filename, self._shell_options
)
hook_test_case.configure(self.fixture)
hook_test_case.run_dynamic_test(test_report)