Ejemplo n.º 1
0
    def __init__(self, user_info, **extra_kwargs):
        """
        Initializes the variables of user_info parameter
        """
        self.access_key = user_info["access_key"]
        self.secret_key = user_info["secret_key"]
        self.hostname = socket.gethostname()
        self.ip = socket.gethostbyname(self.hostname)
        self.ssl = extra_kwargs.get("ssl", False)
        self.port = utils.get_radosgw_port_no()
        self.endpoint_url = (
            "https://{}:{}".format(self.ip, self.port)
            if self.ssl
            else "http://{}:{}".format(self.ip, self.port)
        )
        self.is_secure = False
        self.user_id = user_info["user_id"]
        self.session_token = user_info.get("session_token")

        log.info("access_key: %s" % self.access_key)
        log.info("secret_key: %s" % self.secret_key)
        log.info("hostname: %s" % self.hostname)
        log.info("port: %s" % self.port)
        log.info("user_id: %s" % self.user_id)
        log.info("endpoint url: %s" % self.endpoint_url)
        log.info("ssl: %s" % self.ssl)
        log.info("session_token: %s" % self.session_token)
Ejemplo n.º 2
0
    def __init__(self):
        self._hostname, self._ip = utils.get_hostname_ip()
        self._ssl_port = 443
        self._non_ssl_port = utils.get_radosgw_port_no()
        self._ceph_conf = CephConfOp()
        self._rgw_service = RGWService()

        # _sections_to_check = ['client.rgw.' + self._hostname,
        #                       'client.rgw.' + self._ip]
        # log.info('checking for existence of sections: {}'.format(_sections_to_check))
        # _sections = [section for section in _sections_to_check if self._ceph_conf.check_if_section_exists(section)]
        #
        # log.info('got section(s): {}'.format(_sections))
        # if not any(_sections):
        #     raise RGWBaseException('No RGW section in ceph.conf')
        # self.section = _sections[0]

        sections_in_ceph_conf = self._ceph_conf.cfg.sections()
        log.info(
            'got sections from ceph_conf: {}'.format(sections_in_ceph_conf))
        rgw_section = list(
            filter(lambda section: 'rgw' in section, sections_in_ceph_conf))
        if not rgw_section:
            raise RGWBaseException('No RGW section in ceph.conf')
        self.section = rgw_section[0]
        log.info('using section: {}'.format(self.section))
def test_exec(config):

    io_info_initialize = IOInfoInitialize()
    basic_io_structure = BasicIOInfoStructure()
    io_info_initialize.initialize(basic_io_structure.initial())
    umgmt = UserMgmt()

    # preparing data
    user_names = ["tuffy", "scooby", "max"]
    tenant = "tenant"
    tenant_user_info = umgmt.create_tenant_user(tenant_name=tenant,
                                                user_id=user_names[0],
                                                displayname=user_names[0])
    user_info = umgmt.create_subuser(tenant_name=tenant, user_id=user_names[0])
    cmd = "radosgw-admin quota enable --quota-scope=user --uid={uid} --tenant={tenant}".format(
        uid=user_names[0], tenant=tenant)
    enable_user_quota = utils.exec_shell_cmd(cmd)
    cmd = "radosgw-admin quota set --quota-scope=user --uid={uid} --tenant={tenant} --max_buckets=2000".format(
        uid=user_names[0], tenant=tenant)
    max_bucket = utils.exec_shell_cmd(cmd)
    auth = Auth(user_info)
    rgw = auth.do_auth()
    for cc in range(config.container_count):
        container_name = utils.gen_bucket_name_from_userid(
            user_info["user_id"], rand_no=cc)
        container = swiftlib.resource_op({
            "obj": rgw,
            "resource": "put_container",
            "args": [container_name]
        })
        if container is False:
            raise TestExecError(
                "Resource execution failed: container creation faield")

    host, ip = utils.get_hostname_ip()
    port = utils.get_radosgw_port_no()
    hostname = str(ip) + ":" + str(port)
    cmd = "swift -A http://{hostname}/auth/1.0 -U '{uid}' -K '{key}' stat".format(
        hostname=hostname, uid=user_info["user_id"], key=user_info["key"])
    swift_cmd = utils.exec_shell_cmd(cmd)
    swift_cmd = swift_cmd.replace(" ", "")
    swift_cmd = swift_cmd.replace("\n", ":")
    li = list(swift_cmd.split(":"))
    res_dct = {li[i]: li[i + 1] for i in range(0, len(li) - 1, 2)}

    if int(res_dct["Containers"]) == config.container_count:
        cmd = "radosgw-admin user rm --uid={uid} --tenant={tenant} --purge-data".format(
            uid=user_names[0], tenant=tenant)
        delete_user_bucket = utils.exec_shell_cmd(cmd)
        test_info.success_status("test passed")
        sys.exit(0)
    else:
        cmd = "radosgw-admin user rm --uid={uid} --tenant={tenant} --purge-data".format(
            uid=user_names[0], tenant=tenant)
        delete_user_bucket = utils.exec_shell_cmd(cmd)
        test_info.failed_status("test failed")
        sys.exit(1)
