Beispiel #1
0
    def setup_server(self):
        ServerLayer.__init__(self, self.__name__)
        self.log_file = os.path.join(self.log, 'mongodb.log')
        self.pid_file = os.path.join(self.run, 'mongodb.pid')
        self.lock_file = os.path.join(self.var, 'mongod.lock')
        self.mongod_bin = self.mongod_bin or 'mongod'

        # compute mongod arguments
        self.default_options = {
            'port': self.storage_port,
            'dbpath': self.var,
            'pidfilepath': self.pid_file,
            'logpath': self.log_file,
            'rest': True,
            'noprealloc': True,
            'smallfiles': True,
        }
        all_options = {}
        all_options.update(self.default_options)
        all_options.update(self.extra_options)

        # compute "self.start_cmd"
        arguments_string = self._serialize_arguments(all_options)
        self.start_cmd = '{0} {1}'.format(self.mongod_bin, arguments_string)
        logger.debug('start_cmd=%s' % self.start_cmd)

        # compute "self.servers"
        self.servers = [
            (self.hostname, self.storage_port),
            (self.hostname, self.console_port),
        ]
Beispiel #2
0
 def tearDown(self):
     """
     Tear down the test layer. Remove the working directory.
     """
     ServerLayer.tearDown(self)
     # TODO:
     # maybe differentiate between cleaning up the working directory
     # on startup versus cleaning it up on teardown
     self._workspace_cleanup()
Beispiel #3
0
 def start(self):
     """
     Propagates start operation to ``ServerLayer``.
     Beforehand, brutally removes pid- and lock-files
     to be graceful if the last shutdown went wrong.
     """
     os.path.exists(self.pid_file) and os.unlink(self.pid_file)
     os.path.exists(self.lock_file) and os.unlink(self.lock_file)
     ServerLayer.start(self)