def teardown(self): """ Some clean up work will be done here. """ if self.fio_working_path is not None: # delete files cmd_mid = 'rm -rf %s' % (os.path.join(self.dstpath, self.fio_version)) cmd1 = 'pkill fio || true; ' cmd2 = 'rm -rf %s %s' % ( os.path.join(self.dstpath, self.fio_version), os.path.join(self.dstpath, self.fio_working_path)) cmd = cmd1 + cmd2 remote.run_cmd_between_remotes( mid_host_ip=self.mid_host_ip, mid_host_user=self.mid_host_user, mid_host_password=self.mid_host_password, end_host_ip=self.end_host_ip, end_host_user=self.end_host_user, end_host_password=self.end_host_password, cmd=cmd, cmd_mid=cmd_mid) if self.host_group_pool_id and self.host_group_rbd_id: self.rbd_client.delete_rbd(self.host_group_pool_id, self.host_group_rbd_id) if self.host_group_pool_id and self.rack_group_rbd_id: self.rbd_client.delete_rbd(self.host_group_pool_id, self.rack_group_rbd_id) if self.host_group_pool_id: self.pool_client.delete_pool(self.host_group_pool_id) if self.rack_group_pool_id: self.pool_client.delete_pool(self.rack_group_pool_id)
def teardown(self): if self.fio_working_path is not None: # delete files cmd_mid = 'rm -rf %s' % (os.path.join(self.dstpath, self.fio_version)) cmd1 = 'pkill fio || true; ' cmd2 = 'rm -rf %s %s' % \ (os.path.join(self.dstpath, self.fio_version), os.path.join(self.dstpath, self.fio_working_path)) cmd = cmd1 + cmd2 remote.run_cmd_between_remotes( mid_host_ip=self.mid_host_ip, mid_host_user=self.mid_host_user, mid_host_password=self.mid_host_password, end_host_ip=self.end_host_ip, end_host_user=self.end_host_user, end_host_password=self.end_host_password, cmd=cmd, cmd_mid=cmd_mid) # Delete resource for scenario case14 if self.rbd_id is not None and self.target_pool is not None: try: test_utils.delete_rbd(self.target_pool, self.rbd_id, self.params) except exceptions.UnexpectedResponseCode, e: pass
def teardown(self): # delete files cmd_mid = 'rm -rf %s' % (os.path.join(self.dstpath, self.fio_version)) cmd1 = 'pkill fio || true; ' cmd2 = 'rm -rf %s %s' % (os.path.join(self.dstpath, self.fio_version), os.path.join(self.dstpath, self.fio_working_path)) cmd = cmd1 + cmd2 remote.run_cmd_between_remotes( mid_host_ip=self.mid_host_ip, mid_host_user=self.mid_host_user, mid_host_password=self.mid_host_password, end_host_ip=self.end_host_ip, end_host_user=self.end_host_user, end_host_password=self.end_host_passwprd, cmd=cmd, cmd_mid=cmd_mid) LOG.info("added server name is %s" % self.server_name) if self.server_name is not None: self.server_id = test_utils.get_server_id_by_name( self.params, self.server_name) LOG.info("server id is %s" % self.server_id) if self.server_id is not None: LOG.info('Begin to sleep 60s ...') time.sleep(60) test_utils.delete_osd(self.server_id, self.params) test_utils.del_server(self.server_client, self.server_id)
def teardown(self): if self.fio_working_path is not None: # delete files cmd_mid = 'rm -rf %s' % (os.path.join(self.dstpath, self.fio_version)) cmd1 = 'pkill fio || true; ' cmd2 = 'rm -rf %s %s' % ( os.path.join(self.dstpath, self.fio_version), os.path.join(self.dstpath, self.fio_working_path)) cmd = cmd1 + cmd2 remote.run_cmd_between_remotes( mid_host_ip=self.mid_host_ip, mid_host_user=self.mid_host_user, mid_host_password=self.mid_host_password, end_host_ip=self.end_host_ip, end_host_user=self.end_host_user, end_host_password=self.end_host_passwprd, cmd=cmd, cmd_mid=cmd_mid) time.sleep(240) if self.rbd_id is not None: try: test_utils.delete_rbd(self.pool_id, self.rbd_id, self.params) except exceptions.UnexpectedResponseCode, e: pass
def __check_cluster_status(self): time.sleep(400) stdout_msg = remote.run_cmd_between_remotes( mid_host_ip=self.mid_host_ip, mid_host_user=self.mid_host_user, mid_host_password=self.mid_host_password, end_host_ip=self.end_host_ip, end_host_user=self.end_host_user, end_host_password=self.end_host_passwprd, cmd='ceph -s', timeout=1000) pat = 'health (.*)' result = re.findall(pat, stdout_msg) if len(result) > 0: if result[0] not in ('HEALTH_OK', 'HEALTH_WARN'): raise exceptions.TestFail('Cluster status must be HEALTH_OK, ' 'or HEALTH_WARN not %s' % result[0]) if 'HEALTH_WARN' in result[0]: pat = 'Monitor clock skew detected' war_msg = re.findall(pat, stdout_msg) if not len(war_msg): raise exceptions.TestFail( 'Cluster status must be HEALTH_OK, ' 'or HEALTH_WARN for clock skew detected') else: raise exceptions.TestFail('Msg data error, please check !') LOG.info('Cluster recovery successfully !')
def teardown(self): # delete files cmd_mid = 'rm -rf %s' % (os.path.join(self.dstpath, self.fio_version)) cmd1 = 'pkill fio || true; ' cmd2 = 'rm -rf %s %s' % (os.path.join(self.dstpath, self.fio_version), os.path.join(self.dstpath, self.fio_working_path)) cmd = cmd1 + cmd2 remote.run_cmd_between_remotes(mid_host_ip=self.mid_host_ip, mid_host_user=self.mid_host_user, mid_host_password =self.mid_host_password, end_host_ip=self.end_host_ip, end_host_user=self.end_host_user, end_host_password =self.end_host_password, cmd=cmd, cmd_mid=cmd_mid)
def __write_rbd(self, flag=False): cmd1 = 'cd %s;' % self.fio_working_path cmd2 = './fio -ioengine=rbd -clientname=admin ' cmd3 = '-pool=%s -rw=write -bs=1M -iodepth=128 -numjobs=1 -direct=1 ' % \ self.pool_name cmd4 = '-size=2M -group_reporting -rbdname=%s -name=mytest' % \ self.rbd_name cmd = cmd1 + cmd2 + cmd3 + cmd4 if flag: cmd = 'tar -xzvf %s;' % self.fio_version + cmd remote.run_cmd_between_remotes( mid_host_ip=self.mid_host_ip, mid_host_user=self.mid_host_user, mid_host_password=self.mid_host_password, end_host_ip=self.end_host_ip, end_host_user=self.end_host_user, end_host_password=self.end_host_passwprd, cmd=cmd, timeout=1000)
def __write_rbd(self, pool_name, rbd_name, flag=False): cmd1 = 'cd %s;' % self.fio_working_path cmd2 = './fio -ioengine=%s -clientname=%s ' % (self.ioengine, self.clientname) cmd3 = '-pool=%s -rw=%s -bs=%s -iodepth=%s -numjobs=%s -direct=%s ' % \ (pool_name, self.rw, self.bs, self.iodepth, self.numjobs, self.direct) cmd4 = '-size=%s -group_reporting -rbdname=%s -name=mytest' % \ (self.size, rbd_name) cmd = cmd1 + cmd2 + cmd3 + cmd4 if flag: cmd = 'tar -xzvf %s;' % self.fio_version + cmd remote.run_cmd_between_remotes( mid_host_ip=self.mid_host_ip, mid_host_user=self.mid_host_user, mid_host_password=self.mid_host_password, end_host_ip=self.end_host_ip, end_host_user=self.end_host_user, end_host_password=self.end_host_password, cmd=cmd, timeout=1000)
def _write_rbd(self, rbd_name, rw, bs, iodepth, size, flag=False): cmd1 = 'cd %s;' % self.fio_working_path cmd2 = './fio -ioengine=rbd -clientname=admin ' cmd3 = '-pool=%s -rw=%s -bs=%s -iodepth=%s -numjobs=1 -direct=1 ' % \ (self.pool_name, rw, bs, iodepth) cmd4 = '-size=%s -runtime=20 -group_reporting -rbdname=%s -name=mytest' % \ (size, rbd_name) cmd = cmd1 + cmd2 + cmd3 + cmd4 if flag: cmd = 'tar -xzvf %s;' % self.fio_version + cmd LOG.info("cmd = %s" % cmd) remote.run_cmd_between_remotes( mid_host_ip=self.mid_host_ip, mid_host_user=self.mid_host_user, mid_host_password=self.mid_host_password, end_host_ip=self.end_host_ip, end_host_user=self.end_host_user, end_host_password=self.end_host_password, cmd=cmd, timeout=1000)
def __check_service_status(self, cmd, pat, service_type, status=None): stdout_msg = remote.run_cmd_between_remotes( mid_host_ip=self.mid_host_ip, mid_host_user=self.mid_host_user, mid_host_password=self.mid_host_password, end_host_ip=self.end_host_ip, end_host_user=self.end_host_user, end_host_password=self.end_host_passwprd, cmd=cmd, timeout=1000) result = re.findall(pat, stdout_msg) if 'agent' in service_type: if len(result) != 0: if status in result[0]: return raise exceptions.TestFail('Agent status error !') else: if len(result) != 0: raise exceptions.TestFail('Ceph goes to recovery mode!')
def __write_rbd(self, rw, rw_type, rw_value, bs, iodepth, runtime, flag=False): """ Write rbd via fio :param rw: randread/read/randwrite/write/randrw/rw :param rw_type: rwmixread/None :param rw_value: rw_type value :param bs: :param iodepth: :param runtime: :param flag: True/False mains if need tar file :return: """ cmd1 = 'cd %s;' % self.fio_working_path cmd2 = './fio -ioengine=rbd -clientname=admin -pool=%s ' % \ self.pool_name if rw_type and rw_value: cmd3 = '-rw=%s -%s=%s -bs=%s -iodepth=%s -numjobs=1 -direct=1 ' % \ (rw, rw_type, rw_value, bs, iodepth) else: cmd3 = '-rw=%s -bs=%s -iodepth=%s -numjobs=1 -direct=1 ' % \ (rw, bs, iodepth) cmd4 = '-runtime=%s -group_reporting -rbdname=%s -name=mytest' % \ (runtime, self.rbd_name) cmd = cmd1 + cmd2 + cmd3 + cmd4 if flag: cmd = 'tar -xzvf %s;' % self.fio_version + cmd out_msg = remote.run_cmd_between_remotes( mid_host_ip=self.mid_host_ip, mid_host_user=self.mid_host_user, mid_host_password=self.mid_host_password, end_host_ip=self.end_host_ip, end_host_user=self.end_host_user, end_host_password=self.end_host_password, cmd=cmd, timeout=1000) return out_msg
def is_in_status(): stdout_msg = remote.run_cmd_between_remotes( mid_host_ip=self.mid_host_ip, mid_host_user=self.mid_host_user, mid_host_password=self.mid_host_password, end_host_ip=self.end_host_ip, end_host_user=self.end_host_user, end_host_password=self.end_host_passwprd, cmd='ceph -s', timeout=1000) pat = 'health (.*)' result = re.findall(pat, stdout_msg) if len(result) > 0: if result[0] not in ('HEALTH_OK', 'HEALTH_WARN'): return False if 'HEALTH_WARN' in result[0]: pat = 'Monitor clock skew detected' war_msg = re.findall(pat, stdout_msg) if not len(war_msg): return False else: raise exceptions.TestFail('Msg data error, please check !') return True
def __get_osd_capacity(self): """ Get osd capacity var ceph osd df. """ osd_dict = {} stdout_msg = remote.run_cmd_between_remotes( mid_host_ip=self.mid_host_ip, mid_host_user=self.mid_host_user, mid_host_password=self.mid_host_password, end_host_ip=self.end_host_ip, end_host_user=self.end_host_user, end_host_password=self.end_host_passwprd, cmd='ceph osd df', timeout=1000) stdout_msg = stdout_msg.strip() msg_list = stdout_msg.split('\n') for osd in self.osd_list: osd_id = osd.get('osdId') for msg in msg_list: msg = msg.strip() msg = msg.split() if msg[0].isdigit() and int(msg[0]) == osd_id: osd_dict[osd_id] = float(msg[6]) return osd_dict