Ejemplo n.º 1
0
    def _new_mongod(self, index, replset_name):
        """Return a standalone.MongoDFixture configured to be used as replica-set member."""
        mongod_executable = (self.mongod_executable
                             if self.mixed_bin_versions is None else self.mixed_bin_versions[index])
        mongod_logger = self._get_logger_for_mongod(index)
        mongod_options = self.mongod_options.copy()
        mongod_options["replSet"] = replset_name
        mongod_options["dbpath"] = os.path.join(self._dbpath_prefix, "node{}".format(index))
        mongod_options["set_parameters"] = mongod_options.get("set_parameters", {}).copy()

        return standalone.MongoDFixture(
            mongod_logger, self.job_num, mongod_executable=mongod_executable,
            mongod_options=mongod_options, preserve_dbpath=self.preserve_dbpath)
Ejemplo n.º 2
0
    def _new_standalone_shard(self, index):
        """Return a standalone.MongoDFixture 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_options = self.shard_options.copy()

        preserve_dbpath = shard_options.pop("preserve_dbpath", self.preserve_dbpath)

        mongod_options = self.mongod_options.copy()
        mongod_options.update(shard_options.pop("mongod_options", {}))
        mongod_options["shardsvr"] = ""
        mongod_options["dbpath"] = os.path.join(self._dbpath_prefix, "shard{}".format(index))

        return standalone.MongoDFixture(mongod_logger, self.job_num, mongod_options=mongod_options,
                                        preserve_dbpath=preserve_dbpath, **shard_options)