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

Automate blockresize cases #5585

Merged
merged 1 commit into from
May 30, 2024

Conversation

chunfuwen
Copy link
Contributor

Cover blockresize in various scenarios

Copy link
Contributor

@nanli1 nanli1 left a comment

Choose a reason for hiding this comment

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

Any result

@chunfuwen
Copy link
Contributor Author

PASS 01-type_specific.io-github-autotest-libvirt.virtual_disks.blockresize.coldplug.virtio.capacity
PASS 02-type_specific.io-github-autotest-libvirt.virtual_disks.blockresize.coldplug.virtio.specific
PASS 03-type_specific.io-github-autotest-libvirt.virtual_disks.blockresize.coldplug.virtio.save_restore
PASS 04-type_specific.io-github-autotest-libvirt.virtual_disks.blockresize.coldplug.virtio.not_equal_actual_size
PASS 05-type_specific.io-github-autotest-libvirt.virtual_disks.blockresize.coldplug.virtio.not_zero_offset
PASS 06-type_specific.io-github-autotest-libvirt.virtual_disks.blockresize.coldplug.virtio.non_raw_block_device
PASS 07-type_specific.io-github-autotest-libvirt.virtual_disks.blockresize.coldplug.sata.capacity
PASS 08-type_specific.io-github-autotest-libvirt.virtual_disks.blockresize.coldplug.sata.specific
PASS 09-type_specific.io-github-autotest-libvirt.virtual_disks.blockresize.coldplug.scsi.capacity
PASS 10-type_specific.io-github-autotest-libvirt.virtual_disks.blockresize.coldplug.scsi.specific
PASS 11-type_specific.io-github-autotest-libvirt.virtual_disks.blockresize.hotplug.virtio.capacity
PASS 12-type_specific.io-github-autotest-libvirt.virtual_disks.blockresize.hotplug.virtio.specific
PASS 13-type_specific.io-github-autotest-libvirt.virtual_disks.blockresize.hotplug.scsi.capacity
PASS 14-type_specific.io-github-autotest-libvirt.virtual_disks.blockresize.hotplug.scsi.specific

"Error: %s" % str(details))
else:
session = vm.wait_for_login()
time.sleep(20)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to wait here , or could we use utils_misc.wait_for(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The wait is to allow VM to show up disk ,and following call new_disk, _ = libvirt_disk.get_non_root_disk_name(session) can succeed.
So here it is for guest, and hard to find matched pattern for utils_misc.wait_for().

Comment on lines 42 to 53
def check_image_virtual_size(image_file, matched_size, test):
"""
Check whether image virtual size queried by qemu-img is matched
:param image_file: image file path
:param matched_size: anticipated size
:param test: test case itself

"""
disk_info_dict = utils_misc.get_image_info(image_file)
actual_size_in_bytes = str(disk_info_dict.get("vsize"))
if actual_size_in_bytes != matched_size:
test.fail(f"actual size of block disk is {actual_size_in_bytes}, but expected is : {matched_size}")
Copy link
Contributor

Choose a reason for hiding this comment

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

You could reuse check_obj.check_image_info() if you want

Copy link
Contributor Author

@chunfuwen chunfuwen May 15, 2024

Choose a reason for hiding this comment

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

This is only one line code, looks like it is not necessary introduce another dependence: check_obj.check_image_info()

target_dev = params.get('target_dev')
status_error = "yes" == params.get("status_error")
try:
device_obj = create_customized_disk(params, test)
Copy link
Contributor

Choose a reason for hiding this comment

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

You could reuse setup_attrs if you want

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

@chunfuwen chunfuwen May 15, 2024

Choose a reason for hiding this comment

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

This issue has been discussed multiple round before. Whether use setup_attrs or previously base utils. Setup_attrs need input lots of long and nested config information as raw in cfg file, sometimes it look not easily to understand clearly. Base utils build up from some disperse parameter, and those parameter can share across variants in cfg file. Finally, I would like to say it is real balance here which one your prefer. I would like author choose his or her preferable ways.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I'm fine with it. I was recently requested to use a dictionary in the cfg though, but I agree the author should be able to decide. #5287 (comment)

variants target_bus:
- virtio:
- sata:
only coldplug
Copy link
Contributor

@smitterl smitterl Apr 30, 2024

Choose a reason for hiding this comment

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

Please add no s390-virtio for 'sata'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

:param image_file: image file path
:param matched_size: anticipated size
:param test: test case itself

Copy link
Contributor

Choose a reason for hiding this comment

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

The empty line from l48 should be before the param listing in l45 IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

device_format = params.get("target_format")
source_file_path = setup_scsi_debug_block_device()
overlay_source_file_path = params.get("overlay_source_file_path")
matched_size = params.get("block_size_in_bytes")
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and in the rest of the code (function params), why not call it in a more standard way "expected_size"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

change name to expected_size

vmxml_backup.sync()
libvirt.delete_scsi_disk()
# Clean up files
for file_path in cleanup_files:
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 two comments are not necessary the xml.sync and file_path in cleanup_file already conveys what's done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove those two comments

except virt_vm.VMStartError as details:
test.fail("VM failed to start."
"Error: %s" % str(details))
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

What if does this correspond to? Is this a typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is try exception...else ..finally mechanism

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for clarifying!

target_dev = params.get('target_dev')
status_error = "yes" == params.get("status_error")
try:
device_obj = create_customized_disk(params, test)
Copy link
Contributor

Choose a reason for hiding this comment

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

+1



def check_image_virtual_size(image_file, matched_size, test):
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

matched_size -> expected_size?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

except virt_vm.VMStartError as details:
test.fail("VM failed to start."
"Error: %s" % str(details))
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for clarifying!

Copy link
Contributor

@smitterl smitterl left a comment

Choose a reason for hiding this comment

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

@chunfuwen Just a minor nitpick about the usage of "matched_size", rest LGTM. Thanks

Copy link
Contributor

@smitterl smitterl left a comment

Choose a reason for hiding this comment

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

LGTM, thank you very much!

Copy link
Contributor

@dzhengfy dzhengfy left a comment

Choose a reason for hiding this comment

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

Others LGTM

variants target_bus:
- virtio:
- sata:
only coldplug
Copy link
Contributor

Choose a reason for hiding this comment

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

No aarch64, thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Cover blockresize in various scenarios

Signed-off-by: Chunfu Wen <chwen@redhat.com>
@dzhengfy dzhengfy merged commit a36464a into autotest:master May 30, 2024
5 checks passed
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.

None yet

4 participants