def test_exec(config):

    test_info = AddTestInfo(
        'enable versioning on a bucket and upload keys and its versions')

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    try:

        test_info.started_info()

        all_user_details = rgw_lib.create_users(config.user_count)

        for each_user in all_user_details:

            rgw = ObjectOps(config, each_user)
            rgw.enable_versioning = True
            rgw.version_count = config.version_count
            buckets = rgw.create_bucket()
            rgw.set_bucket_properties()
            rgw.upload(buckets)

        test_info.success_status('test completed')

        sys.exit(0)

    except AssertionError, e:
        log.error(e)
        sys.exit(1)
예제 #2
0
def test_exec(config):

    test_info = AddTestInfo('create m buckets')

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    try:

        # test case starts

        test_info.started_info()

        all_user_details = rgw_lib.create_users(config.user_count)

        for each_user in all_user_details:

            rgw = ObjectOps(config, each_user)

            assert rgw.create_bucket()

        test_info.success_status('test completed')

        sys.exit(0)

    except AssertionError, e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
예제 #3
0
def test_exec(config):
    test_info = AddTestInfo("multipart Upload with cancel and download")
    add_io_info = AddIOInfo()
    add_io_info.initialize()
    try:
        # test case starts
        test_info.started_info()
        all_user_details = rgw_lib.create_users(config.user_count)
        log.info("multipart upload enabled")
        for each_user in all_user_details:
            config.objects_count = 1
            rgw = ObjectOps(config, each_user)
            buckets = rgw.create_bucket()
            rgw.break_upload_at_part_no = config.break_at_part_no
            rgw.multipart_upload(buckets)

            log.info("starting at part no: %s" % config.break_at_part_no)
            log.info("--------------------------------------------------")
            rgw.break_upload_at_part_no = 0
            rgw.multipart_upload(buckets)
            rgw.download_keys()
        test_info.success_status("test completed")
        sys.exit(0)
    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
예제 #4
0
def test_exec(config):

    test_info = AddTestInfo('multipart Upload')

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    try:

        # test case starts

        test_info.started_info()

        all_user_details = rgw_lib.create_users(config.user_count)

        log.info('multipart upload enabled')

        for each_user in all_user_details:

            config.objects_count = 1

            rgw = ObjectOps(config, each_user)
            buckets = rgw.create_bucket()

            rgw.multipart_upload(buckets)

        test_info.success_status('test completed')

        sys.exit(0)

    except AssertionError, e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
예제 #5
0
def test_exec(config):

    test_info = AddTestInfo("create users")

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    try:
        test_info.started_info()

        all_user_details = rgw_lib.create_users(config.user_count,
                                                config.cluster_name)

        # dump the list of users into a file

        with open("user_details", "w") as fout:
            json.dump(all_user_details, fout)

        test_info.success_status("user creation completed")

        sys.exit(0)

    except AssertionError as e:
        log.error(e)
        test_info.failed_status("user creation failed: %s" % e)
        sys.exit(1)
def test_exec_read(config):

    grants = {'permission': 'READ', 'user_id': None, 'recursive': True}

    test_info = AddTestInfo(
        'Test with read permission on buckets for all users')

    add_io_info = AddIOInfo()
    add_io_info.initialize()

    try:

        # test case starts

        test_info.started_info()

        all_user_details = rgw_lib.create_users(config.user_count)

        user1 = all_user_details[0]
        log.info('user1: %s' % user1)

        all_user_details.pop(0)

        u1 = ObjectOps(config, user1)

        for each_user in all_user_details:

            u2 = ObjectOps(config, each_user)

            u2_canonical_id = u2.canonical_id

            log.info('canonical id of u2: %s' % u2_canonical_id)

            grants['user_id'] = u2_canonical_id

            u1.grants = None
            u1.create_bucket()
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.grants = None
            u2.set_bucket_properties()

            # set permissions and read

            u1.grants = grants
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created

            u2.grants = None
            u2.set_bucket_properties()

        test_info.success_status('test completed')

    except AssertionError, e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
