-
Notifications
You must be signed in to change notification settings - Fork 18
Several disk test improvements #824
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
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @kostyanf14, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the flexibility and reliability of disk testing within the system. It empowers users to define the filesystem image format for storage driver tests via a new command-line interface option. Concurrently, it improves the robustness of disk initialization routines by relocating them to pre-test commands and incorporating error handling, which helps in preventing test failures caused by unexpected disk configurations. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces several improvements for disk-based tests. It adds a new command-line option --fs-test-image-format to allow specifying 'raw' or 'qcow2' format for filesystem test images. It also refactors the disk initialization logic for vioscsi and viostor drivers, moving it from a one-time setup step to a pre-test command to ensure a clean state for each test run.
My review has identified a couple of areas for improvement:
- A potential bug in
storage_manager.rbwhere the new image format option unintentionally affects the boot disk image format, which should likely remain fixed. - A suggestion to add input validation for the new command-line option in
cli.rbto improve robustness.
|
|
||
| def create_image(path, size_gb) | ||
| run_cmd(*%W[#{@qemu_img_bin} create -f #{IMAGE_FORMAT} #{path} #{size_gb}G]) | ||
| run_cmd(*%W[#{@qemu_img_bin} create -f #{@fs_test_image_format} #{path} #{size_gb}G]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change in create_image to use @fs_test_image_format has an unintended side effect: it also changes the format of the boot image, since create_boot_image calls this method. The --fs-test-image-format option is intended only for filesystem test images.
The boot image format should likely remain fixed as 'qcow2' to ensure features like snapshots work correctly, as other parts of the code assume this format.
To fix this, you can determine the correct format inside create_image based on which image path is being used.
format = (path == @test_image_path) ? @fs_test_image_format : IMAGE_FORMAT
run_cmd(*%W[#{@qemu_img_bin} create -f #{format} #{path} #{size_gb}G])There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kostyanf14 Do we care?
| parser.on('--fs-test-image-format <fs_test_image_format>', String, | ||
| 'Filesystem test image format (qcow2/raw). Default is qcow2.', | ||
| 'Has effect only when testing storage drivers.', | ||
| &method(:fs_test_image_format=)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve robustness, it's a good practice to validate user input. The --fs-test-image-format option is expected to be either 'qcow2' or 'raw'. You can use OptionParser to enforce this constraint, which will automatically provide a helpful error message for invalid values.
parser.on('--fs-test-image-format <fs_test_image_format>', %w[qcow2 raw],
'Filesystem test image format (qcow2/raw). Default is qcow2.',
'Has effect only when testing storage drivers.',
&method(:fs_test_image_format=))There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces improvements to disk testing functionality by adding support for configurable filesystem test image formats and reorganizing disk initialization commands for better reliability.
Key changes include:
- Adds a new
--fs-test-image-formatCLI option to allow users to specify the disk image format (qcow2/raw) for storage driver testing - Moves the "Initialize Disk" PowerShell command from
post_start_commandstopre_test_commandsin driver configurations, with improved error handling using-ErrorAction SilentlyContinue; exit 0
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/cli.rb | Adds new command-line option --fs-test-image-format to TestOptions for specifying filesystem test image format |
| lib/setupmanagers/qemuhck/qemuhck.rb | Passes the new fs_test_image_format option through to client VM configuration |
| lib/setupmanagers/qemuhck/storage_manager.rb | Implements configurable test image format with fallback to default IMAGE_FORMAT constant; updates image path and creation commands |
| lib/engines/hcktest/drivers/viostor.json | Moves Initialize-Disk from post_start_commands to pre_test_commands with enhanced error handling |
| lib/engines/hcktest/drivers/vioscsi.json | Moves Initialize-Disk from post_start_commands to pre_test_commands with enhanced error handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def create_image(path, size_gb) | ||
| run_cmd(*%W[#{@qemu_img_bin} create -f #{IMAGE_FORMAT} #{path} #{size_gb}G]) | ||
| run_cmd(*%W[#{@qemu_img_bin} create -f #{@fs_test_image_format} #{path} #{size_gb}G]) | ||
| end |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The create_image method now uses @fs_test_image_format for all image creation, but this is also called by create_boot_image (line 52). Boot images should always use the default IMAGE_FORMAT constant ('qcow2'), not the configurable @fs_test_image_format which is intended only for test images. This could cause boot image creation to fail or create incompatible boot images when a non-default format like 'raw' is specified.
Consider adding a format parameter to create_image to distinguish between boot and test image creation, or create separate methods for each use case.
YanVugenfirer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we care of the boot image format will change as well, or we want to switch data disk format on existing setups too?
|
|
||
| def create_image(path, size_gb) | ||
| run_cmd(*%W[#{@qemu_img_bin} create -f #{IMAGE_FORMAT} #{path} #{size_gb}G]) | ||
| run_cmd(*%W[#{@qemu_img_bin} create -f #{@fs_test_image_format} #{path} #{size_gb}G]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kostyanf14 Do we care?
Use QCOW2 as a default. Signed-off-by: Kostiantyn Kostiuk <[email protected]>
We catch issue that HLK test failed and make disk unitialized. Try to initialized disk before each tests to make sure that we have proper setup for testing. Signed-off-by: Kostiantyn Kostiuk <[email protected]>
60bb628 to
488af82
Compare
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces several improvements for disk-based tests. A new command-line option, --fs-test-image-format, is added to allow specifying the disk image format (qcow2 or raw) for storage tests. The implementation correctly propagates this option down to the storage manager. Additionally, the disk initialization logic for vioscsi and viostor drivers is moved to a pre_test_command and made idempotent, which enhances test reliability by ensuring a clean disk state before each test. The changes are logical and well-executed. I have one suggestion to add input validation for the new command-line option to make it more robust.
| parser.on('--fs-test-image-format <fs_test_image_format>', String, | ||
| 'Filesystem test image format (qcow2/raw). Default is qcow2.', | ||
| 'Has effect only when testing storage drivers.', | ||
| &method(:fs_test_image_format=)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new --fs-test-image-format option accepts 'qcow2' or 'raw' as valid formats. To improve robustness, it's a good practice to validate this input at the command-line parsing stage. This will provide immediate and clear feedback to the user if they supply an unsupported format, rather than letting it fail later during image creation.
OptionParser supports this directly by allowing you to pass an array of valid strings.
parser.on('--fs-test-image-format <fs_test_image_format>', %w[qcow2 raw],
'Filesystem test image format (qcow2/raw). Default is qcow2.',
'Has effect only when testing storage drivers.',
&method(:fs_test_image_format=))
No description provided.