Exemplo n.º 1
0
def test_client_event(event_loop):
    transport, protocol, port = yield from fake_server(event_loop)
    client = aiomeasures.StatsD('udp://127.0.0.1:%s' % port)
    asyncio.sleep(.4)
    client.event('title', 'text')
    yield from asyncio.sleep(.1)
    assert '_e{5,4}title|text' in protocol.msg
    transport.close()
    client.close()
Exemplo n.º 2
0
def test_reliablility(event_loop):
    transport, protocol, port = yield from fake_server(event_loop)
    client = aiomeasures.StatsD('udp://127.0.0.1:%s' % port)
    asyncio.sleep(.4)
    client.incr('example.a')
    yield from asyncio.sleep(.1)
    assert 'example.a:1|c' in protocol.msg
    transport.close()

    client.incr('example.b')
    yield from asyncio.sleep(.1)
    assert 'example.b:1|c' not in protocol.msg

    transport, protocol, port = yield from fake_server(event_loop, port)
    client.incr('example.c')
    yield from asyncio.sleep(.1)
    assert 'example.c:1|c' in protocol.msg
    transport.close()

    client.close()
Exemplo n.º 3
0
def test_client(event_loop):
    transport, protocol, port = yield from fake_server(event_loop)
    client = aiomeasures.StatsD('udp://127.0.0.1:%s' % port)
    asyncio.sleep(.4)
    client.incr('example.a')
    client.timing('example.b', 500)
    client.gauge('example.c', 1)
    client.set('example.d', 'bar')
    client.decr('example.e')
    client.counter('example.f', 42)
    client.histogram('example.g', 13)
    yield from asyncio.sleep(.1)
    assert 'example.a:1|c' in protocol.msg
    assert 'example.b:500|ms' in protocol.msg
    assert 'example.c:1|g' in protocol.msg
    assert 'example.d:bar|s' in protocol.msg
    assert 'example.e:-1|c' in protocol.msg
    assert 'example.f:42|c' in protocol.msg
    assert 'example.g:13|h' in protocol.msg
    transport.close()
    client.close()
Exemplo n.º 4
0
from .protocol import Protocol, QDataStreamProtocol
from .servercontext import ServerContext
from .player_service import PlayerService
from .game_service import GameService
from .ladder_service import LadderService
from .control import init as run_control_server

__version__ = '0.5.3'
__author__ = 'Chris Kitching, Dragonfire, Gael Honorez, Jeroen De Dauw, Crotalus, Michael Søndergaard, Michel Jung'
__contact__ = '*****@*****.**'
__license__ = 'GPLv3'
__copyright__ = 'Copyright (c) 2011-2015 ' + __author__

__all__ = ['run_lobby_server', 'games', 'control', 'abc', 'protocol']

stats = aiomeasures.StatsD(config.STATSD_SERVER)


def run_lobby_server(address: (str, int), player_service: PlayerService,
                     games: GameService, loop):
    """
    Run the lobby server

    :param address: Address to listen on
    :param player_service: Service to talk to about players
    :param games: Service to talk to about games
    :param loop: Event loop to use
    :return ServerContext: A server object
    """
    def encode_game(game):
        # Crazy evil encoding scheme
Exemplo n.º 5
0
def test_events():
    event = aiomeasures.Event('Man down!', 'This server needs assistance.')
    handler = aiomeasures.StatsD(':0')
    assert handler.format(
        event) == '_e{9,29}Man down!|This server needs assistance.'
Exemplo n.º 6
0
def test_tags(tags, defaults, expected):
    metric = aiomeasures.CountingMetric('foo', 1, tags=tags)
    handler = aiomeasures.StatsD(':0', tags=defaults)
    assert handler.format(metric) == 'foo:1|c%s' % expected
Exemplo n.º 7
0
def test_formatting(metric, expected):
    handler = aiomeasures.StatsD(':0')
    assert handler.format(metric) == expected
Exemplo n.º 8
0
def test_checks(check, expected):
    handler = aiomeasures.StatsD(':0')
    assert handler.format(check) == expected