summaryrefslogtreecommitdiff
path: root/buildscripts/resmokelib/testing/fixtures
diff options
context:
space:
mode:
authorCarl Raiden Worley <carl.worley@10gen.com>2020-06-24 10:02:36 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-24 23:19:40 +0000
commitf275428ee2632b120247d437552c08aefa871c31 (patch)
tree50ce8313f6696700c46543b7a701a39d7aab1b4d /buildscripts/resmokelib/testing/fixtures
parent8f4f4741ad6711896caa78fbd0486e2da00e25e4 (diff)
downloadmongo-f275428ee2632b120247d437552c08aefa871c31.tar.gz
SERVER-49050 Cannot differentiate logs from different shards with python fixtures
Diffstat (limited to 'buildscripts/resmokelib/testing/fixtures')
-rw-r--r--buildscripts/resmokelib/testing/fixtures/replicaset.py9
-rw-r--r--buildscripts/resmokelib/testing/fixtures/shardedcluster.py13
2 files changed, 16 insertions, 6 deletions
diff --git a/buildscripts/resmokelib/testing/fixtures/replicaset.py b/buildscripts/resmokelib/testing/fixtures/replicaset.py
index 0c599800c2d..e5bd42521ee 100644
--- a/buildscripts/resmokelib/testing/fixtures/replicaset.py
+++ b/buildscripts/resmokelib/testing/fixtures/replicaset.py
@@ -28,7 +28,8 @@ class ReplicaSetFixture(interface.ReplFixture): # pylint: disable=too-many-inst
num_nodes=2, start_initial_sync_node=False, write_concern_majority_journal_default=None,
auth_options=None, replset_config_options=None, voting_secondaries=True,
all_nodes_electable=False, use_replica_set_connection_string=None, linear_chain=False,
- mixed_bin_versions=None, default_read_concern=None, default_write_concern=None):
+ mixed_bin_versions=None, default_read_concern=None, default_write_concern=None,
+ shard_logging_prefix=None):
"""Initialize ReplicaSetFixture."""
interface.ReplFixture.__init__(self, logger, job_num, dbpath_prefix=dbpath_prefix)
@@ -47,6 +48,7 @@ class ReplicaSetFixture(interface.ReplFixture): # pylint: disable=too-many-inst
self.mixed_bin_versions = utils.default_if_none(mixed_bin_versions,
config.MIXED_BIN_VERSIONS)
self.mixed_bin_versions_config = self.mixed_bin_versions
+ self.shard_logging_prefix = shard_logging_prefix
# Use the values given from the command line if they exist for linear_chain and num_nodes.
linear_chain_option = utils.default_if_none(config.LINEAR_CHAIN, linear_chain)
@@ -548,6 +550,11 @@ class ReplicaSetFixture(interface.ReplFixture): # pylint: disable=too-many-inst
suffix = str(index - 1) if self.num_nodes > 2 else ""
node_name = "secondary{}".format(suffix)
+ if self.shard_logging_prefix is not None:
+ node_name = f"{self.shard_logging_prefix}:{node_name}"
+ return logging.loggers.new_fixture_node_logger("ShardedClusterFixture", self.job_num,
+ node_name)
+
return logging.loggers.new_fixture_node_logger(self.__class__.__name__, self.job_num,
node_name)
diff --git a/buildscripts/resmokelib/testing/fixtures/shardedcluster.py b/buildscripts/resmokelib/testing/fixtures/shardedcluster.py
index 36e5a6f2b39..b5549ad9abc 100644
--- a/buildscripts/resmokelib/testing/fixtures/shardedcluster.py
+++ b/buildscripts/resmokelib/testing/fixtures/shardedcluster.py
@@ -245,8 +245,9 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst
def _new_configsvr(self):
"""Return a replicaset.ReplicaSetFixture configured as the config server."""
+ shard_logging_prefix = "configsvr"
mongod_logger = logging.loggers.new_fixture_node_logger(self.__class__.__name__,
- self.job_num, "configsvr")
+ self.job_num, shard_logging_prefix)
configsvr_options = self.configsvr_options.copy()
@@ -268,13 +269,14 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst
mongod_logger, self.job_num, mongod_options=mongod_options,
preserve_dbpath=preserve_dbpath, num_nodes=num_nodes, auth_options=auth_options,
mixed_bin_versions=None, replset_config_options=replset_config_options,
- **configsvr_options)
+ shard_logging_prefix=shard_logging_prefix, **configsvr_options)
def _new_rs_shard(self, index, num_rs_nodes_per_shard):
"""Return a replicaset.ReplicaSetFixture configured as a shard in a sharded cluster."""
- mongod_logger = logging.loggers.new_fixture_node_logger(
- self.__class__.__name__, self.job_num, "shard{}".format(index))
+ shard_logging_prefix = f"shard{index}"
+ mongod_logger = logging.loggers.new_fixture_node_logger(self.__class__.__name__,
+ self.job_num, shard_logging_prefix)
shard_options = self.shard_options.copy()
@@ -300,7 +302,8 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst
mongod_logger, self.job_num, mongod_options=mongod_options,
preserve_dbpath=preserve_dbpath, num_nodes=num_rs_nodes_per_shard,
auth_options=auth_options, replset_config_options=replset_config_options,
- mixed_bin_versions=mixed_bin_versions, **shard_options)
+ mixed_bin_versions=mixed_bin_versions, shard_logging_prefix=shard_logging_prefix,
+ **shard_options)
def _new_standalone_shard(self, index):
"""Return a standalone.MongoDFixture configured as a shard in a sharded cluster."""