Ejemplo n.º 4
0
 def __init__(self, user_info):
     """
     Initializes the user_info variables
     """
     self.secret_key = user_info["key"]
     self.hostname = socket.gethostname()
     self.port = int(utils.get_radosgw_port_no())
     self.is_secure = False
     self.user_id = user_info["user_id"]
Ejemplo n.º 5
0
def get_rgw_ip_and_port():
    """
    Returns RGW ip and port in <ip>:<port> format
    Returns: RGW ip and port
    """
    hostname = socket.gethostname()
    ip = socket.gethostbyname(hostname)
    port = utils.get_radosgw_port_no()
    ip_and_port = f"{ip}:{port}"
    return ip_and_port
Ejemplo n.º 6
0
    def verify_io(self):
        """
        This function to verify the data of buckets owned by a user

        Data verification happens to all the buckets of a particular user for both versioned and normal buckets
        Parameters:

        Returns:

        """
        log.info("***************Starting Verification*****************")
        data = self.file_op.get_data()
        users = data["users"]
        is_secure = True if utils.is_rgw_secure() else False
        host = socket.gethostbyname(socket.gethostname())

        endpoint_proto = "https" if is_secure else "http"
        endpoint_port = utils.get_radosgw_port_no()
        endpoint_url = f"{endpoint_proto}://{host}:{endpoint_port}"

        for each_user in users:
            log.info("verifying data for the user: \n")
            log.info("user_id: %s" % each_user["user_id"])
            log.info("access_key: %s" % each_user["access_key"])
            log.info("secret_key: %s" % each_user["secret_key"])
            conn = boto3.resource(
                "s3",
                aws_access_key_id=each_user["access_key"],
                aws_secret_access_key=each_user["secret_key"],
                endpoint_url=endpoint_url,
                use_ssl=is_secure,
                verify=False,
            )

            for each_bucket in each_user["bucket"]:
                log.info("verifying data for bucket: %s" % each_bucket["name"])
                bucket_from_s3 = conn.Bucket(each_bucket["name"])
                curr_versioning_status = each_bucket["curr_versioning_status"]
                log.info("curr_versioning_status: %s" % curr_versioning_status)
                if not each_bucket["keys"]:
                    log.info("keys are not created")
                else:
                    no_of_keys = len(each_bucket["keys"])
                    log.info("no_of_keys: %s" % no_of_keys)
                    for each_key in each_bucket["keys"]:
                        versioned_keys = len(each_key["versioning_info"])
                        log.info("versioned_keys: %s" % versioned_keys)
                        if not each_key["versioning_info"]:
                            log.info("not versioned key")
                            verify_key(each_key, bucket_from_s3)
                        else:
                            log.info("versioned key")
                            verify_key_with_version(each_key, bucket_from_s3)
        log.info("verification of data completed")