def test_exec_write(config):
    test_info = AddTestInfo(
        "test with write persmission on objects and buckets for all users")
    try:
        # test case starts
        test_info.started_info()
        all_user_details = rgw_lib.create_users(config.user_count)
        user1 = all_user_details[0]
        u1 = ObjectOps(config, user1)
        u1.create_bucket()
        log.info("user1: %s" % user1)
        all_user_details.pop(0)
        for each_user in all_user_details:
            print("iter ------------------>")
            log.info("user2: %s" % each_user)
            u2 = ObjectOps(config, each_user)
            u2_canonical_id = u2.canonical_id
            log.info("canonical id of u2: %s" % u2_canonical_id)
            log.info("setting only read permission")
            grants = {"permission": "READ", "user_id": None, "recursive": True}
            log.info("write persmission are not set")
            grants["user_id"] = u2_canonical_id
            u1.grants = grants
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created
            u2.json_file_upload = u1.json_file_upload
            u2.json_file_download = u1.json_file_download
            u2.grants = None
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets)
            if not key_created:
                log.info(
                    "no write permission set and hence failing to create object"
                )
            elif key_created:
                raise AssertionError("object created even with no permission")
            log.info("setting permission to write also")
            grants = {
                "permission": "WRITE",
                "user_id": u2_canonical_id,
                "recursive": True,
            }
            u1.grants = grants
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created
            u2.grants = None
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets,
                                    object_base_name=str(u2.canonical_id) +
                                    ".key")
            if key_created:
                log.info("object created after permission set")
        test_info.success_status("test completed")
    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
def test_exec_read(config):
    test_info = AddTestInfo("Test with read permission on buckets")
    try:
        # test case starts
        add_io_info = AddIOInfo()
        add_io_info.initialize()
        test_info.started_info()
        all_user_details = rgw_lib.create_users(config.user_count)
        user1 = all_user_details[0]
        log.info("user1: %s" % user1)
        user2 = all_user_details[1]
        log.info("user2: %s" % user2)
        u1 = ObjectOps(config, user1)
        u2 = ObjectOps(config, user2)
        u1_grants = {
            "permission": "READ",
            "user_id": u2.canonical_id,
            "recursive": True,
        }
        u2_grants = {
            "permission": "FULL_CONTROL",
            "user_id": u1.canonical_id,
            "recursive": True,
        }
        u1.grants = u1_grants
        u1.create_bucket()
        u1_buckets = u1.set_bucket_properties()
        u1.upload(u1_buckets, object_base_name=u1.canonical_id + ".key")
        all_keys = u1_buckets[0].get_all_keys()
        for key in all_keys:
            log.info("all keys from user 1--------------")
            log.info("name: %s" % key.name)
        u2.grants = u2_grants
        u2.create_bucket()
        u2_buckets = u2.set_bucket_properties()
        bu2 = u1.connection["conn"].get_bucket(u2_buckets[0].name)
        log.info("copying the objects from u1 to u2")
        for each in all_keys:
            bu2.copy_key(each.key, u1_buckets[0].name, each.key)
        all_keys2 = bu2.get_all_keys()
        for key in all_keys2:
            log.info("all keys from user 2--------------")
            log.info("name: %s" % key.name)
        log.info("verifying copied objects--------")
        u2.grants = None
        u2_buckets = u2.set_bucket_properties()
        all_keys3 = u2_buckets[0].get_all_keys()
        for key in all_keys3:
            log.info("all keys from user 2--------------")
            log.info("name: %s" % key.name)
        test_info.success_status("test completed")
    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
def test_exec_read(config):
    test_info = AddTestInfo('Test with read permission on buckets')
    try:
        # test case starts
        add_io_info = AddIOInfo()
        add_io_info.initialize()
        test_info.started_info()
        all_user_details = rgw_lib.create_users(config.user_count)
        user1 = all_user_details[0]
        log.info('user1: %s' % user1)
        user2 = all_user_details[1]
        log.info('user2: %s' % user2)
        u1 = ObjectOps(config, user1)
        u2 = ObjectOps(config, user2)
        u1_grants = {
            'permission': 'READ',
            'user_id': u2.canonical_id,
            'recursive': True
        }
        u2_grants = {
            'permission': 'FULL_CONTROL',
            'user_id': u1.canonical_id,
            'recursive': True
        }
        u1.grants = u1_grants
        u1.create_bucket()
        u1_buckets = u1.set_bucket_properties()
        u1.upload(u1_buckets, object_base_name=u1.canonical_id + '.key')
        all_keys = u1_buckets[0].get_all_keys()
        for key in all_keys:
            log.info('all keys from user 1--------------')
            log.info('name: %s' % key.name)
        u2.grants = u2_grants
        u2.create_bucket()
        u2_buckets = u2.set_bucket_properties()
        bu2 = u1.connection['conn'].get_bucket(u2_buckets[0].name)
        log.info('copying the objects from u1 to u2')
        for each in all_keys:
            bu2.copy_key(each.key, u1_buckets[0].name, each.key)
        all_keys2 = bu2.get_all_keys()
        for key in all_keys2:
            log.info('all keys from user 2--------------')
            log.info('name: %s' % key.name)
        log.info('verifying copied objects--------')
        u2.grants = None
        u2_buckets = u2.set_bucket_properties()
        all_keys3 = u2_buckets[0].get_all_keys()
        for key in all_keys3:
            log.info('all keys from user 2--------------')
            log.info('name: %s' % key.name)
        test_info.success_status('test completed')
    except AssertionError as e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
