示例#1
0
def configure(ctx, config):
    """
    Configure the s3-tests.  This includes the running of the
    bootstrap code and the updating of local conf files.
    """
    assert isinstance(config, dict)
    log.info('Configuring s3-roundtrip-tests...')
    testdir = teuthology.get_testdir(ctx)
    for client, properties in config['clients'].iteritems():
        s3tests_conf = config['s3tests_conf'][client]
        if properties is not None and 'rgw_server' in properties:
            host = None
            for target, roles in zip(ctx.config['targets'].keys(),
                                     ctx.config['roles']):
                log.info('roles: ' + str(roles))
                log.info('target: ' + str(target))
                if properties['rgw_server'] in roles:
                    _, host = split_user(target)
            assert host is not None, "Invalid client specified as the rgw_server"
            s3tests_conf['s3']['host'] = host
        else:
            s3tests_conf['s3']['host'] = 'localhost'

        def_conf = s3tests_conf['DEFAULT']
        s3tests_conf['s3'].setdefault('port', def_conf['port'])
        s3tests_conf['s3'].setdefault('is_secure', def_conf['is_secure'])

        (remote, ) = ctx.cluster.only(client).remotes.keys()
        remote.run(args=[
            'cd',
            '{tdir}/s3-tests'.format(tdir=testdir),
            run.Raw('&&'),
            './bootstrap',
        ], )
        conf_fp = StringIO()
        conf = dict(
            s3=s3tests_conf['s3'],
            roundtrip=s3tests_conf['roundtrip'],
        )
        yaml.safe_dump(conf, conf_fp, default_flow_style=False)
        teuthology.write_file(
            remote=remote,
            path='{tdir}/archive/s3roundtrip.{client}.config.yaml'.format(
                tdir=testdir, client=client),
            data=conf_fp.getvalue(),
        )
    yield
def configure(ctx, config):
    """
    Configure the s3-tests.  This includes the running of the
    bootstrap code and the updating of local conf files.
    """
    assert isinstance(config, dict)
    log.info('Configuring s3-roundtrip-tests...')
    testdir = teuthology.get_testdir(ctx)
    for client, properties in config['clients'].iteritems():
        s3tests_conf = config['s3tests_conf'][client]
        if properties is not None and 'rgw_server' in properties:
            host = None
            for target, roles in zip(ctx.config['targets'].iterkeys(), ctx.config['roles']):
                log.info('roles: ' + str(roles))
                log.info('target: ' + str(target))
                if properties['rgw_server'] in roles:
                    _, host = split_user(target)
            assert host is not None, "Invalid client specified as the rgw_server"
            s3tests_conf['s3']['host'] = host
        else:
            s3tests_conf['s3']['host'] = 'localhost'

        def_conf = s3tests_conf['DEFAULT']
        s3tests_conf['s3'].setdefault('port', def_conf['port'])
        s3tests_conf['s3'].setdefault('is_secure', def_conf['is_secure'])

        (remote,) = ctx.cluster.only(client).remotes.keys()
        remote.run(
            args=[
                'cd',
                '{tdir}/s3-tests'.format(tdir=testdir),
                run.Raw('&&'),
                './bootstrap',
                ],
            )
        conf_fp = StringIO()
        conf = dict(
                        s3=s3tests_conf['s3'],
                        roundtrip=s3tests_conf['roundtrip'],
                    )
        yaml.safe_dump(conf, conf_fp, default_flow_style=False)
        teuthology.write_file(
            remote=remote,
            path='{tdir}/archive/s3roundtrip.{client}.config.yaml'.format(tdir=testdir, client=client),
            data=conf_fp.getvalue(),
            )
    yield
示例#3
0
def configure(ctx, config):
    """
    Configure rgw and Swift
    """
    assert isinstance(config, dict)
    log.info('Configuring testswift...')
    testdir = teuthology.get_testdir(ctx)
    for client, properties in config['clients'].iteritems():
        log.info('client={c}'.format(c=client))
        log.info('config={c}'.format(c=config))
        testswift_conf = config['testswift_conf'][client]
        if properties is not None and 'rgw_server' in properties:
            host = None
            for target, roles in zip(ctx.config['targets'].iterkeys(), ctx.config['roles']):
                log.info('roles: ' + str(roles))
                log.info('target: ' + str(target))
                if properties['rgw_server'] in roles:
                    _, host = split_user(target)
            assert host is not None, "Invalid client specified as the rgw_server"
            testswift_conf['func_test']['auth_host'] = host
        else:
            testswift_conf['func_test']['auth_host'] = 'localhost'

        log.info(client)
        (remote,) = ctx.cluster.only(client).remotes.keys()
        remote.run(
            args=[
                'cd',
                '{tdir}/swift'.format(tdir=testdir),
                run.Raw('&&'),
                './bootstrap',
                ],
            )
        conf_fp = StringIO()
        testswift_conf.write(conf_fp)
        teuthology.write_file(
            remote=remote,
            path='{tdir}/archive/testswift.{client}.conf'.format(tdir=testdir, client=client),
            data=conf_fp.getvalue(),
            )
    yield
