mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-49050 Cannot differentiate logs from different shards with python fixtures
This commit is contained in:
parent
8f4f4741ad
commit
f275428ee2
@ -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)
|
||||
|
||||
|
@ -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."""
|
||||
|
Loading…
Reference in New Issue
Block a user