예제 #10
0
    def create_rgw_user(self):

        log.info('creating rgw user')

        rgw_user = rgw.create_users(1)[0]

        self.user_id = rgw_user['user_id']
        self.access_key = rgw_user['access_key']
        self.secret_key = rgw_user['secret_key']

        self.rgw_hostname = socket.gethostname()
        self.ganesha_config_exists = False
        self.already_mounted = False
예제 #11
0
def test_exec_write(config):
    test_info = AddTestInfo(
        "test with write persmission on objects and buckets")
    try:
        # test case starts
        test_info.started_info()
        all_user_details = rgw_lib.create_users(config.user_count)
        user1 = all_user_details[0]
        log.info("user1: %s" % user1)
        user2 = all_user_details[1]
        log.info("user2: %s" % user2)
        u1 = ObjectOps(config, user1)
        u2 = ObjectOps(config, user2)
        u2_canonical_id = u2.canonical_id
        log.info("canonical id of u2: %s" % u2_canonical_id)
        grants = {"permission": "READ", "user_id": None, "recursive": True}
        log.info("write persmission are not set")
        grants["user_id"] = u2_canonical_id
        u1.grants = grants
        u1.create_bucket()
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created
        u2.json_file_upload = u1.json_file_upload
        u2.json_file_download = u1.json_file_download
        u2.grants = None
        buckets = u2.set_bucket_properties()
        uploaded = u2.upload(buckets)
        if not uploaded:
            log.info(
                "no write permission set and hence failing to create object")
        log.info("setting permission to write also")
        grants = {
            "permission": "WRITE",
            "user_id": u2_canonical_id,
            "recursive": True
        }
        u1.grants = grants
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created
        u2.grants = None
        buckets = u2.set_bucket_properties()
        uploaded = u2.upload(buckets)
        if uploaded:
            log.info("object created after permission set")
        test_info.success_status("test completed")
    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
예제 #12
0
def test_exec_write(config):
    test_info = AddTestInfo('test with write persmission on objects and buckets for all users')
    try:
        # test case starts
        test_info.started_info()
        all_user_details = rgw_lib.create_users(config.user_count)
        user1 = all_user_details[0]
        u1 = ObjectOps(config, user1)
        log.info('user1: %s' % user1)
        all_user_details.pop(0)
        for each_user in all_user_details:
            print('iter ------------------>')
            log.info('user2: %s' % each_user)
            u2 = ObjectOps(config, each_user)
            u2_canonical_id = u2.canonical_id
            log.info('canonical id of u2: %s' % u2_canonical_id)
            log.info('setting only read permission')
            grants = {'permission': 'READ', 'user_id': None, 'recursive': True}
            log.info('write persmission are not set')
            grants['user_id'] = u2_canonical_id
            u1.grants = grants
            u1.create_bucket()
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created
            u2.json_file_upload = u1.json_file_upload
            u2.json_file_download = u1.json_file_download
            u2.grants = None
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets)
            if not key_created:
                log.info('no write permission set and hence failing to create object')
            elif key_created:
                raise AssertionError("object created even with no permission")
            log.info('setting permission to write also')
            grants = {'permission': 'WRITE', 'user_id': u2_canonical_id, 'recursive': True}
            u1.grants = grants
            u1.set_bucket_properties()
            u2.bucket_names = u1.bucket_names
            u2.buckets_created = u1.buckets_created
            u2.grants = None
            buckets = u2.set_bucket_properties()
            key_created = u2.upload(buckets, object_base_name=str(u2.canonical_id) + ".key")
            if key_created:
                log.info('object created after permission set')
        test_info.success_status('test completed')
    except AssertionError as e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