示例#4
0
def configure(ctx, config):
    """
    Configure rgw and Swift
    """
    assert isinstance(config, dict)
    log.info('Configuring testswift...')
    testdir = teuthology.get_testdir(ctx)
    for client, properties in config['clients'].iteritems():
        log.info('client={c}'.format(c=client))
        log.info('config={c}'.format(c=config))
        testswift_conf = config['testswift_conf'][client]
        if properties is not None and 'rgw_server' in properties:
            host = None
            for target, roles in zip(ctx.config['targets'].iterkeys(), ctx.config['roles']):
                log.info('roles: ' + str(roles))
                log.info('target: ' + str(target))
                if properties['rgw_server'] in roles:
                    _, host = split_user(target)
            assert host is not None, "Invalid client specified as the rgw_server"
            testswift_conf['func_test']['auth_host'] = host
        else:
            testswift_conf['func_test']['auth_host'] = 'localhost'

        log.info(client)
        (remote,) = ctx.cluster.only(client).remotes.keys()
        remote.run(
            args=[
                'cd',
                '{tdir}/swift'.format(tdir=testdir),
                run.Raw('&&'),
                './bootstrap',
                ],
            )
        conf_fp = StringIO()
        testswift_conf.write(conf_fp)
        teuthology.write_file(
            remote=remote,
            path='{tdir}/archive/testswift.{client}.conf'.format(tdir=testdir, client=client),
            data=conf_fp.getvalue(),
            )
    yield
示例#5
0
def configure(ctx, config, run_stages):
    """
    Configure the ragweed.  This includes the running of the
    bootstrap code and the updating of local conf files.
    """
    assert isinstance(config, dict)
    log.info('Configuring ragweed...')
    testdir = teuthology.get_testdir(ctx)
    for client, properties in config['clients'].iteritems():
        (remote, ) = ctx.cluster.only(client).remotes.keys()
        remote.run(args=[
            'cd',
            '{tdir}/ragweed'.format(tdir=testdir),
            run.Raw('&&'),
            './bootstrap',
        ], )

        preparing = 'prepare' in run_stages[client]
        if not preparing:
            # should have been prepared in a previous run
            continue

        ragweed_conf = config['ragweed_conf'][client]
        if properties is not None and 'rgw_server' in properties:
            host = None
            for target, roles in zip(ctx.config['targets'].iterkeys(),
                                     ctx.config['roles']):
                log.info('roles: ' + str(roles))
                log.info('target: ' + str(target))
                if properties['rgw_server'] in roles:
                    _, host = split_user(target)
            assert host is not None, "Invalid client specified as the rgw_server"
            ragweed_conf['rgw']['host'] = host
        else:
            ragweed_conf['rgw']['host'] = 'localhost'

        if properties is not None and 'slow_backend' in properties:
            ragweed_conf['fixtures']['slow backend'] = properties[
                'slow_backend']

        conf_fp = StringIO()
        ragweed_conf.write(conf_fp)
        teuthology.write_file(
            remote=remote,
            path='{tdir}/archive/ragweed.{client}.conf'.format(tdir=testdir,
                                                               client=client),
            data=conf_fp.getvalue(),
        )

    log.info('Configuring boto...')
    boto_src = os.path.join(os.path.dirname(__file__), 'boto.cfg.template')
    for client, properties in config['clients'].iteritems():
        with file(boto_src, 'rb') as f:
            (remote, ) = ctx.cluster.only(client).remotes.keys()
            conf = f.read().format(idle_timeout=config.get('idle_timeout', 30))
            teuthology.write_file(
                remote=remote,
                path='{tdir}/boto.cfg'.format(tdir=testdir),
                data=conf,
            )

    try:
        yield

    finally:
        log.info('Cleaning up boto...')
        for client, properties in config['clients'].iteritems():
            (remote, ) = ctx.cluster.only(client).remotes.keys()
            remote.run(args=[
                'rm',
                '{tdir}/boto.cfg'.format(tdir=testdir),
            ], )
