Exemplo n.º 1
0
    def setUp(self):
        reactor = ExtendedMemoryReactorClock()

        logging_config = {
            "setup": {
                "disable_existing_loggers":
                False,  # otherwise this breaks logging!
                "formatters": {
                    "normal": {
                        "format":
                        "%(asctime)s [%(process)d] "
                        "%(levelname)-5s %(name)s %(message)s"
                    }
                },
                "handlers": {
                    "stderr": {
                        "class": "logging.StreamHandler",
                        "formatter": "normal",
                        "stream": "ext://sys.stderr",
                    },
                },
                "loggers": {
                    "sygnal": {
                        "handlers": ["stderr"],
                        "propagate": False
                    },
                    "sygnal.access": {
                        "handlers": ["stderr"],
                        "level": "INFO",
                        "propagate": False,
                    },
                },
                "root": {
                    "handlers": ["stderr"],
                    "level": "DEBUG"
                },
                "version": 1,
            }
        }

        config = {"apps": {}, "log": logging_config}

        self.config_setup(config)

        config = merge_left_with_defaults(CONFIG_DEFAULTS, config)
        if USE_POSTGRES:
            self._set_up_database(self.dbname)

        self.sygnal = Sygnal(config, reactor)
        self.reactor = reactor
        self.sygnal.database.start()
        self.v1api = PushGatewayApiServer(self.sygnal)

        start_deferred = ensureDeferred(
            self.sygnal._make_pushkins_then_start(0, [], None))

        while not start_deferred.called:
            # we need to advance until the pushkins have started up
            self.sygnal.reactor.advance(1)
            self.sygnal.reactor.wait_for_work(lambda: start_deferred.called)
Exemplo n.º 2
0
    def setUp(self):
        reactor = ExtendedMemoryReactorClock()

        logging_config = {
            "setup": {
                "disable_existing_loggers": False,  # otherwise this breaks logging!
                "formatters": {
                    "normal": {
                        "format": "%(asctime)s [%(process)d] "
                        "%(levelname)-5s %(name)s %(message)s"
                    }
                },
                "handlers": {
                    "stderr": {
                        "class": "logging.StreamHandler",
                        "formatter": "normal",
                        "stream": "ext://sys.stderr",
                    },
                },
                "loggers": {
                    "sygnal": {"handlers": ["stderr"], "propagate": False},
                    "sygnal.access": {
                        "handlers": ["stderr"],
                        "level": "INFO",
                        "propagate": False,
                    },
                },
                "root": {"handlers": ["stderr"], "level": "DEBUG"},
                "version": 1,
            }
        }

        config = {"apps": {}, "log": logging_config}

        self.config_setup(config)

        config = merge_left_with_defaults(CONFIG_DEFAULTS, config)

        self.sygnal = Sygnal(config, reactor)
        self.reactor = reactor

        start_deferred = ensureDeferred(self.sygnal.make_pushkins_then_start())

        while not start_deferred.called:
            # we need to advance until the pushkins have started up
            self.sygnal.reactor.advance(1)
            self.sygnal.reactor.wait_for_work(lambda: start_deferred.called)

        # sygnal should have started a single (fake) tcp listener
        listeners = self.reactor.tcpServers
        self.assertEqual(len(listeners), 1)
        (port, site, _backlog, interface) = listeners[0]
        self.site = site
Exemplo n.º 3
0
    def setUp(self):
        reactor = ExtendedMemoryReactorClock()

        config = {"apps": {}, "db": {}, "log": {"setup": {"version": 1}}}
        config = merge_left_with_defaults(CONFIG_DEFAULTS, config)

        self.config_setup(config)

        self.sygnal = Sygnal(config, reactor)
        self.sygnal.database.start()
        self.v1api = PushGatewayApiServer(self.sygnal)

        start_deferred = ensureDeferred(
            self.sygnal._make_pushkins_then_start(0, [], None))

        while not start_deferred.called:
            # we need to advance until the pushkins have started up
            self.sygnal.reactor.advance(1)
            self.sygnal.reactor.wait_for_work(lambda: start_deferred.called)