コード例 #1
0
def runTest(port):
    url = getDefaultHealthCheckUrl(None, port)
    role = getDefaultRoleForApp('health')
    secret = getDefaultSecretForApp('health')
    channel = makeUniqueString()

    for i in range(5):
        healthCheck(url, role, secret, channel)
コード例 #2
0
def test_health_check(runner):
    '''Starts a server, then run a health check'''
    port = runner.port

    url = getDefaultHealthCheckUrl(None, port)
    role = getDefaultRoleForApp('health')
    secret = getDefaultSecretForApp('health')
    channel = makeUniqueString()

    healthCheck(url, role, secret, channel, retry=False, httpCheck=False)
コード例 #3
0
ファイル: test_pubsub.py プロジェクト: tiwariashish86/cobra
def test_publish(runner):
    port = runner.port

    url = getDefaultHealthCheckUrl(None, port)
    role = getDefaultRoleForApp('health')
    secret = getDefaultSecretForApp('health')

    creds = createCredentials(role, secret)
    connection = Connection(url, creds)

    asyncio.get_event_loop().run_until_complete(clientCoroutine(connection))
コード例 #4
0
def test_health_check_with_no_redis(redisDownRunner):
    '''Starts a server, then run a health check'''
    port = redisDownRunner.port

    url = getDefaultHealthCheckUrl(None, port)
    role = getDefaultRoleForApp('health')
    secret = getDefaultSecretForApp('health')
    channel = makeUniqueString()

    with pytest.raises(ActionException):
        healthCheck(url, role, secret, channel)
コード例 #5
0
def test_server_again(debugMemoryRunner):
    '''This make sure that we cleanup our server properly,
    and to run the debugMemory code
    '''
    port = debugMemoryRunner.port

    url = getDefaultHealthCheckUrl(None, port)
    role = getDefaultRoleForApp('health')
    secret = getDefaultSecretForApp('health')
    channel = makeUniqueString()

    healthCheck(url, role, secret, channel)
コード例 #6
0
def test_server(runner):
    '''Starts a server, then run a health check'''
    port = runner.port

    url = getDefaultHealthCheckUrl(None, port)
    role = getDefaultRoleForApp('health')
    secret = getDefaultSecretForApp('health')
    channel = makeUniqueString()

    # Run 2 health-checks in a row
    healthCheck(url, role, secret, channel)
    healthCheck(url, role, secret, channel)
コード例 #7
0
def test_monitor(runner):
    '''Starts a server, then run a health check'''
    port = runner.port

    url = getDefaultMonitorUrl(None, port)
    role = getDefaultRoleForApp('stats')
    secret = getDefaultSecretForApp('stats')

    creds = createCredentials(role, secret)
    connection = Connection(url, creds)

    asyncio.get_event_loop().run_until_complete(clientCoroutine(connection))
    monitor(connection)
コード例 #8
0
ファイル: test_admin.py プロジェクト: tiwariashish86/cobra
def test_admin_disconnect_one(runner):
    '''Starts a server, then run a health check'''
    port = runner.port

    url = getDefaultHealthCheckUrl(None, port)
    role = getDefaultRoleForApp('health')
    secret = getDefaultSecretForApp('health')

    creds = createCredentials(role, secret)
    connection = Connection(url, creds)
    connectionToBeClosed = Connection(url, creds)

    asyncio.get_event_loop().run_until_complete(
        clientCoroutine(connection, connectionToBeClosed))
コード例 #9
0
def test_monitor_redis_down(redisDownRunner):
    '''Starts a server, then run a health check'''
    port = redisDownRunner.port

    url = getDefaultMonitorUrl(None, port)
    role = getDefaultRoleForApp('stats')
    secret = getDefaultSecretForApp('stats')

    creds = createCredentials(role, secret)
    connection = Connection(url, creds)

    # FIXME: bring this back
    asyncio.get_event_loop().run_until_complete(
        clientCoroutineRedisDown(connection))

    with pytest.raises(ActionException):
        monitor(connection)
コード例 #10
0
def test_save_position(runner):
    '''Starts a server, then run a health check'''
    port = runner.port

    url = getDefaultHealthCheckUrl(None, port)
    role = getDefaultRoleForApp('health')
    secret = getDefaultSecretForApp('health')

    creds = createCredentials(role, secret)
    connection = Connection(url, creds)
    _ = Connection(url, creds)

    uniqueId = uuid.uuid4().hex[:8]
    channel = 'test_save_position_channel::' + uniqueId
    resumeFromLastPositionId = 'last_position_id::' + uniqueId

    asyncio.get_event_loop().run_until_complete(
        clientCoroutine(connection, channel, url, creds,
                        resumeFromLastPositionId))
