Esempio n. 1
0
    def __get_pool_rbd_id(self):
        rbd_list = []
        pool_id = test_utils.get_pool_id(self.env, self.params)
        if self.params.get("rbd_count"):
            rbd_count = int(self.params.get("rbd_count"))
            for i in range(rbd_count):
                rbd_id = test_utils.create_rbd(pool_id=pool_id, params=self.params)
                rbd_list.append(str(rbd_id))
        else:
            rbd_id = test_utils.create_rbd(pool_id=pool_id, params=self.params)
            rbd_list.append(str(rbd_id))

        return pool_id, rbd_list
Esempio n. 2
0
 def test_start_rbtask(self):
     LOG.info('cluster_id %s' % self.params.get('cluster_id'))
     rbd_id = test_utils.create_rbd(self.pool_id, self.params)
     body = {'rbd_id': rbd_id}
     self.env['rbtask_rbd_id'] = rbd_id
     resp = self.client.start_rbtask(**body)
     time.sleep(10)
     body = resp.body
     if not len(body):
         raise exceptions.TestError('Failed to start rbtask!')
     self.env['rbtask_id'] = body.get('id')
     self.env['remote_timestamp'] = body['properties']['timestamp']
 def test(self):
     # Create rbd in the pool
     self.rbd_id = test_utils.create_rbd(self.pool_id, self.params)
     if self.rbd_id == None:
         raise exceptions.TestFail("rbd is not existed")
     else:
         LOG.info("RBD id is %d" % self.rbd_id)
         # Create iscsi
         self.iscsi_target_id = self._create_iscsi_target()
         time.sleep(1)
         target_multipath = len(self.iscsi_target_hostip)
         if target_multipath <= 2:
             raise exceptions.TestFail("Multipath is %d" % target_multipath)
         # Bind iscsi to rbd
         self.lun_id = self._create_iscsi_lun(self.iscsi_target_id,
                                              self.rbd_id)
         time.sleep(1)
         self.iscsi_actions(self.control_server_ip, self.control_username,
                            self.control_password, self.initiator_ip,
                            self.initiator_username,
                            self.initiator_password, self.target_ip)
Esempio n. 4
0
    def test_create(self):
        snapshot_group_body_list = []
        snap_name = 'cloudtest_' + utils_misc.generate_random_string(6)
        for i in range(self.pool_count):
            pool_id = test_utils.create_pool(self.params)
            self.env['pool_id_%s' % i] = pool_id
            for j in range(self.rbd_count_of_per_pool):
                rbd_id = test_utils.create_rbd(pool_id=pool_id,
                                               params=self.params)
                self.env['rbd_id_%s_%s' % (i, j)] = rbd_id
                snapshot_group_body = {
                    "pool_id": pool_id,
                    "rbd_id": rbd_id,
                    "snap_name": snap_name
                }
                snapshot_group_body_list.append(snapshot_group_body)

        resp = self.client.create(snapshot_group_body_list)
        body = resp.body
        self.env['snapshot_group_id'] = body.get('id')
        self.env['snapshot_group_name'] = body.get('name')
        LOG.info("Create snapshot_group successfully: %s" % body)
Esempio n. 5
0
    def setup(self):
        """
        Set up before executing test
        """
        if self.env.get('cluster'):
            self.cluster_id = self.env.get('cluster')
        elif self.params.get('cluster_id'):
            self.cluster_id = int(self.params.get('cluster_id'))
        else:
            raise exceptions.TestSetupFail(
                'Please set cluster_id in config first')

        self.pool_id = test_utils.get_pool_id(self.env, self.params)
        if self.env.get('snapshot_rbd'):
            self.rbd_id = self.env.get('snapshot_rbd')
        else:
            self.rbd_id = test_utils.create_rbd(self.pool_id, self.params)
            LOG.info("rbd_id is %s" % self.rbd_id)
            self.env['snapshot_rbd'] = self.rbd_id

        if self.params.get('snapshots_id'):
            self.snapshot_id = self.params.get('snapshots_id')
Esempio n. 6
0
    def setup(self):
        """
        Set up before executing test
        """
        if 'cluster' in self.env:
            self.cluster_id = self.env['cluster']
        elif self.params.get('cluster_id'):
            self.cluster_id = self.params.get('cluster_id')
        self.pools_id = test_utils.get_pool_id(self.env, self.params)
        self.params['pool_id'] = self.pools_id

        if 'rbds' in self.env:
            self.rbds_id = self.env['rbds']
        else:
            self.rbds_id = test_utils.create_rbd(self.pools_id, self.params)
            self.env['rbds'] = self.rbds_id
        self.params['rbds_id'] = self.rbds_id

        for k, v in self.params.items():
            if 'rest_arg_' in k:
                new_key = k.split('rest_arg_')[1]
                self.body[new_key] = v

        self.client = QosClient(self.params)
