X-Git-Url: https://git.proxmox.com/?p=ceph.git;a=blobdiff_plain;f=ceph%2Fqa%2Fworkunits%2Frgw%2Ftest_rgw_reshard.py;fp=ceph%2Fqa%2Fworkunits%2Frgw%2Ftest_rgw_reshard.py;h=0b370dc723428816fa9b105c7897a38c4503588c;hp=ab026c7ed77b63bc424ccdc20f4f6937019b6923;hb=05a536ef04248702f72713fd2fe81cb055624784;hpb=ab27109dd2e88c6e1082a346b3be8444697297c6 diff --git a/ceph/qa/workunits/rgw/test_rgw_reshard.py b/ceph/qa/workunits/rgw/test_rgw_reshard.py index ab026c7ed..0b370dc72 100755 --- a/ceph/qa/workunits/rgw/test_rgw_reshard.py +++ b/ceph/qa/workunits/rgw/test_rgw_reshard.py @@ -1,13 +1,11 @@ #!/usr/bin/python3 import errno -import logging as log import time -import subprocess +import logging as log import json -import boto3 -import botocore.exceptions import os +from common import exec_cmd, boto_connect, create_user """ Rgw manual and dynamic resharding testing against a running instance @@ -19,11 +17,6 @@ Rgw manual and dynamic resharding testing against a running instance # # -log.basicConfig(format = '%(message)s', level=log.DEBUG) -log.getLogger('botocore').setLevel(log.CRITICAL) -log.getLogger('boto3').setLevel(log.CRITICAL) -log.getLogger('urllib3').setLevel(log.CRITICAL) - """ Constants """ USER = 'tester' DISPLAY_NAME = 'Testing' @@ -33,18 +26,6 @@ BUCKET_NAME = 'a-bucket' VER_BUCKET_NAME = 'myver' INDEX_POOL = 'default.rgw.buckets.index' -def exec_cmd(cmd, **kwargs): - check_retcode = kwargs.pop('check_retcode', True) - kwargs['shell'] = True - kwargs['stdout'] = subprocess.PIPE - proc = subprocess.Popen(cmd, **kwargs) - log.info(proc.args) - out, _ = proc.communicate() - if check_retcode: - assert(proc.returncode == 0) - return out - return (out, proc.returncode) - class BucketStats: def __init__(self, bucket_name, bucket_id, num_objs=0, size_kb=0, num_shards=0): self.bucket_name = bucket_name @@ -163,41 +144,14 @@ def main(): """ execute manual and dynamic resharding commands """ - # create user - _, ret = exec_cmd('radosgw-admin user create --uid {} --display-name {} --access-key {} --secret {}'.format(USER, DISPLAY_NAME, ACCESS_KEY, SECRET_KEY), check_retcode=False) - assert(ret == 0 or errno.EEXIST) - - def boto_connect(portnum, ssl, proto): - endpoint = proto + '://localhost:' + portnum - conn = boto3.resource('s3', - aws_access_key_id=ACCESS_KEY, - aws_secret_access_key=SECRET_KEY, - use_ssl=ssl, - endpoint_url=endpoint, - verify=False, - config=None, - ) - try: - list(conn.buckets.limit(1)) # just verify we can list buckets - except botocore.exceptions.ConnectionError as e: - print(e) - raise - print('connected to', endpoint) - return conn - - try: - connection = boto_connect('80', False, 'http') - except botocore.exceptions.ConnectionError: - try: # retry on non-privileged http port - connection = boto_connect('8000', False, 'http') - except botocore.exceptions.ConnectionError: - # retry with ssl - connection = boto_connect('443', True, 'https') + create_user(USER, DISPLAY_NAME, ACCESS_KEY, SECRET_KEY) + + connection = boto_connect(ACCESS_KEY, SECRET_KEY) # create a bucket bucket = connection.create_bucket(Bucket=BUCKET_NAME) ver_bucket = connection.create_bucket(Bucket=VER_BUCKET_NAME) - connection.BucketVersioning('ver_bucket') + connection.BucketVersioning(VER_BUCKET_NAME).enable() bucket_acl = connection.BucketAcl(BUCKET_NAME).load() ver_bucket_acl = connection.BucketAcl(VER_BUCKET_NAME).load() @@ -313,13 +267,23 @@ def main(): json_op = json.loads(cmd.decode('utf-8', 'ignore')) # ignore utf-8 can't decode 0x80 assert len(json_op) == 0 + # TESTCASE 'check that PUT succeeds during reshard' + log.debug(' test: PUT succeeds during reshard') + num_shards = get_bucket_stats(VER_BUCKET_NAME).num_shards + exec_cmd('''radosgw-admin --inject-delay-at=do_reshard --inject-delay-ms=5000 \ + bucket reshard --bucket {} --num-shards {}''' + .format(VER_BUCKET_NAME, num_shards + 1), wait = False) + time.sleep(1) + ver_bucket.put_object(Key='put_during_reshard', Body=b"some_data") + log.debug('put object successful') + # Clean up log.debug("Deleting bucket {}".format(BUCKET_NAME)) bucket.objects.all().delete() bucket.delete() log.debug("Deleting bucket {}".format(VER_BUCKET_NAME)) + ver_bucket.object_versions.all().delete() ver_bucket.delete() - main() log.info("Completed resharding tests")