Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scsi_device: add new case of hostdev device for scsi commands testing #5986

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

meinaLi
Copy link
Contributor

@meinaLi meinaLi commented Nov 8, 2024

Automate case:
VIRT-302167 - [Host device assignment][SCSI] SCSI command passthrough test for hostdev scsi device

@meinaLi meinaLi marked this pull request as draft November 8, 2024 10:18
@meinaLi meinaLi force-pushed the hostdev_device branch 2 times, most recently from ca52f4b to 8a24ae2 Compare November 12, 2024 02:56
@meinaLi
Copy link
Contributor Author

meinaLi commented Nov 12, 2024

# avocado run --vt-type libvirt --test-runner=runner --vt-machine-type q35 scsi_device.scsi_command_test.with_hostdev.guest_multipath
JOB ID     : 11722ca97ebee116a07bcf4af0249d7c6fc095c9
JOB LOG    : /var/lib/avocado/job-results/job-2024-11-11T21.49-11722ca/job.log
 (1/1) type_specific.io-github-autotest-libvirt.scsi_device.scsi_command_test.with_hostdev.guest_multipath: PASS (64.18 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /var/lib/avocado/job-results/job-2024-11-11T21.49-11722ca/results.html
JOB TIME   : 64.83 s

@meinaLi meinaLi marked this pull request as ready for review November 12, 2024 06:34
@meinaLi
Copy link
Contributor Author

meinaLi commented Dec 16, 2024

@chunfuwen @smitterl This case is in scsi device plan. The test scenarios is coming from customer. Could you help review it when you have time? Thanks.

script_path = params.get("script_path")
vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name)
backup_xml = vmxml.copy()
get_scsi_cmd = "lsscsi | grep LIO | wc -l"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of using pipes in bash commands because in case the output is not as expected, it's harder to debug.

How about you do the following?

def get_scsi_count(...):
...
    status, output = cmd_status_output("lsscsi")
    scsi_lio_count = len(re.findall("LIO", output))
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your suggestion. I moved it to a function now.

"EOF"
).format(script_path, mpath_dev)
vm_session.cmd(script_in_guest)
run_script_in_guest = "/bin/bash %s" % script_path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use "/bin/bash" you do not need the shebang "#!/bin/bash".
In any case, why do you create a bash script and then execute those commands, instead of something like the following?

for cmd in [
    "mpathpersist --out ...",
    "mpathpersist --out ...",
    ...
    "mpathpersist --out --register ..."
    ]:
    s, o = vm_session.cmd_status_output(cmd)
    if s:
        test.error(f"Error running '{cmd}' in VM: '{o}'")

Again, I think it might be easier later to debug any issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Using list but not script can be more easy to debug in our test. So I've changed it.

if vm.is_alive():
vm.destroy()
backup_xml.sync()
# Delete the first iscsi target
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, the comments are unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

def create_second_target_by_iscsi(emulated_image, second_target):
"""
This test needs to have two LUNs with same image but not same target name.
The current libvirt.setup_or_cleanup_iscsi() can't cover it.
Copy link
Contributor

@smitterl smitterl Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like duplicated code. Couldn't you use iscsi.Iscsi.create_iSCSI(second_params) instead? It allows for setting the target name, second_params['target']='tgp1'.

This is what setup_or_cleanup_iscsi does, too: https://github.com/avocado-framework/avocado-vt/blob/master/virttest/utils_test/libvirt.py#L587

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered this method before. But in this case we want to use a same backend storage to create two different iscsi target. It can't be created in the above function.

Automate case:
VIRT-302167 - [Host device assignment][SCSI] SCSI command passthrough test for hostdev scsi device

Signed-off-by: Meina Li <[email protected]>
@meinaLi meinaLi requested a review from smitterl January 6, 2025 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants