Пример #1
0
    def __init_mongod(self, params, add_auth=False):
        cfg = self.mongod_default.copy()
        cfg.update(params)

        # create db folder
        cfg['dbpath'] = self.__init_db(cfg.get('dbpath', None))

        if add_auth:
            cfg['auth'] = True
            if self.auth_key:
                cfg['keyFile'] = self.key_file

        # create logpath: goes in dbpath by default under process name + ".log"
        logpath = cfg.setdefault('logpath',
                                 os.path.join(cfg['dbpath'], 'mongod.log'))
        self.__init_logpath(logpath)

        # find open port
        if 'port' not in cfg:
            cfg['port'] = process.PortPool().port(check=True)

        self.__init_test_commands(cfg)

        if self.enable_majority_read_concern and self.version >= (3, 2):
            cfg['enableMajorityReadConcern'] = True

        return process.write_config(cfg), cfg
Пример #2
0
 def setUp(self):
     self.hostname = HOSTNAME
     self.s = None
     self.executable = sys.executable
     self.pp = process.PortPool(min_port=1025, max_port=2000)
     self.sockets = {}
     self.tmp_files = list()
     self.bin_path = os.path.join(os.environ.get('MONGOBIN', ''), 'mongod')
     self.db_path = tempfile.mkdtemp()
     self.cfg = {"oplogSize": 10, 'dbpath': self.db_path}
Пример #3
0
    def __init_mongos(self, params, ssl):
        cfg = params.copy()
        cfg.update(ssl)

        self.__init_logpath(cfg.get('logpath', None))

        # use keyFile
        if self.auth_key:
            cfg['keyFile'] = self.__init_auth_key(self.auth_key, tempfile.mkdtemp())

        if 'port' not in cfg:
            cfg['port'] = process.PortPool().port(check=True)

        return process.write_config(cfg), cfg
Пример #4
0
    def __init_mongos(self, params):
        cfg = params.copy()

        log_path = cfg.setdefault(
            'logpath',
            os.path.join(tempfile.mkdtemp(prefix='mongo-'), 'mongos.log'))
        self.__init_logpath(log_path)

        # use keyFile
        if self.auth_key:
            cfg['keyFile'] = self.key_file

        if 'port' not in cfg:
            cfg['port'] = process.PortPool().port(check=True)

        self.__init_test_commands(cfg)

        return process.write_config(cfg), cfg
Пример #5
0
    def __init_mongod(self, params, add_auth=False):
        cfg = self.mongod_default.copy()
        cfg.update(params)

        # create db folder
        cfg['dbpath'] = self.__init_db(cfg.get('dbpath', None))

        if add_auth:
            cfg['auth'] = True
            if self.auth_key:
                cfg['keyFile'] = self.key_file

        # create logpath: goes in dbpath by default under process name + ".log"
        logpath = cfg.setdefault('logpath',
                                 os.path.join(cfg['dbpath'], 'mongod.log'))
        self.__init_logpath(logpath)

        # find open port
        if 'port' not in cfg:
            cfg['port'] = process.PortPool().port(check=True)

        self.__init_test_commands(cfg)
        self.__init_compressors(cfg)

        # Read concern majority requires MongoDB >= 3.2, WiredTiger storage
        # engine, and protocol version 1:
        # https://docs.mongodb.com/manual/reference/read-concern/
        if ('enableMajorityReadConcern' not in cfg
                and self.enable_majority_read_concern and self.version >=
            (3, 2)):
            if (cfg.get('storageEngine', 'wiredTiger') == 'wiredTiger'
                    and cfg.get('protocolVersion', 1) == 1):
                cfg['enableMajorityReadConcern'] = True
            else:
                logger.info(
                    'Not adding enableMajorityReadConcern because '
                    'storageEngine=%r and protocolVersion=%r is '
                    'incompatible' %
                    (cfg.get('storageEngine'), cfg.get('protocolVersion')))

        return process.write_config(cfg), cfg
Пример #6
0
    def __init_mongod(self, params, ssl):
        cfg = self.mongod_default.copy()
        cfg.update(params)
        cfg.update(ssl)

        # create db folder
        cfg['dbpath'] = self.__init_db(cfg.get('dbpath', None))

        # use keyFile
        if self.auth_key:
            cfg['auth'] = True
            cfg['keyFile'] = self.__init_auth_key(self.auth_key, cfg['dbpath'])

        if self.login:
            cfg['auth'] = True

        # create logpath
        self.__init_logpath(cfg.get('logpath', None))

        # find open port
        if 'port' not in cfg:
            cfg['port'] = process.PortPool().port(check=True)

        return process.write_config(cfg), cfg
Пример #7
0
 def test_singleton(self):
     pp2 = process.PortPool(min_port=1025, max_port=1038)
     self.assertEqual(id(self.pp), id(pp2))
Пример #8
0
 def setUp(self):
     self.hostname = HOSTNAME
     self.pp = process.PortPool()
     self.pp.change_range(min_port=1025, max_port=1080)
     self.sockets = {}