Пример #1
0
def rabbit_config(request, rabbit_manager):
    from kombu import pools
    from nameko.testing.utils import (
        reset_rabbit_vhost,
        reset_rabbit_connections,
        get_rabbit_connections,
        get_rabbit_config,
    )

    amqp_uri = request.config.getoption("AMQP_URI")

    conf = get_rabbit_config(amqp_uri)

    reset_rabbit_connections(conf["vhost"], rabbit_manager)
    reset_rabbit_vhost(conf["vhost"], conf["username"], rabbit_manager)

    yield conf

    pools.reset()  # close connections in pools

    # raise a runtime error if the test leaves any connections lying around
    connections = get_rabbit_connections(conf["vhost"], rabbit_manager)
    open_connections = [conn for conn in connections if conn["state"] != "closed"]
    if open_connections:
        count = len(open_connections)
        raise RuntimeError("{} rabbit connection(s) left open.".format(count))
Пример #2
0
def rabbit_config(request, rabbit_manager):
    from kombu import pools
    from nameko.testing.utils import (reset_rabbit_vhost,
                                      reset_rabbit_connections,
                                      get_rabbit_connections,
                                      get_rabbit_config)

    amqp_uri = request.config.getoption('AMQP_URI')

    conf = get_rabbit_config(amqp_uri)

    reset_rabbit_connections(conf['vhost'], rabbit_manager)
    reset_rabbit_vhost(conf['vhost'], conf['username'], rabbit_manager)

    yield conf

    pools.reset()  # close connections in pools

    # raise a runtime error if the test leaves any connections lying around
    connections = get_rabbit_connections(conf['vhost'], rabbit_manager)
    open_connections = [
        conn for conn in connections if conn['state'] != "closed"
    ]
    if open_connections:
        count = len(open_connections)
        raise RuntimeError("{} rabbit connection(s) left open.".format(count))
Пример #3
0
def rabbit_config(request, rabbit_manager):
    amqp_uri = request.config.getoption('AMQP_URI')

    conf = get_rabbit_config(amqp_uri)

    reset_rabbit_connections(conf['vhost'], rabbit_manager)
    reset_rabbit_vhost(conf['vhost'], conf['username'], rabbit_manager)

    yield conf

    pools.reset()  # close connections in pools

    # raise a runtime error if the test leaves any connections lying around
    connections = get_rabbit_connections(conf['vhost'], rabbit_manager)
    if connections:
        count = len(connections)
        raise RuntimeError("{} rabbit connection(s) left open.".format(count))
Пример #4
0
def rabbit_config(request, rabbit_manager):
    amqp_uri = request.config.getoption('AMQP_URI')

    conf = get_rabbit_config(amqp_uri)

    reset_rabbit_connections(conf['vhost'], rabbit_manager)
    reset_rabbit_vhost(conf['vhost'], conf['username'], rabbit_manager)

    yield conf

    pools.reset()  # close connections in pools

    # raise a runtime error if the test leaves any connections lying around
    connections = get_rabbit_connections(conf['vhost'], rabbit_manager)
    if connections:
        count = len(connections)
        raise RuntimeError("{} rabbit connection(s) left open.".format(count))