2021-02-26 16:52:14 +00:00
|
|
|
"""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
|
|
|
|
|
|
2024-10-10 10:59:18 -07:00
|
|
|
from buildscripts.resmokelib.testing.hooks import interface, jsfile
|
2021-02-26 16:52:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class EnableSpuriousWriteConflicts(interface.Hook):
|
|
|
|
|
"""Toggles write conflicts."""
|
|
|
|
|
|
2021-07-29 12:53:14 -04:00
|
|
|
IS_BACKGROUND = False
|
|
|
|
|
|
2022-09-02 21:56:05 +00:00
|
|
|
def __init__(self, hook_logger, fixture, shell_options=None):
|
2021-02-26 16:52:14 +00:00
|
|
|
"""Initialize ToggleWriteConflicts."""
|
|
|
|
|
super().__init__(hook_logger, fixture, "TogglesWTWriteConflictExceptions")
|
2025-04-03 10:20:08 -04:00
|
|
|
self._enable_js_filename = os.path.join(
|
|
|
|
|
"jstests", "hooks", "write_conflicts", "enable_write_conflicts.js"
|
|
|
|
|
)
|
|
|
|
|
self._disable_js_filename = os.path.join(
|
|
|
|
|
"jstests", "hooks", "write_conflicts", "disable_write_conflicts.js"
|
|
|
|
|
)
|
2021-02-26 16:52:14 +00:00
|
|
|
self._shell_options = shell_options
|
|
|
|
|
|
|
|
|
|
def before_test(self, test, test_report):
|
|
|
|
|
"""Enable WTWriteConflictExceptions."""
|
|
|
|
|
hook_test_case = jsfile.DynamicJSTestCase.create_after_test(
|
2024-05-16 18:00:17 -04:00
|
|
|
test.logger, test, self, self._enable_js_filename, self._shell_options
|
|
|
|
|
)
|
2021-02-26 16:52:14 +00:00
|
|
|
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(
|
2024-05-16 18:00:17 -04:00
|
|
|
test.logger, test, self, self._disable_js_filename, self._shell_options
|
|
|
|
|
)
|
2021-02-26 16:52:14 +00:00
|
|
|
hook_test_case.configure(self.fixture)
|
|
|
|
|
hook_test_case.run_dynamic_test(test_report)
|