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)
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)
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))
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)
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)
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)
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)
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))
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)
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))
# 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:
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))
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,
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