Ejemplo n.º 7
0
    def __init__(self, access_key, secret_key, user_id, port=None):

        log.debug("class: %s" % self.__class__.__name__)

        self.access_key = access_key
        self.secret_key = secret_key
        self.hostname = socket.gethostname()
        self.port = int(utils_v2.get_radosgw_port_no())
        self.is_secure = False
        self.user_id = user_id
        self.json_file_upload = self.user_id + "." + "upload" + "." + "json"
        self.json_file_download = self.user_id + "." + "download" + "." + "json"
def test_exec(config):
    """
    Executes test based on configuration passed
    Args:
        config(object): Test configuration
    """
    io_info_initialize = IOInfoInitialize()
    basic_io_structure = BasicIOInfoStructure()
    io_info_initialize.initialize(basic_io_structure.initial())
    umgmt = UserMgmt()
    ceph_conf = CephConfOp()
    rgw_service = RGWService()
    # preparing data
    user_name = resource_op.create_users(no_of_users_to_create=1)[0]["user_id"]
    tenant = "tenant"
    tenant_user_info = umgmt.create_tenant_user(tenant_name=tenant,
                                                user_id=user_name,
                                                displayname=user_name)
    user_info = umgmt.create_subuser(tenant_name=tenant, user_id=user_name)

    hostname = socket.gethostname()
    ip = socket.gethostbyname(hostname)
    port = utils.get_radosgw_port_no()

    ip_and_port = f"{ip}:{port}"
    s3_auth.do_auth(tenant_user_info, ip_and_port)

    bucket_name = utils.gen_bucket_name_from_userid(user_name, rand_no=0)

    # Create a bucket
    s3cmd_reusable.create_bucket(bucket_name)
    log.info(f"Bucket {bucket_name} created")

    # Upload file to bucket
    uploaded_file_info = s3cmd_reusable.upload_file(
        bucket_name, test_data_path=TEST_DATA_PATH)
    uploaded_file = uploaded_file_info["name"]
    log.info(f"Uploaded file {uploaded_file} to bucket {bucket_name}")

    # Delete file from bucket
    s3cmd_reusable.delete_file(bucket_name, uploaded_file)
    log.info(f"Deleted file {uploaded_file} from bucket {bucket_name}")

    # Delete bucket
    s3cmd_reusable.delete_bucket(bucket_name)
    log.info(f"Bucket {bucket_name} deleted")

    # check for any crashes during the execution
    crash_info = reusable.check_for_crash()
    if crash_info:
        raise TestExecError("ceph daemon crash found!")
Ejemplo n.º 9
0
    def verify_io(self):
        """
            This function to verify the data of buckets owned by a user

            Data verification happens to all the buckets of a particular user for both versioned and normal buckets
            Parameters:

            Returns:

        """
        log.info('***************Starting Verification*****************')
        data = self.file_op.get_data()
        users = data['users']
        for each_user in users:
            log.info('verifying data for the user: \n')
            log.info('user_id: %s' % each_user['user_id'])
            log.info('access_key: %s' % each_user['access_key'])
            log.info('secret_key: %s' % each_user['secret_key'])
            conn = boto3.resource(
                's3',
                aws_access_key_id=each_user['access_key'],
                aws_secret_access_key=each_user['secret_key'],
                endpoint_url='http://%s:%s' % (socket.gethostbyname(
                    socket.gethostname()), int(utils.get_radosgw_port_no())),
                use_ssl=False)
            for each_bucket in each_user['bucket']:
                log.info('verifying data for bucket: %s' % each_bucket['name'])
                bucket_from_s3 = conn.Bucket(each_bucket['name'])
                curr_versioning_status = each_bucket['curr_versioning_status']
                log.info('curr_versioning_status: %s' % curr_versioning_status)
                if not each_bucket['keys']:
                    log.info('keys are not created')
                else:
                    no_of_keys = len(each_bucket['keys'])
                    log.info('no_of_keys: %s' % no_of_keys)
                    for each_key in each_bucket['keys']:
                        versioned_keys = len(each_key['versioning_info'])
                        log.info('versioned_keys: %s' % versioned_keys)
                        if not each_key['versioning_info']:
                            log.info('not versioned key')
                            verify_key(each_key, bucket_from_s3)
                        else:
                            log.info('versioned key')
                            verify_key_with_version(each_key, bucket_from_s3)
        log.info('verification of data completed')
