]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Adding multi-region tests 39/head
authorJoe Buck <jbbuck@gmail.com>
Tue, 13 Aug 2013 16:23:56 +0000 (09:23 -0700)
committerJoe Buck <jbbuck@gmail.com>
Fri, 16 Aug 2013 17:38:12 +0000 (10:38 -0700)
Adding tests for ticket #5604 to test
user propagation via the radosgw-agent.

Signed-off-by: Joe Buck <jbbuck@gmail.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
teuthology/task/radosgw-admin.py
teuthology/task_util/rgw.py

index 0a385c8f817e9446946b2ad930fc709a6884d931..5f0945ba495d0faceaa88d88024cae1ece131633 100644 (file)
@@ -4,9 +4,12 @@
 #   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
@@ -14,9 +17,8 @@ import boto.s3.acl
 
 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__)
@@ -99,6 +101,65 @@ def task(ctx, config):
             ])
     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
index 3dca2ccd2ba53d41cda2856d32351967fd82a358..0e6751444a61b46a7f38a83e1cb7b425257d4f4e 100644 (file)
@@ -4,12 +4,13 @@ import json
 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),
@@ -21,7 +22,7 @@ def rgwadmin(ctx, client, cmd, stdin=StringIO(), check_status=False):
         '-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,
@@ -100,7 +101,6 @@ def zone_for_client(ctx, client):
 
 
 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))
 
@@ -108,17 +108,22 @@ 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)
-
-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