Esempio n. 1
0
    def start_server(self, config=None):
        '''Starts a junebug server. Stores the service to "self.service", and
        the url at "self.url"'''
        # TODO: This setup is very manual, because we don't call
        # service.startService. This must be fixed to close mirror the real
        # program with our tests.
        if config is None:
            config = yield self.create_channel_config()
        self.service = JunebugService(config)
        self.api = JunebugApi(self.service, config)
        self.service.api = self.api

        redis = yield self.get_redis()
        yield self.api.setup(redis, self.get_message_sender())

        self.config = self.api.config
        self.redis = self.api.redis
        self.inbounds = self.api.inbounds
        self.outbounds = self.api.outbounds
        self.message_sender = self.api.message_sender

        port = reactor.listenTCP(0,
                                 Site(self.api.app.resource()),
                                 interface='127.0.0.1')
        self.service._port = port
        self.addCleanup(self.stop_server)
        addr = port.getHost()
        self.url = "http://%s:%s" % (addr.host, addr.port)
Esempio n. 2
0
    def test_start_service(self):
        service = JunebugService(
            JunebugConfig({
                'host': '127.0.0.1',
                'port': 0,
            }))

        yield service.startService()
        server = service._port
        self.assertTrue(server.connected)

        yield service.stopService()
        self.assertFalse(server.connected)
Esempio n. 3
0
def start_server(config):
    '''Starts a new Junebug HTTP API server on the specified resource and
    port'''
    service = JunebugService(config)
    yield service.startService()
    returnValue(service)