def run(**kw): log.info("Running test") ceph_nodes = kw.get("ceph_nodes") test_data = kw.get("test_data") iscsi_util = IscsiUtils(ceph_nodes) iscsi_initiator = iscsi_util.get_iscsi_initiator_linux() initiatorname = iscsi_util.get_initiatorname() iscsi_util.write_multipath(iscsi_initiator) # to be chnage later iscsi_util.write_chap(initiatorname, iscsi_initiator) no_of_luns = test_data["no_of_luns"] device_list = iscsi_util.get_devicelist_luns(no_of_luns) if device_list == 1: return 1 iscsi_util.create_directory_with_io(device_list, iscsi_initiator, io_size="2G") rc = iscsi_util.do_ios(iscsi_initiator, device_list) if iscsi_util.check_mnted_disks(iscsi_initiator, device_list) == 1: return 1 iscsi_util.umount_directory(device_list, iscsi_initiator) iscsi_util.dissconect_linux_initiator(iscsi_initiator) if rc != 0: log.error("fio test failed") return 1 else: return 0
def run(**kw): log.info("Running test") ceph_nodes = kw.get("ceph_nodes") test_data = kw.get("test_data") iscsi_util = IscsiUtils(ceph_nodes) iscsi_initiators = iscsi_util.get_iscsi_initiator_linux() initiatorname = iscsi_util.get_initiatorname() iscsi_util.write_multipath(iscsi_initiators) iscsi_util.write_chap(initiatorname, iscsi_initiators) no_of_luns = test_data["no_of_luns"] rc = [] device_list = iscsi_util.get_devicelist_luns(no_of_luns) iscsi_util.create_directory_with_io(device_list, iscsi_initiators, io_size="1G") with parallel() as p: p.spawn(iscsi_util.do_ios, iscsi_initiators, device_list) p.spawn(do_failover, iscsi_initiators, device_list, ceph_nodes) for op in p: rc.append(op) print("return " + str(rc)) rc = set(rc) if len(rc) == 1: print(rc) iscsi_util.umount_directory(device_list, iscsi_initiators) iscsi_initiators.exec_command( sudo=True, cmd="iscsiadm -m node -T iqn.2003-01.com.redhat.iscsi-" "gw:ceph-igw -u", long_running=True, ) iscsi_initiators.exec_command(sudo=True, cmd="systemctl stop multipathd", long_running=True) return 0 else: print(rc) return 1
def run(**kw): log.info("Running test") ceph_nodes = kw.get("ceph_nodes") test_data = kw.get("test_data") iscsi_util = IscsiUtils(ceph_nodes) iscsi_initiators = iscsi_util.get_iscsi_initiator_linux() initiatorname = iscsi_util.get_initiatorname() iscsi_util.write_multipath(iscsi_initiators) iscsi_util.write_chap(initiatorname, iscsi_initiators) no_of_luns = test_data["no_of_luns"] rc = [] device_list = iscsi_util.get_devicelist_luns(no_of_luns) iscsi_util.create_directory_with_io(device_list, iscsi_initiators, io_size="1G") with parallel() as p: p.spawn(iscsi_util.do_ios, iscsi_initiators, device_list) p.spawn(do_failover, iscsi_initiators, device_list, ceph_nodes) for op in p: rc.append(op) uuid = [] iscsi_initiators.exec_command(sudo=True, cmd="cp /etc/fstab /etc/fstab.backup") out, err = iscsi_initiators.exec_command(sudo=True, cmd="cat /etc/fstab") output = out.read().decode() fstab = output.rstrip("\n") for device in device_list: out, err = iscsi_initiators.exec_command( sudo=True, cmd="blkid /dev/mapper/mpa" + device + "" " -s UUID -o value", long_running=True, ) output = out.rstrip("\n") uuid.append(output) for i in range(no_of_luns): temp = ("\nUUID=" + uuid[i] + "\t/mnt/" + device_list[i] + "/\text4\t_netdev\t0 0") fstab += temp fstab_file = iscsi_initiators.remote_file(sudo=True, file_name="/etc/fstab", file_mode="w") fstab_file.write(fstab) fstab_file.flush() mnted_disks = list_mnted_disks(iscsi_initiators) iscsi_initiators.exec_command(sudo=True, cmd="reboot", check_ec=False) sleep(200) iscsi_initiators.reconnect() iscsi_util.do_iptables_flush() mnted_disks_after_reboot = list_mnted_disks(iscsi_initiators) log.info("i/o exit code: {}, failover exit code{}".format(rc[0], rc[1])) log.info("disks before reboot:\n" + str(mnted_disks)) log.info("disks after reboot:\n" + str(mnted_disks_after_reboot)) log.info("number number of disks before reboot:" + str(len(mnted_disks))) log.info("number number of disks after reboot:" + str(len(mnted_disks_after_reboot))) if sum(rc) == 0 and mnted_disks_after_reboot == mnted_disks: iscsi_util.umount_directory(device_list, iscsi_initiators) iscsi_util.dissconect_linux_initiator(iscsi_initiators) iscsi_initiators.exec_command(sudo=True, cmd="mv /etc/fstab.backup /etc/fstab") return 0 else: return 1