]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw_admin: don't use boto for testing 301 responses
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 14 Jan 2015 23:10:23 +0000 (15:10 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Wed, 14 Jan 2015 23:10:23 +0000 (15:10 -0800)
boto follows up on the redirects. Switched to using httplib2 for sending
this request.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
tasks/radosgw_admin.py

index fa667010ebbb57454903e9cb1e718111a82a7e3b..9a51ac66b6d8b8d0bb4800fbb4389f02d671567b 100644 (file)
@@ -18,6 +18,8 @@ import boto.exception
 import boto.s3.connection
 import boto.s3.acl
 
+import httplib2
+
 import util.rgw as rgw_utils
 
 from teuthology import misc as teuthology
@@ -35,6 +37,21 @@ def successful_ops(out):
     return entry['total']['successful_ops']
 
 
+def create_presigned_url(conn, method, bucket_name, key_name, expiration):
+    return conn.generate_url(expires_in=expiration,
+        method=method,
+        bucket=bucket_name,
+        key=key_name,
+        query_auth=True,
+    )
+
+def send_raw_http_request(conn, method, bucket_name, key_name, follow_redirects = False):
+    url = create_presigned_url(conn, method, bucket_name, key_name, 3600)
+    print url
+    h = httplib2.Http()
+    h.follow_redirects = follow_redirects
+    return h.request(url, method)
+
 def task(ctx, config):
     """
     Test radosgw-admin functionality against a running rgw instance.
@@ -266,26 +283,20 @@ def task(ctx, config):
             # Attempt to create a new connection with user1 to the destination RGW
             log.debug('Attempt to create a new connection with user1 to the destination RGW')
             # and use that to attempt a delete (that should fail)
-            exception_encountered = False
-            try:
-                (dest_remote_host, dest_remote_port) = ctx.rgw.role_endpoints[dest_client]
-                connection_dest = boto.s3.connection.S3Connection(
-                    aws_access_key_id=access_key,
-                    aws_secret_access_key=secret_key,
-                    is_secure=False,
-                    port=dest_remote_port,
-                    host=dest_remote_host,
-                    calling_format=boto.s3.connection.OrdinaryCallingFormat(),
-                    )
 
-                # this should fail
-                connection_dest.delete_bucket(bucket_name2)
-            except boto.exception.S3ResponseError as e:
-                assert e.status == 301
-                exception_encountered = True
+            (dest_remote_host, dest_remote_port) = ctx.rgw.role_endpoints[dest_client]
+            connection_dest = boto.s3.connection.S3Connection(
+                aws_access_key_id=access_key,
+                aws_secret_access_key=secret_key,
+                is_secure=False,
+                port=dest_remote_port,
+                host=dest_remote_host,
+                calling_format=boto.s3.connection.OrdinaryCallingFormat(),
+                )
 
-            # confirm that the expected exception was seen
-            assert exception_encountered
+            # this should fail
+            r, content = send_raw_http_request(connection_dest, 'DELETE', bucket_name2, '', follow_redirects = False)
+            assert r.status == 301
 
             # now delete the bucket on the source RGW and do another sync
             log.debug('now delete the bucket on the source RGW and do another sync')