def test_gunicorn_application_init_statsd(monkeypatch): monkeypatch.setattr(sys, 'argv', ['talisker', 'wsgi:app']) statsd_config = {'hostport': '1.2.3.4:2000', 'prefix': 'test'} monkeypatch.setattr(statsd, 'get_config', lambda: statsd_config) app = gunicorn.TaliskerApplication('') assert app.cfg.statsd_host == ('1.2.3.4', 2000) assert app.cfg.statsd_prefix == 'test'
def test_gunicorn_application_load(monkeypatch): monkeypatch.setattr(sys, 'argv', ['', __name__ + ':wsgi', '--bind=0.0.0.0:0']) app = gunicorn.TaliskerApplication('') wsgiapp = app.load_wsgiapp() assert wsgiapp._talisker_wrapped assert wsgiapp._talisker_original_app == wsgi
def test_gunicorn_application_warn_errorlog(monkeypatch, log): monkeypatch.setattr(sys, 'argv', ['talisker', 'wsgi:app', '--log-file', '/tmp/log']) gunicorn.TaliskerApplication('') record = log[0] assert 'ignoring gunicorn errorlog' in record.msg assert record._structured['errorlog'] == '/tmp/log'
def test_gunicorn_application_config_loglevel_debug_devel(monkeypatch, log): monkeypatch.setattr( sys, 'argv', ['talisker', 'wsgi:app', '--log-level', 'debug']) app = gunicorn.TaliskerApplication('', devel=True) assert app.cfg.loglevel.lower() == 'debug' assert logs.get_talisker_handler().level == logging.DEBUG
def test_gunicorn_application_warn_statsd(monkeypatch, log): monkeypatch.setattr( sys, 'argv', ['talisker', 'wsgi:app', '--statsd-host', 'localhost:8125']) gunicorn.TaliskerApplication('') record = log[0] assert 'ignoring gunicorn statsd' in record.msg assert record._structured['statsd_host'] == 'localhost:8125'
def test_gunicorn_application_init(monkeypatch): monkeypatch.setattr(sys, 'argv', ['talisker', 'wsgi:app']) app = gunicorn.TaliskerApplication('') assert app.cfg.logger_class == gunicorn.GunicornLogger assert app.cfg.loglevel.lower() == 'info' assert app.cfg.pre_request is gunicorn.gunicorn_pre_request assert app.cfg.on_starting is gunicorn.gunicorn_on_starting assert app.cfg.child_exit is gunicorn.gunicorn_child_exit assert logs.get_talisker_handler().level == logging.NOTSET
def test_gunicorn_application_config_errorlog(monkeypatch, context): monkeypatch.setattr(sys, 'argv', ['talisker', 'wsgi:app', '--log-file', '/tmp/log']) app = gunicorn.TaliskerApplication('') assert context.logs.exists( msg='ignoring gunicorn errorlog', extra={'errorlog': '/tmp/log'}, ) assert app.cfg.errorlog == '-'
def test_gunicorn_application_config_logger_class(monkeypatch, log): monkeypatch.setattr( sys, 'argv', ['talisker', 'wsgi:app', '--logger-class', 'gunicorn.glogging.Logger']) from gunicorn.glogging import Logger app = gunicorn.TaliskerApplication('') record = log[0] assert 'using custom gunicorn logger class' in record.msg assert record._structured['logger_class'] is Logger assert app.cfg.logger_class is Logger
def test_gunicorn_application_config_statsd(monkeypatch, log): monkeypatch.setattr( sys, 'argv', ['talisker', 'wsgi:app', '--statsd-host', 'localhost:8125']) app = gunicorn.TaliskerApplication('') record = log[0] assert 'ignoring gunicorn statsd' in record.msg assert record._structured['statsd_host'] == ('localhost', 8125) assert app.cfg.statsd_host is None assert app.cfg.statsd_prefix is None
def test_gunicorn_application_config_logger_class(monkeypatch, context): monkeypatch.setattr( sys, 'argv', ['talisker', 'wsgi:app', '--logger-class', 'gunicorn.glogging.Logger']) from gunicorn.glogging import Logger app = gunicorn.TaliskerApplication('') assert context.logs.exists( msg='using custom gunicorn logger class', extra={'logger_class': Logger}, ) assert app.cfg.logger_class is Logger
def test_gunicorn_application_config_statsd(monkeypatch, context): monkeypatch.setattr( sys, 'argv', ['talisker', 'wsgi:app', '--statsd-host', 'localhost:8125']) app = gunicorn.TaliskerApplication('') assert context.logs.exists( msg='ignoring gunicorn statsd', extra={'statsd_host': ('localhost', 8125)}, ) assert app.cfg.statsd_host is None assert app.cfg.statsd_prefix is None
def test_gunicorn_application_init_devel_overriden(monkeypatch): monkeypatch.setattr(sys, 'argv', ['talisker', 'wsgi:app', '--timeout', '10']) app = gunicorn.TaliskerApplication('', devel=True) assert app.cfg.timeout == 10
def test_gunicorn_application_init_devel(monkeypatch): monkeypatch.setattr(sys, 'argv', ['talisker', 'wsgi:app']) app = gunicorn.TaliskerApplication('', devel=True) assert app.cfg.accesslog == '-' assert app.cfg.timeout == 99999 assert app.cfg.reload
def test_gunicorn_application_init(monkeypatch): monkeypatch.setattr(sys, 'argv', ['talisker', 'wsgi:app']) app = gunicorn.TaliskerApplication('') assert app.cfg.access_log_format == gunicorn.access_log_format assert app.cfg.logger_class == gunicorn.GunicornLogger
def test_gunicorn_application_init(monkeypatch): monkeypatch.setattr(sys, 'argv', ['talisker', 'wsgi:app']) app = gunicorn.TaliskerApplication('') assert app.cfg.logger_class == gunicorn.GunicornLogger assert app.cfg.loglevel == 'DEBUG'