Ejemplo n.º 10
0
    def __init__(self, user_info, **extra_kwargs):
        self.access_key = user_info['access_key']
        self.secret_key = user_info['secret_key']
        self.hostname = socket.gethostname()
        self.ip = socket.gethostbyname(self.hostname)
        self.ssl = extra_kwargs.get('ssl', False)
        self.port = utils.get_radosgw_port_no()
        self.endpoint_url = 'https://{}:{}'.format(self.ip, self.port) if self.ssl \
                                else 'http://{}:{}'.format(self.ip, self.port)
        self.is_secure = False
        self.user_id = user_info['user_id']

        log.info('access_key: %s' % self.access_key)
        log.info('secret_key: %s' % self.secret_key)
        log.info('hostname: %s' % self.hostname)
        log.info('port: %s' % self.port)
        log.info('user_id: %s' % self.user_id)
        log.info('endpoint url: %s' % self.endpoint_url)
        log.info('ssl: %s' % self.ssl)
Ejemplo n.º 11
0
def test_exec(config):

    io_info_initialize = IOInfoInitialize()
    basic_io_structure = BasicIOInfoStructure()
    io_info_initialize.initialize(basic_io_structure.initial())

    umgmt = UserMgmt()

    host, ip = utils.get_hostname_ip()
    port = utils.get_radosgw_port_no()
    hostname = str(ip) + ":" + str(port)
    log.info(hostname)

    # preparing data
    admin_api_user = "******" + randomString()
    log.info(admin_api_user)
    user_info = umgmt.create_rest_admin_user(user_id=admin_api_user,
                                             displayname=admin_api_user)

    rgw = RGWAdmin(access_key=user_info['access_key'],
                   secret_key=user_info['secret_key'],
                   server=hostname,
                   secure=False,
                   verify=False)

    api_user = "******" + randomString()
    log.info(api_user)
    for uc in range(config.user_count):
        #Create User
        data = rgw.create_user(uid=api_user,
                               display_name=api_user,
                               email=api_user + '@abc.xyz')
        log.info("User created successfully")
        log.info(data)
        log.info('verification starts')
        op = utils.exec_shell_cmd("radosgw-admin user info --uid %s" %
                                  api_user)
        json_doc = json.loads(op)
        log.info(json_doc)
        v = verify_user(data, json_doc)
        if v is False:
            test_info.failed_status('test failed')
            sys.exit(1)
        log.info("Verification for create operation completed")

        #Update User
        data = rgw.modify_user(uid=api_user,
                               display_name=api_user + "_11",
                               email=api_user + '*****@*****.**')
        log.info("User Updated successfully")
        log.info(data)
        log.info('verification starts')
        op = utils.exec_shell_cmd("radosgw-admin user info --uid %s" %
                                  api_user)
        json_doc = json.loads(op)
        log.info(json_doc)
        v = verify_user(data, json_doc)
        if v is False:
            test_info.failed_status('test failed')
            sys.exit(1)
        log.info("Verification for Update operation completed")

        #delete User
        data = rgw.remove_user(uid=api_user, purge_data=False)
        log.info(data)
        log.info("User removed")
        op = utils.exec_shell_cmd("radosgw-admin user list")
        json_doc = json.loads(op)
        if api_user in json_doc:
            test_info.failed_status('test failed')
            sys.exit(1)
        log.info("Verification for Delete operation completed")
    # check for any crashes during the execution
    crash_info = reusable.check_for_crash()
    if crash_info:
        raise TestExecError("ceph daemon crash found!")
Ejemplo n.º 12
0
 def __init__(self, user_info):
     self.secret_key = user_info['key']
     self.hostname = socket.gethostname()
     self.port = int(utils.get_radosgw_port_no())
     self.is_secure = False
     self.user_id = user_info['user_id']