diff --git a/buildscripts/resmokelib/config.py b/buildscripts/resmokelib/config.py index 444f5e8b7ae..d11fcc917b0 100644 --- a/buildscripts/resmokelib/config.py +++ b/buildscripts/resmokelib/config.py @@ -3,7 +3,7 @@ import collections import datetime import itertools -import os.path +import os import time import buildscripts.resmokelib.setup_multiversion.config as multiversion_config @@ -817,3 +817,6 @@ VALIDATE_SELECTOR_PATHS = True # If set, resmoke.py will set Testdata.pauseAfterPopulate to allow tests that check this # flag to pause after populating their initial datasets. PAUSE_AFTER_POPULATE = None + +# Whether ASAN (AddressSanitizer) is enabled, determined by the presence of ASAN_OPTIONS. +IS_ASAN = bool(os.environ.get("ASAN_OPTIONS")) diff --git a/buildscripts/resmokelib/testing/fixtures/interface.py b/buildscripts/resmokelib/testing/fixtures/interface.py index 3ae34480775..2280c42e0bf 100644 --- a/buildscripts/resmokelib/testing/fixtures/interface.py +++ b/buildscripts/resmokelib/testing/fixtures/interface.py @@ -217,7 +217,7 @@ class Fixture(object, metaclass=registry.make_registry_metaclass(_FIXTURES)): def mongo_client( self, read_preference=pymongo.ReadPreference.PRIMARY, timeout_millis=30000, **kwargs - ): + ) -> pymongo.MongoClient: """Return a pymongo.MongoClient connecting to this fixture with specified 'read_preference'. The PyMongo driver will wait up to 'timeout_millis' milliseconds @@ -524,7 +524,9 @@ def create_fixture_table(fixture): return "Fixture status:\n" + table -def build_client(node, auth_options=None, read_preference=pymongo.ReadPreference.PRIMARY): +def build_client( + node, auth_options=None, read_preference=pymongo.ReadPreference.PRIMARY, **kwargs +) -> pymongo.MongoClient: """Authenticate client for the 'authenticationDatabase' and return the client.""" if auth_options is not None: return node.mongo_client( @@ -533,9 +535,10 @@ def build_client(node, auth_options=None, read_preference=pymongo.ReadPreference authSource=auth_options["authenticationDatabase"], authMechanism=auth_options["authenticationMechanism"], read_preference=read_preference, + **kwargs, ) else: - return node.mongo_client(read_preference=read_preference) + return node.mongo_client(read_preference=read_preference, **kwargs) # Represents a row in a node info table. diff --git a/buildscripts/resmokelib/testing/hooks/fuzz_runtime_parameters.py b/buildscripts/resmokelib/testing/hooks/fuzz_runtime_parameters.py index 31450be9adc..0dad086f412 100644 --- a/buildscripts/resmokelib/testing/hooks/fuzz_runtime_parameters.py +++ b/buildscripts/resmokelib/testing/hooks/fuzz_runtime_parameters.py @@ -7,7 +7,7 @@ import sys import threading import time -from buildscripts.resmokelib import errors +from buildscripts.resmokelib import config, errors from buildscripts.resmokelib.mongo_fuzzer_configs import generate_normal_mongo_parameters from buildscripts.resmokelib.testing.fixtures import interface as fixture_interface from buildscripts.resmokelib.testing.fixtures import replicaset, shardedcluster, standalone @@ -23,6 +23,13 @@ def validate_runtime_parameter_spec(spec): ) +def build_client(node, auth_options): + """Build a pymongo MongoClient for the given node with the given auth options.""" + if config.IS_ASAN: + return fixture_interface.build_client(node, auth_options, timeout_millis=120000) + return fixture_interface.build_client(node, auth_options) + + class RuntimeParametersState: """Encapsulates the runtime-state of a set of parameters we are fuzzing. Tracks the last time we set a parameter value and holds the logic for generating new values.""" @@ -222,7 +229,7 @@ class FuzzRuntimeParameters(interface.Hook): def _invoke_get_parameter_and_log(self, node): """Helper to print the current state of a node's runtime-fuzzable parameters. Only usable once before_suite has initialized the runtime state of the parameters.""" - client = fixture_interface.build_client(node, self._auth_options) + client = build_client(node, self._auth_options) params_to_get = ( self._mongos_param_state.get_spec() if client.is_mongos @@ -366,9 +373,7 @@ class _SetParameterThread(threading.Thread): mongod_params_to_set, ) for node in repl_set.nodes: - invoke_set_parameter( - fixture_interface.build_client(node, self._auth_options), mongod_params_to_set - ) + invoke_set_parameter(build_client(node, self._auth_options), mongod_params_to_set) for standalone in self._standalone_fixtures: self.logger.info( @@ -376,9 +381,7 @@ class _SetParameterThread(threading.Thread): standalone.port, mongod_params_to_set, ) - invoke_set_parameter( - fixture_interface.build_client(standalone, self._auth_options), mongod_params_to_set - ) + invoke_set_parameter(build_client(standalone, self._auth_options), mongod_params_to_set) for mongos in self._mongos_fixtures: self.logger.info( @@ -386,6 +389,4 @@ class _SetParameterThread(threading.Thread): mongos.port, mongos_params_to_set, ) - invoke_set_parameter( - fixture_interface.build_client(mongos, self._auth_options), mongos_params_to_set - ) + invoke_set_parameter(build_client(mongos, self._auth_options), mongos_params_to_set) diff --git a/buildscripts/resmokelib/testing/hooks/validate.py b/buildscripts/resmokelib/testing/hooks/validate.py index b9c37164b31..540883648c2 100644 --- a/buildscripts/resmokelib/testing/hooks/validate.py +++ b/buildscripts/resmokelib/testing/hooks/validate.py @@ -11,6 +11,7 @@ import pymongo.mongo_client from pymongo.collection import Collection from pymongo.database import Database +from buildscripts.resmokelib import config from buildscripts.resmokelib.testing.fixtures.external import ExternalFixture from buildscripts.resmokelib.testing.fixtures.interface import build_client from buildscripts.resmokelib.testing.fixtures.standalone import MongoDFixture @@ -131,7 +132,12 @@ def validate_node( auth_options = None if shell_options and "authenticationMechanism" in shell_options: auth_options = shell_options - client = build_client(node, auth_options, pymongo.ReadPreference.PRIMARY_PREFERRED) + if config.IS_ASAN: + client = build_client( + node, auth_options, pymongo.ReadPreference.PRIMARY_PREFERRED, timeout_millis=120000 + ) + else: + client = build_client(node, auth_options, pymongo.ReadPreference.PRIMARY_PREFERRED) # Skip validating collections for arbiters. admin_db = client.get_database("admin")