def test_exec(config):
    test_info = AddTestInfo("create m buckets, n objects and delete")
    add_io_info = AddIOInfo()
    add_io_info.initialize()
    try:
        test_info.started_info()
        rgw_service = RGWService()
        quota_mgmt = QuotaMgmt()
        test_config = AddToCephConf()
        if config.shards:
            test_config.set_to_ceph_conf(
                "global", ConfigOpts.rgw_override_bucket_index_max_shards,
                config.shards)
            log.info(
                "test to continue after service restart, sleept time 120 seconds"
            )
            no_of_shards_for_each_bucket = int(config.shards) * int(
                config.bucket_count)
        if config.dynamic_sharding is True:
            test_config.set_to_ceph_conf(
                "global",
                ConfigOpts.rgw_max_objs_per_shard,
                config.max_objects_per_shard,
            )
            test_config.set_to_ceph_conf("global",
                                         ConfigOpts.rgw_dynamic_resharding,
                                         True)
            num_shards_expected = config.objects_count / config.max_objects_per_shard
            log.info("num_shards_expected: %s" % num_shards_expected)
            log.info(
                "test to continue after service restart, sleept time 120 seconds"
            )
        rgw_service.restart()
        time.sleep(120)
        all_user_details = rgw_lib.create_users(config.user_count)
        for each_user in all_user_details:
            if config.max_objects:
                quota_mgmt.set_bucket_quota(each_user["user_id"],
                                            config.max_objects)
                quota_mgmt.enable_bucket_quota(each_user["user_id"])
            rgw = ObjectOps(config, each_user)
            buckets = rgw.create_bucket()
            rgw.upload(buckets)
        test_info.success_status("test completed")
        sys.exit(0)
    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
예제 #14
0
def test_exec_write(config):
    test_info = AddTestInfo('test with write persmission on objects and buckets')
    try:
        # test case starts
        test_info.started_info()
        all_user_details = rgw_lib.create_users(config.user_count)
        user1 = all_user_details[0]
        log.info('user1: %s' % user1)
        user2 = all_user_details[1]
        log.info('user2: %s' % user2)
        u1 = ObjectOps(config, user1)
        u2 = ObjectOps(config, user2)
        u2_canonical_id = u2.canonical_id
        log.info('canonical id of u2: %s' % u2_canonical_id)
        grants = {'permission': 'READ', 'user_id': None, 'recursive': True}
        log.info('write persmission are not set')
        grants['user_id'] = u2_canonical_id
        u1.grants = grants
        u1.create_bucket()
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created
        u2.json_file_upload = u1.json_file_upload
        u2.json_file_download = u1.json_file_download
        u2.grants = None
        buckets = u2.set_bucket_properties()
        uploaded = u2.upload(buckets)
        if not uploaded:
            log.info('no write permission set and hence failing to create object')
        log.info('setting permission to write also')
        grants = {'permission': 'WRITE', 'user_id': u2_canonical_id, 'recursive': True}
        u1.grants = grants
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created
        u2.grants = None
        buckets = u2.set_bucket_properties()
        uploaded = u2.upload(buckets)
        if uploaded:
            log.info('object created after permission set')
        test_info.success_status('test completed')
    except AssertionError as e:
        log.error(e)
        test_info.failed_status('test failed: %s' % e)
        sys.exit(1)
def test_exec(config):
    test_info = AddTestInfo("create m buckets, n keys and download")
    add_io_info = AddIOInfo()
    add_io_info.initialize()
    try:
        # test case starts
        test_info.started_info()
        all_user_details = rgw_lib.create_users(config.user_count)
        for each_user in all_user_details:
            rgw = ObjectOps(config, each_user)
            buckets = rgw.create_bucket()
            rgw.upload(buckets)
            rgw.download_keys()
        test_info.success_status("test completed")
        sys.exit(0)
    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)
예제 #16
0
def test_exec_read(config):
    """
    config.bucket_count = 3
    config.objects_count = 3
    config.objects_size_range = {'min': 50, 'max': 100}
    """
    grants = {"permission": "READ", "user_id": None, "recursive": True}
    test_info = AddTestInfo("Test with read permission on buckets")
    add_io_info = AddIOInfo()
    add_io_info.initialize()
    try:
        # test case starts
        test_info.started_info()
        all_user_details = rgw_lib.create_users(config.user_count)
        user1 = all_user_details[0]
        log.info("user1: %s" % user1)
        user2 = all_user_details[1]
        log.info("user2: %s" % user2)
        u1 = ObjectOps(config, user1)
        u2 = ObjectOps(config, user2)
        u2_canonical_id = u2.canonical_id
        log.info("canonical id of u2: %s" % u2_canonical_id)
        grants["user_id"] = u2_canonical_id
        u1.grants = None
        u1.create_bucket()
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created
        u2.grants = None
        u2.set_bucket_properties()
        # set permissions and read
        u1.grants = grants
        u1.set_bucket_properties()
        u2.bucket_names = u1.bucket_names
        u2.buckets_created = u1.buckets_created
        u2.grants = None
        u2.set_bucket_properties()
        test_info.success_status("test completed")
    except AssertionError as e:
        log.error(e)
        test_info.failed_status("test failed: %s" % e)
        sys.exit(1)