<commit_before>import contextlib
import logging

from ..orchestra import run
from teuthology import misc as teuthology
import teuthology.task_util.rgw as rgw_utils

log = logging.getLogger(__name__)

def run_radosgw_agent(ctx, client, config):
    """
    Run a single radosgw-agent. See task() for config format.
    """
    src_client = config['src']
    dest_client = config['dest']

    src_zone = rgw_utils.zone_for_client(ctx, src_client)
    dest_zone = rgw_utils.zone_for_client(ctx, dest_client)

    log.info("source is %s", src_zone)
    log.info("dest is %s", dest_zone)

    testdir = teuthology.get_testdir(ctx)
    (remote,) = ctx.cluster.only(client).remotes.keys()
    remote.run(
        args=[
            'cd', testdir, run.Raw('&&'),
            'git', 'clone', 'https://github.com/ceph/radosgw-agent.git',
            'radosgw-agent.{client}'.format(client=client),
            run.Raw('&&'),
            'cd', 'radosgw-agent.{client}'.format(client=client),
            run.Raw('&&'),
            './bootstrap',
            ]
        )

    src_host, src_port = rgw_utils.get_zone_host_and_port(ctx, src_client,
                                                          src_zone)
    dest_host, dest_port = rgw_utils.get_zone_host_and_port(ctx, dest_client,
                                                            dest_zone)
    src_access, src_secret = rgw_utils.get_zone_system_keys(ctx, src_client,
                                                            src_zone)
    dest_access, dest_secret = rgw_utils.get_zone_system_keys(ctx, dest_client,
                                                              dest_zone)
    port = config.get('port', 8000)
    daemon_name = '{host}.syncdaemon'.format(host=remote.name)

    return remote.run(
        args=[
            '{tdir}/daemon-helper'.format(tdir=testdir), 'kill',
            '{tdir}/radosgw-agent.{client}/radosgw-agent'.format(tdir=testdir,
                                                                 client=client),
            '--src-access-key', src_access,
            '--src-secret-key', src_secret,
            '--src-host', src_host,
            '--src-port', str(src_port),
            '--src-zone', src_zone,
            '--dest-access-key', dest_access,
            '--dest-secret-key', dest_secret,
            '--dest-host', dest_host,
            '--dest-port', str(dest_port),
            '--dest-zone', dest_zone,
            '--daemon-id', daemon_name,
            '--test-server-host', '0.0.0.0', '--test-server-port', str(port),
            '--log-file', '{tdir}/archive/rgw_sync_agent.{client}.log'.format(
                tdir=testdir,
                client=client),
            ],
        wait=False,
        stdin=run.PIPE,
        logger=log.getChild(daemon_name)
        )


@contextlib.contextmanager
def task(ctx, config):<commit_msg>radosgw-agent: get verbose logs from the agent<commit_after>import contextlib
import logging

from ..orchestra import run
from teuthology import misc as teuthology
import teuthology.task_util.rgw as rgw_utils

log = logging.getLogger(__name__)

def run_radosgw_agent(ctx, client, config):
    """
    Run a single radosgw-agent. See task() for config format.
    """
    src_client = config['src']
    dest_client = config['dest']

    src_zone = rgw_utils.zone_for_client(ctx, src_client)
    dest_zone = rgw_utils.zone_for_client(ctx, dest_client)

    log.info("source is %s", src_zone)
    log.info("dest is %s", dest_zone)

    testdir = teuthology.get_testdir(ctx)
    (remote,) = ctx.cluster.only(client).remotes.keys()
    remote.run(
        args=[
            'cd', testdir, run.Raw('&&'),
            'git', 'clone', 'https://github.com/ceph/radosgw-agent.git',
            'radosgw-agent.{client}'.format(client=client),
            run.Raw('&&'),
            'cd', 'radosgw-agent.{client}'.format(client=client),
            run.Raw('&&'),
            './bootstrap',
            ]
        )

    src_host, src_port = rgw_utils.get_zone_host_and_port(ctx, src_client,
                                                          src_zone)
    dest_host, dest_port = rgw_utils.get_zone_host_and_port(ctx, dest_client,
                                                            dest_zone)
    src_access, src_secret = rgw_utils.get_zone_system_keys(ctx, src_client,
                                                            src_zone)
    dest_access, dest_secret = rgw_utils.get_zone_system_keys(ctx, dest_client,
                                                              dest_zone)
    port = config.get('port', 8000)
    daemon_name = '{host}.syncdaemon'.format(host=remote.name)

    return remote.run(
        args=[
            '{tdir}/daemon-helper'.format(tdir=testdir), 'kill',
            '{tdir}/radosgw-agent.{client}/radosgw-agent'.format(tdir=testdir,
                                                                 client=client),
            '-v',
            '--src-access-key', src_access,
            '--src-secret-key', src_secret,
            '--src-host', src_host,
            '--src-port', str(src_port),
            '--src-zone', src_zone,
            '--dest-access-key', dest_access,
            '--dest-secret-key', dest_secret,
            '--dest-host', dest_host,
            '--dest-port', str(dest_port),
            '--dest-zone', dest_zone,
            '--daemon-id', daemon_name,
            '--test-server-host', '0.0.0.0', '--test-server-port', str(port),
            '--log-file', '{tdir}/archive/rgw_sync_agent.{client}.log'.format(
                tdir=testdir,
                client=client),
            ],
        wait=False,
        stdin=run.PIPE,
        logger=log.getChild(daemon_name)
        )


@contextlib.contextmanager
def task(ctx, config):
{'fraction_non_alphanumeric': 0.1358987692841047, 'fraction_numerical': 0.0027734442711041776, 'mean_word_length': 1.75549188156638, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5428478', 'n_tokens_mistral': 1801, 'n_tokens_neox': 1765, 'n_words': 282}