<commit_before>import contextlib
import logging

from ..orchestra import run

log = logging.getLogger(__name__)

@contextlib.contextmanager
def task(ctx, config):
    """
    Run test_stress_watch

    The config should be as follows:

    test_stress_watch:
        clients: [client list]

    example:

    tasks:
    - ceph:
    - test_stress_watch:
        clients: [client.0]
    - interactive:
    """
    log.info('Beginning test_stress_watch...')
    assert isinstance(config, dict), \
        "please list clients to run on"
    testsnaps = {}

    (mon,) = ctx.cluster.only('mon.0').remotes.iterkeys()
    remotes = []
    for role in config.get('clients', ['client.0']):
        assert isinstance(role, basestring)
        PREFIX = 'client.'
        assert role.startswith(PREFIX)
        id_ = role[len(PREFIX):]
        (remote,) = ctx.cluster.only(role).remotes.iterkeys()
        remotes.append(remote)

        remote.run(
            args=[
                'cp',
                '/tmp/cephtest/ceph.conf',
                '/tmp/cephtest/data/ceph.conf',
                ],
            logger=log.getChild('test_stress_watch.{id}'.format(id=id_)),
            wait=True,
            )

        proc = remote.run(
            args=[
                '/bin/sh', '-c',
                " ".join([
                    'cd', '/tmp/cephtest/data;',
                    'export CEPH_CLIENT_ID={id_}; export CEPH_CONF=ceph.conf; LD_PRELOAD=/tmp/cephtest/binary/usr/local/lib/librados.so.2 /tmp/cephtest/binary/usr/local/bin/test_stress_watch'.format(
                        id_=id_),
                    ])
                ],
            logger=log.getChild('testsnaps.{id}'.format(id=id_)),
            stdin=run.PIPE,
            wait=False
            )
        testsnaps[id_] = proc

    try:
        yield
    finally:
        for i in remotes:
            i.run(
                args=[
                    'rm',
                    '/tmp/cephtest/data/ceph.conf'<commit_msg>watch_notify_stress.py: add ceph flags option<commit_after>import contextlib
import logging

from ..orchestra import run

log = logging.getLogger(__name__)

@contextlib.contextmanager
def task(ctx, config):
    """
    Run test_stress_watch

    The config should be as follows:

    test_stress_watch:
        clients: [client list]

    example:

    tasks:
    - ceph:
    - test_stress_watch:
        clients: [client.0]
    - interactive:
    """
    log.info('Beginning test_stress_watch...')
    assert isinstance(config, dict), \
        "please list clients to run on"
    testsnaps = {}

    (mon,) = ctx.cluster.only('mon.0').remotes.iterkeys()
    remotes = []
    for role in config.get('clients', ['client.0']):
        assert isinstance(role, basestring)
        PREFIX = 'client.'
        assert role.startswith(PREFIX)
        id_ = role[len(PREFIX):]
        (remote,) = ctx.cluster.only(role).remotes.iterkeys()
        remotes.append(remote)

        remote.run(
            args=[
                'cp',
                '/tmp/cephtest/ceph.conf',
                '/tmp/cephtest/data/ceph.conf',
                ],
            logger=log.getChild('test_stress_watch.{id}'.format(id=id_)),
            wait=True,
            )

        args =[ '/bin/sh', '-c',
                " ".join([
                    'cd', '/tmp/cephtest/data;',
                    'export CEPH_CLIENT_ID={id_}; export CEPH_CONF=ceph.conf; export CEPH_ARGS="{flags}"; LD_PRELOAD=/tmp/cephtest/binary/usr/local/lib/librados.so.2 /tmp/cephtest/binary/usr/local/bin/test_stress_watch {flags}'.format(
                        id_=id_,
                        flags=config.get('flags', ''),
                        )
                    ])
                ]

        log.info("args are %s" % (args,))

        proc = remote.run(
            args=args,
            logger=log.getChild('testsnaps.{id}'.format(id=id_)),
            stdin=run.PIPE,
            wait=False
            )
        testsnaps[id_] = proc

    try:
        yield
    finally:
        for i in remotes:
            i.run(
                args=[
                    'rm',
                    '/tmp/cephtest/data/ceph.conf'
{'fraction_non_alphanumeric': 0.1326457183976973, 'fraction_numerical': 0.001918925401775006, 'mean_word_length': 1.5948973242065962, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2963609', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1269, 'n_words': 218}