Esempio n. 7
0
    def _lun_ops(self, ops):
        target_id = self.env.get('iscsi_target')['target_id']

        self.rbd_pool_id = test_utils.get_pool_id(self.env, self.params)

        if self.params.get('rbd_id'):
            self.rbd_id = self.params.get('rbd_id')
        else:
            self.rbd_id = test_utils.create_rbd(self.rbd_pool_id, self.params)

        if ops in 'add':
            body = {
                'target_id': target_id,
                'pool_id': self.rbd_pool_id,
                'rbd_id': self.rbd_id
            }
            resp = self.client.add_lun(**body)
            self.env['iscsi_target_lun'] = resp.body
            return resp

        elif ops in 'delete':
            body = {'target_id': target_id, 'lun_id': self.lun_id}

            return self.client.delete_lun(**body)
Esempio n. 8
0
 def __get_rbd_id(self):
     pool_id = self.__get_pool_id()
     rbd_id = test_utils.create_rbd(pool_id, self.params)
     return rbd_id
Esempio n. 9
0
    def test_iscsi_chap(self):
        # Create rbd in the pool
        self.rbd_id = test_utils.create_rbd(self.pool_id, self.params)

        # Create iscsi
        self.target_id = self._create_iscsi_target()
        target_name = self._query_specified_target(self.target_id)

        if target_name not in self.iscsi_target_name:
            LOG.info("Target name %s is not expected. "
                     "The target name created is %s" %
                     (target_name, self.iscsi_target_name))

        # Get the first target ip via target id
        self.target_ip = test_utils.get_specified_targetip(
            self.params, self.target_id, 0)

        # Bind iscsi to rbd
        self.lun_id = self._create_iscsi_lun(self.target_id, self.rbd_id)
        self._get_lun_info()

        # Create count1 and count2(single way chap)
        self.account_group_id1 = self._create_account_group("two")
        self.account_group_id2 = self._create_account_group("two")

        self.username1, self.password1, self.username_out1, self.password_out1\
            = self._query_account_group(self.account_group_id1)
        LOG.info("username1: %s, password1: %s, username_out1: %s, "
                 "password_out1: %s" %
                 (self.username1, self.password1, self.username_out1,
                  self.password_out1))
        self.username2, self.password2, self.username_out2, self.password_out2\
            = self._query_account_group(self.account_group_id2)
        LOG.info("username2: %s, password2: %s, username_out2: %s, "
                 "password_out2: %s" %
                 (self.username2, self.password2, self.username_out2,
                  self.password_out2))

        self._bind_account_operation('bind', self.account_group_id2,
                                     self.target_id)

        self._delete_account_group(self.account_group_id1)

        # There are bugs about iscsi modify function
        '''account_name_out = data_factory.generate_random_string(
            6)
        account_pass_out = data_factory.generate_random_string(6)
        self._modify_account_group(self.account_group_id2, self.username2,
                                   self.password2, account_name_out,
                                   account_pass_out)
        self.username2, self.password2, self.username_out2, self.password_out2 \
            = self._query_account_group(self.account_group_id2)
        LOG.info("username2: %s, password2: %s, username_out2: %s, "
                 "password_out2: %s" % (self.username2, self.password2,
                 self.username_out2, self.password_out2))'''

        LOG.info("old_config_list is %s" % self.old_config_list)

        self._verify_login_iscsi_with_account(self.username2, self.password2,
                                              self.username_out2,
                                              self.password_out2,
                                              self.old_config_list, True)

        self.password_out2 = 'test'
        self._verify_login_iscsi_with_account(self.username2, self.password2,
                                              self.username_out2,
                                              self.password_out2,
                                              self.old_config_list, False)
 def test_rbd_remote_backup(self):
     """
     This test basically performs following steps:
         1. create rbd in testpool
         2. format disk
         3. create remote backup for this rbd(e.g.record1)
         4. write data to this rbd via ISCSI, include 1->11 steps
         5. create remote backup for this rbd(e.g.record2)
         6. recover rbd from record1
         7. repeat step3: sub-step 2)3)4)5)7)
         8. check testfile.txt does not exist
         9. do recover rbd from record2
         10. check testfile.txt exists
     """
     mount_point = self.params.get('mount_point', '/mnt')
     file_name = self.params.get('file_name', 'testfile.txt')
     # step1 create rbd in testpool
     self.rbd_id = test_utils.create_rbd(self.pool_id, self.params)
     LOG.info("Create rbd %s in pool %s" % (self.rbd_id, self.pool_id))
     # step2 format disk
     self._create_and_bind_ISCSI_to_rbd(self.rbd_id)
     time.sleep(60)
     need_mk = True
     create_data = False
     find = test_utils.operate_iscsi(self.control_server_ip,
                                     self.control_username,
                                     self.control_password,
                                     self.initiator_ip,
                                     self.initiator_username,
                                     self.initiator_password,
                                     self.iscsi_target_name,
                                     self.initiator_ip, mount_point,
                                     file_name, need_mk, create_data)
     self._verify_file_exist(file_name, mount_point, find, False)
     self._delete_iscsi_lun(self.target_id, self.lun_id)
     time.sleep(60)
     # step3 create remote backup for this rbd
     rbtask_id_1 = self._start_rbtask(self.rbd_id)
     rb_record_1 = self._verify_task_successfully(rbtask_id_1, 'backed_up')
     # step4 write data to this rbd via ISCSI
     self.lun_id = self._create_iscsi_lun(self.target_id, self.rbd_id)
     time.sleep(60)
     need_mk = False
     create_data = True
     # step4: sub-step 2)-10)
     find = test_utils.operate_iscsi(self.control_server_ip,
                                     self.control_username,
                                     self.control_password,
                                     self.initiator_ip,
                                     self.initiator_username,
                                     self.initiator_password,
                                     self.iscsi_target_name,
                                     self.initiator_ip, mount_point,
                                     file_name, need_mk, create_data)
     self._verify_file_exist(file_name, mount_point, find, True)
     # step4: sub-step 11)
     self._delete_iscsi_lun(self.target_id, self.lun_id)
     time.sleep(60)
     # step 5 create remote backup for this rbd
     rbtask_id_2 = self._start_rbtask(self.rbd_id)
     rb_record_2 = self._verify_task_successfully(rbtask_id_2, 'backed_up')
     # step 6 recover rbd from rb_record_1
     restore_id = self._start_restore(self.rbd_id, rb_record_1)
     self._verify_task_successfully(restore_id, 'restored')
     # step 7
     self.lun_id = self._create_iscsi_lun(self.target_id, self.rbd_id)
     time.sleep(60)
     need_mk = False
     create_data = False
     find = test_utils.operate_iscsi(self.control_server_ip,
                                     self.control_username,
                                     self.control_password,
                                     self.initiator_ip,
                                     self.initiator_username,
                                     self.initiator_password,
                                     self.iscsi_target_name,
                                     self.initiator_ip, mount_point,
                                     file_name, need_mk, create_data)
     # step 8 check testfile.txt does not exist
     self._verify_file_exist(file_name, mount_point, find, False)
     self._delete_iscsi_lun(self.target_id, self.lun_id)
     time.sleep(60)
     # step 9 do recover rbd from record2
     restore_id = self._start_restore(self.rbd_id, rb_record_2)
     self._verify_task_successfully(restore_id, 'restored')
     # step 10 verify testfile.txt exists
     self.lun_id = self._create_iscsi_lun(self.target_id, self.rbd_id)
     time.sleep(60)
     need_mk = False
     create_data = False
     find = test_utils.operate_iscsi(self.control_server_ip,
                                     self.control_username,
                                     self.control_password,
                                     self.initiator_ip,
                                     self.initiator_username,
                                     self.initiator_password,
                                     self.iscsi_target_name,
                                     self.initiator_ip, mount_point,
                                     file_name, need_mk, create_data)
     self._verify_file_exist(file_name, mount_point, find, True)
     self._delete_iscsi_lun(self.target_id, self.lun_id)
