# grep '^ *# TESTCASE' | sed 's/^ *# TESTCASE //'
#
-from cStringIO import StringIO
-import logging
+import contextlib
import json
+import logging
+import time
+
+from cStringIO import StringIO
import boto.exception
import boto.s3.connection
import teuthology.task_util.rgw as rgw_utils
-import time
-
from teuthology import misc as teuthology
+from teuthology import contextutil
from teuthology.task_util.rgw import rgwadmin
log = logging.getLogger(__name__)
])
assert err
+ # this whole block should only be run if regions have been configured
+ if multi_region_run:
+ rgw_utils.radosgw_agent_sync_all(ctx)
+ # post-sync, validate that user1 exists on the sync destination host
+ for agent_client, c_config in ctx.radosgw_agent.config.iteritems():
+ dest_client = c_config['dest']
+ (err, out) = rgwadmin(ctx, dest_client, ['user', 'info', '--uid', user1])
+ assert not err
+ assert out['user_id'] == user1
+ assert out['email'] == email
+ assert out['display_name'] == display_name1
+ assert len(out['keys']) == 1
+ assert out['keys'][0]['access_key'] == access_key
+ assert out['keys'][0]['secret_key'] == secret_key
+ assert not out['suspended']
+
+ # compare the metadata between different regions, make sure it matches
+ for agent_client, c_config in ctx.radosgw_agent.config.iteritems():
+ source_client = c_config['src']
+ dest_client = c_config['dest']
+ (err1, out1) = rgwadmin(ctx, source_client, ['metadata', 'get', 'user:{uid}'.format(uid=user1)])
+ (err2, out2) = rgwadmin(ctx, dest_client, ['metadata', 'get', 'user:{uid}'.format(uid=user1)])
+ assert not err1
+ assert not err2
+ assert out1 == out2
+
+ # suspend a user on the master, then check the status on the destination
+ for agent_client, c_config in ctx.radosgw_agent.config.iteritems():
+ source_client = c_config['src']
+ dest_client = c_config['dest']
+ (err, out) = rgwadmin(ctx, source_client, ['user', 'suspend', '--uid', user1])
+ rgw_utils.radosgw_agent_sync_all(ctx)
+ (err, out) = rgwadmin(ctx, dest_client, ['user', 'info', '--uid', user1])
+ assert not err
+ assert out['suspended']
+
+ # delete a user on the master, then check that it's gone on the destination
+ for agent_client, c_config in ctx.radosgw_agent.config.iteritems():
+ source_client = c_config['src']
+ dest_client = c_config['dest']
+ (err, out) = rgwadmin(ctx, source_client, ['user', 'rm', '--uid', user1])
+ assert not err
+ rgw_utils.radosgw_agent_sync_all(ctx)
+ (err, out) = rgwadmin(ctx, dest_client, ['user', 'info', '--uid', user1])
+ assert out is None
+
+ # then recreate it so later tests pass
+ (err, out) = rgwadmin(ctx, client, [
+ 'user', 'create',
+ '--uid', user1,
+ '--display-name', display_name1,
+ '--email', email,
+ '--access-key', access_key,
+ '--secret', secret_key,
+ '--max-buckets', '4'
+ ])
+ assert not err
+ # end of 'if multi_region_run:'
+
# TESTCASE 'info-existing','user','info','existing user','returns correct info'
(err, out) = rgwadmin(ctx, client, ['user', 'info', '--uid', user1])
assert not err
import requests
from urlparse import urlparse
+from ..orchestra.connection import split_user
from teuthology import misc as teuthology
log = logging.getLogger(__name__)
def rgwadmin(ctx, client, cmd, stdin=StringIO(), check_status=False):
- log.info('radosgw-admin: %s' % cmd)
+ log.info('rgwadmin: %s' % cmd)
testdir = teuthology.get_testdir(ctx)
pre = [
'{tdir}/adjust-ulimits'.format(tdir=testdir),
'-n', client,
]
pre.extend(cmd)
- log.info('radosgw-admin: cmd=%s' % pre)
+ log.info('rgwadmin: cmd=%s' % pre)
(remote,) = ctx.cluster.only(client).remotes.iterkeys()
proc = remote.run(
args=pre,
def radosgw_agent_sync(ctx, agent_host, agent_port):
- print 'agent_host', agent_host, 'port', agent_port
log.info('sync agent {h}:{p}'.format(h=agent_host, p=agent_port))
return requests.post('http://{addr}:{port}/metadata/incremental'.format(addr = agent_host, port = agent_port))
if ctx.radosgw_agent.procs:
for agent_client, c_config in ctx.radosgw_agent.config.iteritems():
dest_zone = zone_for_client(ctx, agent_client)
- port = c_config.get('port', 8000)
- dest_host, dest_port = get_zone_host_and_port(ctx, agent_client, dest_zone)
- radosgw_agent_sync(ctx, dest_host, port)
-
-def radosgw_agent_sync_all(ctx):
- if ctx.radosgw_agent.procs:
- for agent_client, c_config in ctx.radosgw_agent.config.iteritems():
- dest_zone = zone_for_client(ctx, agent_client)
- port = c_config.get('port', 8000)
- dest_host, dest_port = get_zone_host_and_port(ctx, agent_client, dest_zone)
- radosgw_agent_sync(ctx, dest_host, port)
-
-
-
+ sync_dest, sync_port = get_sync_agent(ctx, agent_client)
+ log.debug('doing a sync from {host1} to {host2}'.format(
+ host1=agent_client,host2=sync_dest))
+ radosgw_agent_sync(ctx, sync_dest, sync_port)
+
+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
+
+def get_sync_agent(ctx, source):
+ for task in ctx.config['tasks']:
+ if 'radosgw-agent' not in task:
+ continue
+ for client, conf in task['radosgw-agent'].iteritems():
+ if conf['src'] == source:
+ return host_for_role(ctx, source), conf.get('port', 8000)
+ return None, None