コード例 #11
0
# from cobras.client.kv_store import readClient
from cobras.client.connection import ActionException, Connection
from cobras.client.credentials import (
    createCredentials,
    getDefaultRoleForApp,
    getDefaultSecretForApp,
)
from cobras.common.apps_config import PUBSUB_APPKEY, getDefaultEndpoint, makeUrl


@click.command()
@click.option('--endpoint', default=getDefaultEndpoint())
@click.option('--appkey', default=PUBSUB_APPKEY)
@click.option('--rolename', default=getDefaultRoleForApp('pubsub'))
@click.option('--rolesecret', default=getDefaultSecretForApp('pubsub'))
@click.option('--channel', default='sms_republished_v1_neo_kv_store')
@click.option('--position')
def read(endpoint, appkey, rolename, rolesecret, channel, position):
    '''Read from the cobra key value store
    '''
    url = makeUrl(endpoint, appkey)
    credentials = createCredentials(rolename, rolesecret)

    async def handler(url, credentials, channel, position):
        connection = Connection(url, credentials)
        await connection.connect()

        try:
            data = await connection.read(channel, position)
        except ActionException as e:
コード例 #12
0
ファイル: admin.py プロジェクト: tiwariashish86/cobra
        return

    if action == 'get_connections':
        openedConnections = await connection.adminGetConnections()
        print(f'#{len(openedConnections)} connection(s)')
        for connection in openedConnections:
            print(f'\t{connection}')

    elif action == 'disconnect':
        await connection.adminCloseConnection(connectionId)


@click.option('--endpoint', default=getDefaultEndpoint())
@click.option('--appkey', default=ADMIN_APPKEY)
@click.option('--rolename', default=getDefaultRoleForApp('admin'))
@click.option('--rolesecret', default=getDefaultSecretForApp('admin'))
@click.option('--action', default='get_connections')
@click.option('--connection_id')
@click.command()
def admin(endpoint, appkey, rolename, rolesecret, action, connection_id):
    '''Execute admin operations on the server

    \b
    cobra admin --action disconnect --connection_id 3919dc67
    '''

    url = makeUrl(endpoint, appkey)
    credentials = createCredentials(rolename, rolesecret)

    asyncio.get_event_loop().run_until_complete(
        adminCoroutine(url, credentials, action, connection_id))
コード例 #13
0
import click
from cobras.client.credentials import (
    createCredentials,
    getDefaultRoleForApp,
    getDefaultSecretForApp,
)
from cobras.client.monitor import runMonitor
from cobras.common.apps_config import STATS_APPKEY, getDefaultEndpoint, makeUrl


@click.command()
@click.option('--endpoint', default=getDefaultEndpoint())
@click.option('--appkey', default=STATS_APPKEY)
@click.option('--rolename', default=getDefaultRoleForApp('stats'))
@click.option('--rolesecret', default=getDefaultSecretForApp('stats'))
@click.option('--raw', is_flag=True)
@click.option('--hide_nodes', is_flag=True)
@click.option('--hide_roles', is_flag=True)
@click.option('--hide_channels', is_flag=True)
@click.option('--hide_summary', is_flag=True)
@click.option('--subscribers', is_flag=True)
@click.option('--role_filter')
@click.option('--channel_filter')
@click.option('--metric_filter')
@click.option('--system', is_flag=True)
@click.option('--once', is_flag=True)
@click.option('--tidy', is_flag=True)
@click.option('--unsafe', is_flag=True)
def monitor(
    endpoint,
コード例 #14
0
ファイル: health.py プロジェクト: tiwariashish86/cobra
from cobras.client.health_check import (
    getDefaultHealthCheckChannel,
    getDefaultHealthCheckHttpUrl,
    healthCheck,
)
from cobras.common.apps_config import HEALTH_APPKEY, getDefaultEndpoint, makeUrl


@click.command()
@click.option('--endpoint', default=getDefaultEndpoint())
@click.option('--appkey', default=HEALTH_APPKEY)
@click.option('--http_url', default=getDefaultHealthCheckHttpUrl)
@click.option('--http', is_flag=True)
@click.option('--http_extra_check', is_flag=True)
@click.option('--rolename', default=getDefaultRoleForApp('health'))
@click.option('--rolesecret', default=getDefaultSecretForApp('health'))
@click.option('--channel', default=getDefaultHealthCheckChannel())
@click.option('--retry', is_flag=True)
def health(
    endpoint,
    appkey,
    http_url,
    http,
    http_extra_check,
    rolename,
    rolesecret,
    channel,
    retry,
):
    '''Health check