mongo/buildscripts/resmokelib/testing/hooks
Gabriel Marks f80ba058ab SERVER-112797 Set security cluster parameters periodically at runtime in config fuzzer (#45148)
GitOrigin-RevId: fd2d873e5a58d4c549006b8b8563caa1e0c427ca
2025-12-15 22:18:00 +00:00
..
OWNERS.yml SERVER-112797 Set security cluster parameters periodically at runtime in config fuzzer (#45148) 2025-12-15 22:18:00 +00:00
README.md SERVER-113858 Rename the test suites and python hooks to reference execution control rather than the concurrency adjustment algorithm (#43953) 2025-11-21 16:16:52 +00:00
__init__.py SERVER-94076 Remove unused imports via Ruff rule (#27337) 2024-10-04 01:43:13 +00:00
add_remove_shards.py SERVER-114666 Forbid tracking temporary collections in the global catalog (#44712) 2025-12-08 17:15:38 +00:00
analyze_shard_key.py SERVER-90570: Enable formatting checks for buildscripts directory, excluding idl (#22254) 2024-05-16 22:07:36 +00:00
antithesis_logging.py SERVER-94077 Use isort in Ruff configs (#27865) 2024-10-10 19:33:49 +00:00
background_job.py SERVER-99522 Delete dead py linters (#31760) 2025-04-09 19:33:45 +00:00
bghook.py SERVER-99522 Delete dead py linters (#31760) 2025-04-09 19:33:45 +00:00
change_streams.py SERVER-99522 Delete dead py linters (#31760) 2025-04-09 19:33:45 +00:00
check_system_buckets_metrics.py SERVER-112599 Introduce server status metrics to track user commands targeting system buckets collections (#42814) 2025-12-11 10:16:08 +00:00
cleanup.py SERVER-107303 Replica set reconfiguration to CSRS testing (#39143) 2025-08-08 07:13:03 +00:00
cleanup_concurrency_workloads.py SERVER-94077 Use isort in Ruff configs (#27865) 2024-10-10 19:33:49 +00:00
cluster_index_consistency.py SERVER-90570: Enable formatting checks for buildscripts directory, excluding idl (#22254) 2024-05-16 22:07:36 +00:00
cluster_parameter.py SERVER-94076 Remove unused imports via Ruff rule (#27337) 2024-10-04 01:43:13 +00:00
continuous_initial_sync.py SERVER-102043: Add retries on AutoReconnect in hooks (#33339) 2025-04-10 01:51:17 +00:00
cpp_libfuzzer.py SERVER-106467 save fuzzer artifacts to a directory that will be archived (#40085) 2025-08-15 18:01:59 +00:00
dbcheck_background.py SERVER-90570: Enable formatting checks for buildscripts directory, excluding idl (#22254) 2024-05-16 22:07:36 +00:00
dbhash.py SERVER-99522 Delete dead py linters (#31760) 2025-04-09 19:33:45 +00:00
dbhash_background.py SERVER-90570: Enable formatting checks for buildscripts directory, excluding idl (#22254) 2024-05-16 22:07:36 +00:00
drop_sessions_collection.py SERVER-109587 Handle secondaries when re-creating sessions collection in background hook (#40372) 2025-08-22 07:58:00 +00:00
drop_user_collections.py SERVER-92105 Make DropShardedCollections hook drop all user collections (#24322) 2024-07-04 16:27:44 +00:00
enable_spurious_write_conflicts.py SERVER-103300: Fix filepath for spurious write conflicts hook (#34511) 2025-04-10 04:47:33 +00:00
fcv_upgrade_downgrade.py SERVER-90570: Enable formatting checks for buildscripts directory, excluding idl (#22254) 2024-05-16 22:07:36 +00:00
fuzz_runtime_parameters.py SERVER-112797 Set security cluster parameters periodically at runtime in config fuzzer (#45148) 2025-12-15 22:18:00 +00:00
fuzz_runtime_stress.py SERVER-99522 Delete dead py linters (#31760) 2025-04-09 19:33:45 +00:00
fuzzer_restore_settings.py SERVER-90570: Enable formatting checks for buildscripts directory, excluding idl (#22254) 2024-05-16 22:07:36 +00:00
generate_and_check_perf_results.py SERVER-112201 Add ability to override benchmarks_sep failures in commit queue. (#42464) 2025-10-14 13:25:57 +00:00
hello_failures.py SERVER-94077 Use isort in Ruff configs (#27865) 2024-10-10 19:33:49 +00:00
initialsync.py SERVER-103471 Don't use fileCopyBased initsync with inMemory storage engine in BackgroundInitialSync hook (#34690) 2025-04-11 14:33:03 +00:00
interface.py SERVER-99522 Delete dead py linters (#31760) 2025-04-09 19:33:45 +00:00
jsfile.py SERVER-96927 Use extend-select instead of select to include isort (#29038) 2024-11-26 20:14:08 +00:00
lifecycle.py SERVER-94077 Use isort in Ruff configs (#27865) 2024-10-10 19:33:49 +00:00
magic_restore.py SERVER-101646 Move magic restore test infrastructure into enterprise module (#35020) 2025-04-16 15:33:16 +00:00
maintenance.py SERVER-111295 Set python as formatter in format_multirun (#41677) 2025-09-24 17:41:24 +00:00
metadata_consistency.py Revert "SERVER-114501 Add availability canaries hooks (#44642)" (#44865) 2025-12-05 17:06:47 +00:00
oplog.py SERVER-99522 Delete dead py linters (#31760) 2025-04-09 19:33:45 +00:00
orphans.py SERVER-90570: Enable formatting checks for buildscripts directory, excluding idl (#22254) 2024-05-16 22:07:36 +00:00
periodic_kill_secondaries.py SERVER-111008 Remove change stream change collection code (#41875) 2025-10-07 20:43:45 +00:00
periodic_stack_trace.py SERVER-96106 Support EINTR/SIGUSR2 testing via config fuzzer (#29737) 2024-12-06 01:49:52 +00:00
preimages_consistency.py SERVER-99522 Delete dead py linters (#31760) 2025-04-09 19:33:45 +00:00
queryable_server_hook.py SERVER-94077 Use isort in Ruff configs (#27865) 2024-10-10 19:33:49 +00:00
reconfig_background.py SERVER-90570: Enable formatting checks for buildscripts directory, excluding idl (#22254) 2024-05-16 22:07:36 +00:00
replicaset_transition_to_and_from_csrs.py SERVER-111964 replicaset_transition_to_and_from_csrs should be resilient to text fixture restarts (#42359) 2025-10-10 10:17:19 +00:00
rotate_execution_control_params.py SERVER-113858 Rename the test suites and python hooks to reference execution control rather than the concurrency adjustment algorithm (#43953) 2025-11-21 16:16:52 +00:00
routing_table_consistency.py SERVER-90570: Enable formatting checks for buildscripts directory, excluding idl (#22254) 2024-05-16 22:07:36 +00:00
run_query_stats.py SERVER-94077 Use isort in Ruff configs (#27865) 2024-10-10 19:33:49 +00:00
secondary_lag.py SERVER-90570: Enable formatting checks for buildscripts directory, excluding idl (#22254) 2024-05-16 22:07:36 +00:00
shard_filtering_metadata.py SERVER-90570: Enable formatting checks for buildscripts directory, excluding idl (#22254) 2024-05-16 22:07:36 +00:00
simulate_crash.py SERVER-112797 Set security cluster parameters periodically at runtime in config fuzzer (#45148) 2025-12-15 22:18:00 +00:00
stepdown.py SERVER-104330 ContinuousAddRemoveShard clashes with ContinuousStepdown (#35881) 2025-06-10 11:32:02 +00:00
validate.py SERVER-114319: Add exemption to initial sync and kill primary suites for enforceFastCounts and collHash (#44421) 2025-12-03 19:10:58 +00:00
validate_background.py SERVER-90570: Enable formatting checks for buildscripts directory, excluding idl (#22254) 2024-05-16 22:07:36 +00:00
validate_direct_secondary_reads.py SERVER-99522 Delete dead py linters (#31760) 2025-04-09 19:33:45 +00:00
wait_for_replication.py SERVER-100130 Add support to pass traceCtx from resmoke to legacy shell (#42761) 2025-10-22 16:48:28 +00:00

README.md

Hooks

Hooks are a mechanism to run routines around the tests, at the test content boundaries.

Supported hooks

Specify any of the following as the hooks in your Suite config:

  • AnalyzeShardKeysInBackground - A hook for running analyzeShardKey commands while a test is running.
  • AntithesisLogging - Prints antithesis commands before & after test run.
  • BackgroundInitialSync - Background Initial Sync
    • 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.
    • This test accepts a parameter n that specifies a number of tests after which it will wait for replication to finish before validating and restarting the initial sync node.
    • This requires the ReplicaSetFixture to be started with start_initial_sync_node=True. If used at the same time as CleanEveryN, the n value passed to this hook should be equal to the n value for CleanEveryN.
  • CheckClusterIndexConsistency - Checks that indexes are the same across chunks for the same collections.
  • CheckMetadataConsistencyInBackground - Check the metadata consistency of a sharded cluster.
  • CheckOrphansDeleted - Check if the range deleter failed to delete any orphan documents.
  • CheckReplDBHashInBackground - A hook for comparing the dbhashes of all replica set members while a test is running.
  • CheckReplDBHash - Check if the dbhashes match.
  • CheckReplOplogs - Check that local.oplog.rs matches on the primary and secondaries.
  • CheckReplPreImagesConsistency - Check that config.system.preimages is consistent between the primary and secondaries.
  • CheckRoutingTableConsistency - Verifies the absence of corrupted entries in config.chunks and config.collections.
  • CheckShardFilteringMetadata - Inspect filtering metadata on shards
  • CleanEveryN - Restart the fixture after it has ran n tests.
  • CleanupConcurrencyWorkloads - Drop all databases, except those that have been excluded.
    • For concurrency tests that run on different DBs, drop all databases except ones in exclude_dbs. For tests that run on the same DB, drop all databases except ones in exclude_dbs and the DB used by the test/workloads. For tests that run on the same collection, drop all collections in all databases except for exclude_dbs and the collection used by the test/workloads.
    • On mongod-related fixtures, this will clear the dbpath
  • ClusterParameter - Sets the specified cluster server parameter.
  • ContinuousAddRemoveShard - Continuously adds and removes shards at regular intervals. If running with configsvr transitions, will transition in/out of config shard mode.
  • ContinuousInitialSync - Periodically initial sync nodes then step them up.
  • ContinuousStepdown - regularly connect to replica sets and send a replSetStepDown command.
  • ContinuousTransition - connects to replica sets and transitions them from replica set to CSRS node in the background.
  • DoReconfigInBackground - A hook for running a safe reconfig against a replica set while a test is running.
  • DropSessionsCollection - A hook for dropping and recreating config.system.sessions while tests are running.
  • DropUserCollections - Drops all user collections.
  • EnableSpuriousWriteConflicts - Toggles write conflicts.
  • FCVUpgradeDowngradeInBackground - A hook to run background FCV upgrade and downgrade against test servers while a test is running.
  • FuzzRuntimeParameters - Regularly connect to nodes and sends them a setParameter command; uses the Config Fuzzer.
  • FuzzRuntimeStress - Test hook that periodically changes the amount of stress the system is experiencing.
  • FuzzerRestoreSettings - Cleans up unwanted changes from fuzzer.
  • GenerateAndCheckPerfResults - Combine JSON results from individual benchmarks and check their reported values against any thresholds set for them.
    • Combines test results from individual benchmark files to a single file. This is useful for generating the json file to feed into the Evergreen performance visualization plugin.
  • HelloDelays - Sets Hello fault injections.
  • IntermediateInitialSync - Intermediate Initial Sync
    • 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.
    • This requires the ReplicaSetFixture to be started with 'start_initial_sync_node=True'.
  • LagOplogApplicationInBackground - Toggles secondary oplog application lag.
  • LibfuzzerHook - Merges inputs after a fuzzer run.
  • MagicRestoreEveryN - Open a backup cursor and run magic restore process after n tests have run.
    • Requires the use of MagicRestoreFixture.
  • PeriodicKillSecondaries - Periodically kills the secondaries in a replica set.
    • Also verifies that the secondaries can reach the SECONDARY state without having connectivity to the primary after an unclean shutdown.
  • PeriodicStackTrace - Test hook that sends the stacktracing signal to mongo processes at randomized intervals.
  • QueryableServerHook - Starts the queryable server before each test for queryable restores. Restarts the queryable server between tests.
  • RotateExecutionControlParams - Periodically rotates 'executionControlConcurrencyAdjustmentAlgorithm' and deprioritization server parameters to random valid values.
  • RunChangeStreamsInBackground - Run in the background full cluster change streams while a test is running. Open and close the change stream every 1..10 tests (random using config.RANDOM_SEED).
  • RunDBCheckInBackground - A hook for running dbCheck on a replica set while a test is running.
    • This includes dbhashes for all non-local databases and non-replicated system collections that match on the primary and secondaries.
    • It also will check the performance results against any thresholds that are set for each benchmark. If no thresholds are set for a test, this hook should always pass.
  • RunQueryStats - Runs $queryStats after every test, and clears the query stats store before every test.
  • SimulateCrash - A hook to simulate crashes.
  • ValidateCollections - Run full validation.
  • ValidateCollectionsInBackground - A hook to run background collection validation against test servers while a test is running.
    • This will run on all collections in all databases on every stand-alone node, primary replica-set node, or primary shard node.
  • ValidateDirectSecondaryReads - Only supported in suites that use ReplicaSetFixture.
    • To be used with set_read_preference_secondary.js and implicit_enable_profiler.js in suites that read directly from secondaries in a replica set. Check the profiler collections of all databases at the end of the suite to verify that each secondary only ran the read commands it got directly from the shell.
  • WaitForReplication - Wait for replication to complete.

Interfaces

All hooks inherit from the buildscripts.resmokelib.testing.hooks.interface.Hook parent class and can override any subset of the following empty base methods:

  • before_suite
  • before_test
  • after_test
  • after_suite

At least 1 base method must be overridden, otherwise the hook will not do anything at all. During test suite execution, each hook runs its custom logic in the respective scenarios. Some customizable tasks that hooks can perform include: validating data, deleting data, performing cleanup, etc.

  • BGHook - A hook that repeatedly calls run_action() in a background thread for the duration of the test suite.
  • DataConsistencyHook - 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.
  • Hook - Common interface all Hooks will inherit from.
  • JSHook - A hook interface with a static JavaScript file to execute.
  • PerClusterDataConsistencyHook - A hook that runs on each independent cluster of the fixture.
    • The independent cluster itself may be another fixture.