summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2018-08-25 10:53:50 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2018-08-25 10:53:50 -0400
commit0736e45adfd738ec6b87e14e935e9405e6d5aabc (patch)
treed920c7c1791c9edf26d42252240797ebaed83d6c
parenta1a4c8f82019cddc3c830331962b714034c22b9b (diff)
downloadmongo-0736e45adfd738ec6b87e14e935e9405e6d5aabc.tar.gz
SERVER-29008 Set TestData.numTestClients property in resmoke.py.
Forwards the value for resmoke.py's --numClientsPerFixture command line option to the mongo shell running the test. This enables the fuzzer to know if there are concurrent clients running the test. (cherry picked from commit 835a13294a78486e0d5458e8814895ea76bf5f7a)
-rw-r--r--buildscripts/resmokelib/core/programs.py3
-rw-r--r--buildscripts/resmokelib/testing/testcases.py26
2 files changed, 19 insertions, 10 deletions
diff --git a/buildscripts/resmokelib/core/programs.py b/buildscripts/resmokelib/core/programs.py
index d94cd438ee0..63e2b12de87 100644
--- a/buildscripts/resmokelib/core/programs.py
+++ b/buildscripts/resmokelib/core/programs.py
@@ -116,7 +116,7 @@ def mongos_program(logger, executable=None, process_kwargs=None, **kwargs):
def mongo_shell_program(logger, executable=None, connection_string=None, filename=None,
- process_kwargs=None, isMainTest=True, **kwargs):
+ process_kwargs=None, **kwargs):
"""
Returns a Process instance that starts a mongo shell with arguments
constructed from 'kwargs'.
@@ -148,7 +148,6 @@ def mongo_shell_program(logger, executable=None, connection_string=None, filenam
# Only use 'opt_default' if the property wasn't set in the YAML configuration.
test_data[opt_name] = opt_default
- test_data["isMainTest"] = isMainTest
global_vars["TestData"] = test_data
# Pass setParameters for mongos and mongod through TestData. The setParameter parsing in
diff --git a/buildscripts/resmokelib/testing/testcases.py b/buildscripts/resmokelib/testing/testcases.py
index 78110ff680d..44bb0d767ea 100644
--- a/buildscripts/resmokelib/testing/testcases.py
+++ b/buildscripts/resmokelib/testing/testcases.py
@@ -344,9 +344,6 @@ class JSTestCase(TestCase):
test_data = global_vars.get("TestData", {}).copy()
test_data["minPort"] = core.network.PortAllocator.min_test_port(fixture.job_num)
test_data["maxPort"] = core.network.PortAllocator.max_test_port(fixture.job_num)
- # Marks the main test when multiple test clients are run concurrently, to notify the test
- # of any code that should only be run once. If there is only one client, it is the main one.
- test_data["isMainTest"] = True
global_vars["TestData"] = test_data
self.shell_options["global_vars"] = global_vars
@@ -419,19 +416,32 @@ class JSTestCase(TestCase):
raise t._get_exception()
def _make_process(self, logger=None, thread_id=0):
+ # Since _make_process() is called by each thread, we make a shallow copy of the mongo shell
+ # options to avoid modifying the shared options for the JSTestCase.
+ shell_options = self.shell_options.copy()
+ global_vars = shell_options["global_vars"].copy()
+ test_data = global_vars["TestData"].copy()
+
+ # We set a property on TestData to mark the main test when multiple clients are going to run
+ # concurrently in case there is logic within the test that must execute only once. We also
+ # set a property on TestData to indicate how many clients are going to run the test so they
+ # can avoid executing certain logic when there may be other operations running concurrently.
+ is_main_test = thread_id == 0
+ test_data["isMainTest"] = is_main_test
+ test_data["numTestClients"] = self.num_clients
+
+ global_vars["TestData"] = test_data
+ shell_options["global_vars"] = global_vars
+
# If logger is none, it means that it's not running in a thread and thus logger should be
# set to self.logger.
logger = utils.default_if_none(logger, self.logger)
- is_main_test = True
- if thread_id > 0:
- is_main_test = False
return core.programs.mongo_shell_program(
logger,
executable=self.shell_executable,
filename=self.js_filename,
connection_string=self.fixture.get_driver_connection_url(),
- isMainTest=is_main_test,
- **self.shell_options)
+ **shell_options)
def _run_test_in_thread(self, thread_id):
# Make a logger for each thread.