示例#6
0
文件: s3tests.py 项目: C2python/ceph
def configure(ctx, config):
    """
    Configure the s3-tests.  This includes the running of the
    bootstrap code and the updating of local conf files.
    """
    assert isinstance(config, dict)
    log.info('Configuring s3-tests...')
    testdir = teuthology.get_testdir(ctx)
    for client, properties in config['clients'].iteritems():
        s3tests_conf = config['s3tests_conf'][client]
        if properties is not None and 'rgw_server' in properties:
            host = None
            for target, roles in zip(ctx.config['targets'].iterkeys(), ctx.config['roles']):
                log.info('roles: ' + str(roles))
                log.info('target: ' + str(target))
                if properties['rgw_server'] in roles:
                    _, host = split_user(target)
            assert host is not None, "Invalid client specified as the rgw_server"
            s3tests_conf['DEFAULT']['host'] = host
        else:
            s3tests_conf['DEFAULT']['host'] = 'localhost'

        if properties is not None and 'slow_backend' in properties:
	    s3tests_conf['fixtures']['slow backend'] = properties['slow_backend']

        (remote,) = ctx.cluster.only(client).remotes.keys()
        remote.run(
            args=[
                'cd',
                '{tdir}/s3-tests'.format(tdir=testdir),
                run.Raw('&&'),
                './bootstrap',
                ],
            )
        conf_fp = StringIO()
        s3tests_conf.write(conf_fp)
        teuthology.write_file(
            remote=remote,
            path='{tdir}/archive/s3-tests.{client}.conf'.format(tdir=testdir, client=client),
            data=conf_fp.getvalue(),
            )

    log.info('Configuring boto...')
    boto_src = os.path.join(os.path.dirname(__file__), 'boto.cfg.template')
    for client, properties in config['clients'].iteritems():
        with file(boto_src, 'rb') as f:
            (remote,) = ctx.cluster.only(client).remotes.keys()
            conf = f.read().format(
                idle_timeout=config.get('idle_timeout', 30)
                )
            teuthology.write_file(
                remote=remote,
                path='{tdir}/boto.cfg'.format(tdir=testdir),
                data=conf,
                )

    try:
        yield

    finally:
        log.info('Cleaning up boto...')
        for client, properties in config['clients'].iteritems():
            (remote,) = ctx.cluster.only(client).remotes.keys()
            remote.run(
                args=[
                    'rm',
                    '{tdir}/boto.cfg'.format(tdir=testdir),
                    ],
                )
示例#7
0
文件: rgw.py 项目: leseb/ceph-ci
def host_for_role(ctx, role):
    for target, roles in zip(ctx.config['targets'].iterkeys(),
                             ctx.config['roles']):
        if role in roles:
            _, host = split_user(target)
            return host
示例#8
0
def host_for_role(ctx, role):
    for target, roles in zip(ctx.config['targets'].iterkeys(), ctx.config['roles']):
        if role in roles:
            _, host = split_user(target)
            return host
示例#9
0
def configure(ctx, config):
    """
    Configure the s3-tests.  This includes the running of the
    bootstrap code and the updating of local conf files.
    """
    assert isinstance(config, dict)
    log.info('Configuring s3-tests...')
    testdir = teuthology.get_testdir(ctx)
    for client, properties in config['clients'].items():
        s3tests_conf = config['s3tests_conf'][client]
        if properties is not None and 'rgw_server' in properties:
            host = None
            for target, roles in zip(ctx.config['targets'].keys(),
                                     ctx.config['roles']):
                log.info('roles: ' + str(roles))
                log.info('target: ' + str(target))
                if properties['rgw_server'] in roles:
                    _, host = split_user(target)
            assert host is not None, "Invalid client specified as the rgw_server"
            s3tests_conf['DEFAULT']['host'] = host
        else:
            s3tests_conf['DEFAULT']['host'] = 'localhost'

        if properties is not None and 'slow_backend' in properties:
            s3tests_conf['fixtures']['slow backend'] = properties[
                'slow_backend']

        (remote, ) = ctx.cluster.only(client).remotes.keys()
        remote.run(args=[
            'cd',
            '{tdir}/s3-tests'.format(tdir=testdir),
            run.Raw('&&'),
            './bootstrap',
        ], )
        conf_fp = BytesIO()
        s3tests_conf.write(conf_fp)
        teuthology.write_file(
            remote=remote,
            path='{tdir}/archive/s3-tests.{client}.conf'.format(tdir=testdir,
                                                                client=client),
            data=conf_fp.getvalue(),
        )

    log.info('Configuring boto...')
    boto_src = os.path.join(os.path.dirname(__file__), 'boto.cfg.template')
    for client, properties in config['clients'].items():
        with open(boto_src, 'rb') as f:
            (remote, ) = ctx.cluster.only(client).remotes.keys()
            conf = six.ensure_str(
                f.read()).format(idle_timeout=config.get('idle_timeout', 30))
            teuthology.write_file(
                remote=remote,
                path='{tdir}/boto.cfg'.format(tdir=testdir),
                data=six.ensure_binary(conf),
            )

    try:
        yield

    finally:
        log.info('Cleaning up boto...')
        for client, properties in config['clients'].items():
            (remote, ) = ctx.cluster.only(client).remotes.keys()
            remote.run(args=[
                'rm',
                '{tdir}/boto.cfg'.format(tdir=testdir),
            ], )
示例#10
0
 def test_split_user_both(self):
     got = connection.split_user('*****@*****.**')
     assert got == ('jdoe', 'somehost.example.com')
示例#11
0
 def test_split_user_just_host(self):
     got = connection.split_user('somehost.example.com')
     assert got == (None, 'somehost.example.com')