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

Virtual disk: add 2 new datastore cases #6183

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

Conversation

meinaLi
Copy link
Contributor

@meinaLi meinaLi commented Feb 13, 2025

Automate two cases:
VIRT-303298 [virtual disks][dataStore] Hotplug/unplug disks with data files
VIRT-303297 [virtual_disks][dataStore] Start guest with disks that have data files

@meinaLi
Copy link
Contributor Author

meinaLi commented Feb 13, 2025

# avocado run --vt-type libvirt --vt-omit-data-loss --vt-machine-type q35 virtual_disks.datastore
JOB ID     : 4f0c394be5083bec9eb7de51e2b6b8db54b513c2
JOB LOG    : /var/log/avocado/job-results/job-2025-02-12T21.39-4f0c394/job.log
 (1/4) type_specific.io-github-autotest-libvirt.virtual_disks.datastore.with_file.start_vm: STARTED
 (1/4) type_specific.io-github-autotest-libvirt.virtual_disks.datastore.with_file.start_vm: PASS (51.71 s)
 (2/4) type_specific.io-github-autotest-libvirt.virtual_disks.datastore.with_file.hotplug_disk: STARTED
 (2/4) type_specific.io-github-autotest-libvirt.virtual_disks.datastore.with_file.hotplug_disk: PASS (55.80 s)
 (3/4) type_specific.io-github-autotest-libvirt.virtual_disks.datastore.with_block.start_vm: STARTED
 (3/4) type_specific.io-github-autotest-libvirt.virtual_disks.datastore.with_block.start_vm: PASS (74.12 s)
 (4/4) type_specific.io-github-autotest-libvirt.virtual_disks.datastore.with_block.hotplug_disk: STARTED
 (4/4) type_specific.io-github-autotest-libvirt.virtual_disks.datastore.with_block.hotplug_disk: PASS (72.37 s)
RESULTS    : PASS 4 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /var/log/avocado/job-results/job-2025-02-12T21.39-4f0c394/results.html
JOB TIME   : 262.71 s

if with_hotplug:
if not vm.is_alive():
vm.start()
_, new_image_path = disk_obj.prepare_disk_obj(disk_type, disk_dict, new_image_path="", extra=data_file_option)
Copy link
Contributor

Choose a reason for hiding this comment

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

line 51 to line 55 ,please put them into one small method to make code clean

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move to hotplug_disk().

if not vm.is_alive():
vm.start()
vm_session = vm.wait_for_login()
test.log.info("TEST_STEP: Check the disk dumpxml.")
Copy link
Contributor

Choose a reason for hiding this comment

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

line 61 to line 68 ,please put them into one method e.g. validate_attached_datastore()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move to check_result().

Copy link
Contributor

@chunfuwen chunfuwen left a comment

Choose a reason for hiding this comment

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

lgtm

Start guest with datastore and hotplug disk with datastore.
"""
def prepare_vm():
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be more appropriate to say " prepare_disk" here

disk_xml = virsh.dumpxml(vm_name, "--xpath //disk", debug=True).stdout_text
if "dataStore" not in disk_xml:
test.fail("Can't get the datastore element automatically!")
test.log.info("TEST_STEP: Do rear/write for disk.")
Copy link
Contributor

Choose a reason for hiding this comment

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

A typo here: s/rear/read

if with_hotplug:
test.log.info("TEST_STEP: Hotplug disk with datastore.")
new_image_path, disk_dev = hotplug_disk(data_file_option)
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to also log the TEST_STEP here, right?

test.log.info("TEST_STEP: Check the disk dumpxml.")
check_result()
if with_hotplug:
virsh.detach_device(vm_name, disk_dev.xml, debug=True, ignore_status=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to log the TEST_STEP here for hotunplug

finally:
vmxml_backup.sync()
disk_obj.cleanup_disk_preparation(disk_type)
if with_block:
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't cleanup_disk_preparation enough to clean up the disk? Why do we need the following lines?

Automate two cases:
VIRT-303298 [virtual disks][dataStore] Hotplug/unplug disks with data files
VIRT-303297 [virtual_disks][dataStore] Start guest with disks that have data files

Signed-off-by: Meina Li <[email protected]>
@meinaLi meinaLi requested a review from fangge1212 March 7, 2025 08:55
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.

3 participants