Esempio n. 11
0
    def setup(self):
        """
        Set up before executing test
        1. Cluster is deployed
        2. 5 100G rbd/image are created, and sequence writen
        3. Zabbix server and account is configured
        4. More hosts are available for adding
        """
        # cluster is deployed
        if 'cluster' in self.env:
            self.cluster_id = self.env['cluster']
        elif self.params.get('cluster_id'):
            self.cluster_id = self.params.get('cluster_id')
        else:
            raise exceptions.TestSetupFail(
                "Please set cluster_id in config first")

        self.pool_response = test_utils.create_pool(self.params, flag=True)
        self.pool_name = self.pool_response.get('name')
        self.pool_id = self.pool_response.get('id')

        # 5 100G rbd/image are created, and sequence writen
        self._copy_fio_package_to_host()
        self.params['capacity'] = 1024 * 1024 * 1024 * 100
        rw = self.params.get('fio_rw', 'write')
        bs = self.params.get('fio_bs', '1M')
        iodepth = self.params.get('fio_iodepth', 128)
        size = self.params.get('fio_write_size', '100G')
        flag = True
        for i in range(0, 5):
            rbd_name = 'cloudtest_' + utils_misc.generate_random_string(6)
            self.params['rbd_name'] = rbd_name
            rbd_id = test_utils.create_rbd(self.pool_id, self.params)
            LOG.info("Create rbd %s in pool %s" % (rbd_name, self.pool_id))
            self.rbds_id.append(rbd_id)
            self._write_rbd(rbd_name=rbd_name,
                            rw=rw,
                            bs=bs,
                            iodepth=iodepth,
                            size=size,
                            flag=flag)
            flag = False

        zabbix_ip = remote.get_zabbix_server_ip(self.mid_host_ip,
                                                self.mid_host_user,
                                                self.mid_host_password)
        self.params['rest_arg_zabbix_server_ip'] = zabbix_ip
        self.params['rest_arg_ntp_server_ip'] = zabbix_ip
        # Zabbix server and account is configured
        for k, v in self.params.items():
            if 'rest_arg_' in k:
                new_key = k.split('rest_arg_')[1]
                self.body[new_key] = v
        self._set_cluster_conf()
        zabbix_group_id = self.zabbix_client.get_host_group("cloudCeph")
        LOG.info("The cloudCeph group id in zabbix is %s" % zabbix_group_id)
        if zabbix_group_id:
            host_id = self.zabbix_client.get_host_id_by_group_id(
                zabbix_group_id)
            LOG.info("Monitored host id in zabbix is %s" % host_id)
        if host_id:
            self.recover_item_id = self.zabbix_client.get_item_id(
                host_id, "ceph.cluster.recovering_bytes")
            LOG.info(
                "The ceph.cluster.recovering_bytes item id in zabbix is %s" %
                self.recover_item_id)
        else:
            raise exceptions.TestSetupFail(
                "Zabbix server error, cannot get host id!")
        if self.recover_item_id is None:
            exceptions.TestSetupFail(
                "Cannot get the value of ceph.cluster.recovering_bytes!")
Esempio n. 12
0
    def test(self):
        # Create rbd in the pool
        self.rbd_id = test_utils.create_rbd(self.pool_id, self.params)

        # Create iscsi
        self.target_id = self._create_iscsi_target()
        # Bind iscsi to rbd
        self.lun_id = self._create_iscsi_lun(self.target_id, self.rbd_id)

        mount_point = self.params.get('mount_point', '/mnt')
        file_name = self.params.get('file_name', 'testfile.txt')
        self.target_ip = test_utils.get_specified_targetip(
            self.params, self.target_id, 0)
        need_mk = True
        create_data = True
        find = test_utils.operate_iscsi(
            self.control_server_ip, self.control_username,
            self.control_password, self.initiator_ip, self.initiator_username,
            self.initiator_password, self.iscsi_target_name, self.target_ip,
            mount_point, file_name, need_mk, create_data)
        if find:
            LOG.info("Find %s under %s!" % (file_name, mount_point))
        else:
            LOG.error("%s not found under %s" % (file_name, mount_point))
        # Unbind iscsi from the rbd
        self._delete_iscsi_lun(self.target_id, self.lun_id)

        time.sleep(30)
        # Create snapshot with the rbd
        self.snapshot_id = self._create_snapshot(self.rbd_id)
        need_mk = False
        create_data = True
        file_name_2 = self.params.get('file_name_2', 'testfile2.txt')
        find = test_utils.operate_iscsi(
            self.control_server_ip, self.control_username,
            self.control_password, self.initiator_ip, self.initiator_username,
            self.initiator_password, self.iscsi_target_name, self.target_ip,
            mount_point, file_name_2, need_mk, create_data)
        if find:
            LOG.info("Find %s under %s!" % (file_name_2, mount_point))
        else:
            LOG.error("%s not found under %s" % (file_name_2, mount_point))

        time.sleep(30)
        # Rollback  snapshot to this rbd
        self._snapshot_rollback(self.rbd_id, self.snapshot_id)

        # Bind iscsi to the rbd
        self.lun_id = self._create_iscsi_lun(self.target_id, self.rbd_id)

        time.sleep(30)
        need_mk = False
        create_data = False
        find = test_utils.operate_iscsi(
            self.control_server_ip, self.control_username,
            self.control_password, self.initiator_ip, self.initiator_username,
            self.initiator_password, self.iscsi_target_name, self.target_ip,
            mount_point, file_name_2, need_mk, create_data)
        if find:
            LOG.error("Find %s under %s!" % (file_name_2, mount_point))
        else:
            LOG.info("%s not found under %s is expected!" %
                     (file_name_2, mount_point))