Skip to content

Refactor OS matrix to support different architectures #983

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

Open
wants to merge 49 commits into
base: main
Choose a base branch
from

Conversation

rnetser
Copy link
Collaborator

@rnetser rnetser commented May 17, 2025

Short description:
More details:
What this PR does / why we need it:
Which issue(s) this PR fixes:
Special notes for reviewer:
jira-ticket:

Summary by CodeRabbit

  • New Features

    • Added support for arm64 and s390x architectures (s390x as work in progress) in test configuration and documentation.
    • Introduced new configuration files and utilities for architecture-specific OS image matrices.
    • Added new architecture-specific image classes and constants for test images.
  • Bug Fixes

    • Improved robustness of dictionary access throughout tests and utilities to prevent errors when configuration keys are missing.
  • Refactor

    • Consolidated and modularized OS image and template configuration for easier architecture extension.
    • Updated test and utility code to use safer methods for dictionary value retrieval and path construction.
    • Replaced platform-dependent path joins with consistent string formatting for image paths.
    • Enhanced pytest matrix parameter handling to avoid errors during collection or setup phases.
  • Documentation

    • Added detailed architecture support documentation in a new file.
    • Updated getting started guide to reflect multi-architecture support and configuration options.
  • Chores

    • Updated test and tox configuration to support architecture-specific test runs and environments.
    • Removed default test config file from pytest options to allow flexible configuration loading.

@rnetser rnetser marked this pull request as draft May 17, 2025 17:47
Copy link

coderabbitai bot commented May 17, 2025

## Walkthrough

This update introduces multi-architecture support for test image configurations, adding dedicated handling for `arm64` and `s390x` architectures alongside `x86_64`. It refactors OS matrix generation into reusable utilities, modularizes image metadata into dataclasses, and updates test configs, fixtures, and tox environments to leverage these changes. Numerous dictionary accesses are made safer using `.get()`. Documentation and pytest markers are updated accordingly.

## Changes

| Files / Groups                                                                                      | Change Summary |
|-----------------------------------------------------------------------------------------------------|---------------|
| `utilities/constants.py`, `libs/infra/images.py`, `utilities/os_utils.py`                           | Refactored image and OS matrix handling: introduced architecture-specific classes, dataclasses for image metadata, and utilities for OS matrix generation. Added support for `arm64` and `s390x`. |
| `tests/global_config.py`                                                                            | Removed all statically defined OS matrices and related constants; simplified configuration. |
| `tests/global_config_x86.py`, `tests/global_config_arm64.py`, `tests/global_config_s390x.py`        | Added/updated architecture-specific global config files using new OS matrix utilities and image constants. |
| `tests/global_config_aws.py`, `tests/global_config_ibm_spectrum_sc.py`, `tests/global_config_interop.py`, `tests/global_config_interop_sno.py`, `tests/global_config_lvms.py`, `tests/global_config_nfs.py`, `tests/global_config_oci.py`, `tests/global_config_rh_it.py`, `tests/global_config_sno.py`, `tests/global_config_sno_hpp.py` | Updated to load new architecture-specific config files (`global_config_x86.py`). |
| `conftest.py`, `tests/conftest.py`, `tests/os_params.py`, `utilities/virt.py`, `utilities/pytest_utils.py` | Updated to use safer `.get()` dictionary access, improved error handling, and robust fixture/config logic. |
| `tests/storage/cdi_import/test_import_http.py`, `tests/storage/cdi_upload/test_upload_virtctl.py`, `tests/virt/node/hotplug/test_cpu_memory_hotplug.py` | Introduced local variables for OS dicts, replaced direct config access with `.get()`. |
| `tests/virt/cluster/common_templates/windows/test_windows_custom_options.py`, `tests/virt/cluster/longevity_tests/constants.py`, `tests/virt/node/general/test_networkinterfacemultiqueue_feature.py`, `tests/virt/node/general/test_oom.py`, `tests/virt/node/general/test_windows_vtpm_bitlocker.py`, `tests/virt/node/general/test_wsl2.py`, `tests/virt/node/gpu/gpu_pci_passthrough/test_windows_vm_with_gpu_pci_passthrough.py`, `tests/virt/node/gpu/vgpu/test_windows_vm_with_vgpu.py`, `tests/virt/node/high_performance_vm/test_high_performance_templates.py`, `tests/virt/node/migration_and_maintenance/test_post_copy_migration.py`, `tests/virt/node/migration_and_maintenance/test_vm_memory_load_with_migration.py` | Replaced `os.path.join` with f-string path concatenation for image paths; removed unused `os` imports. |
| Many test files (e.g., `tests/storage/test_hotplug.py`, `tests/scale/test_scale_benchmark.py`, `tests/virt/cluster/common_templates/general/test_base_custom_templates.py`, etc.) | Replaced direct dictionary key access with `.get()` for safer value retrieval from config/OS dicts. |
| `pytest.ini`                                                                                        | Added `x86_64` and `s390x` markers; removed default test config from `addopts`. |
| `tox.ini`                                                                                           | Split `pytest-check` into `pytest-check-x86` and `pytest-check-arm64` environments; added template for `pytest-check-s390x`. |
| `docs/GETTING_STARTED.md`                                                                           | Updated documentation to mention `arm64` and `s390x` image architecture support. |

## Possibly related PRs

- RedHatQE/openshift-virtualization-tests#930: Related to ARM64 test coverage enhancements for RHEL10 instance types and test markers.
- RedHatQE/openshift-virtualization-tests#915: Related to OS matrix data handling and test configuration updates.
- RedHatQE/openshift-virtualization-tests#1142: Fixes flakiness in metrics tests by adding a retry mechanism, related to test reliability improvements.

## Suggested labels

`verified`, `size/L`, `can-be-merged`, `lgtm-dshchedr`, `approved-rnetser`, `lgtm-rnetser`

## Suggested reviewers

- dshchedr
- vsibirsk
- RoniKishner

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b532999 and dcdff86.

📒 Files selected for processing (9)
  • tests/global_config_arm64.py (2 hunks)
  • tests/global_config_aws.py (1 hunks)
  • tests/global_config_gcp.py (1 hunks)
  • tests/global_config_ibm_spectrum_sc.py (1 hunks)
  • tests/global_config_lvms.py (1 hunks)
  • tests/global_config_nfs.py (1 hunks)
  • tests/global_config_oci.py (1 hunks)
  • tests/global_config_rh_it.py (1 hunks)
  • tests/storage/storage_migration/test_mtc_storage_class_migration.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/global_config_aws.py
🚧 Files skipped from review as they are similar to previous changes (8)
  • tests/global_config_lvms.py
  • tests/global_config_gcp.py
  • tests/global_config_oci.py
  • tests/global_config_ibm_spectrum_sc.py
  • tests/global_config_nfs.py
  • tests/global_config_rh_it.py
  • tests/storage/storage_migration/test_mtc_storage_class_migration.py
  • tests/global_config_arm64.py
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: can-be-merged
  • GitHub Check: can-be-merged
  • GitHub Check: tox
  • GitHub Check: build-container
  • GitHub Check: can-be-merged
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ghost
Copy link

ghost commented May 17, 2025

Report bugs in Issues

The following are automatically added:

  • Add reviewers from OWNER file (in the root of the repository) under reviewers section.
  • Set PR size label.
  • New issue is created for the PR. (Closed when PR is merged/closed)
  • Run pre-commit if .pre-commit-config.yaml exists in the repo.

Available user actions:

  • To mark PR as WIP comment /wip to the PR, To remove it from the PR comment /wip cancel to the PR.
  • To block merging of PR comment /hold, To un-block merging of PR comment /hold cancel.
  • To mark PR as verified comment /verified to the PR, to un-verify comment /verified cancel to the PR.
    verified label removed on each new commit push.
  • To cherry pick a merged PR comment /cherry-pick <target branch to cherry-pick to> in the PR.
    • Multiple target branches can be cherry-picked, separated by spaces. (/cherry-pick branch1 branch2)
    • Cherry-pick will be started when PR is merged
  • To build and push container image command /build-and-push-container in the PR (tag will be the PR number).
    • You can add extra args to the Podman build command
      • Example: /build-and-push-container --build-arg OPENSHIFT_PYTHON_WRAPPER_COMMIT=<commit_hash>
  • To add a label by comment use /<label name>, to remove, use /<label name> cancel
  • To assign reviewers based on OWNERS file use /assign-reviewers
  • To check if PR can be merged use /check-can-merge
  • to assign reviewer to PR use /assign-reviewer @<reviewer>

PR will be approved when the following conditions are met:

  • /approve from one of the approvers.
  • Minimum number of required /lgtm (2) is met.
Approvers and Reviewers
  • Approvers:

    • dshchedr
    • dshchedr
    • myakove
    • rnetser
    • rnetser
    • vsibirsk
    • vsibirsk
  • Reviewers:

    • RoniKishner
    • RoniKishner
    • dshchedr
    • dshchedr
    • geetikakay
    • rnetser
    • rnetser
    • vsibirsk
    • vsibirsk
Supported /retest check runs
  • /retest tox: Retest tox
  • /retest build-container: Retest build-container
  • /retest all: Retest all
Supported labels
  • hold
  • verified
  • wip
  • lgtm
  • approve

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (5)
utilities/constants.py (1)

158-160: Minor grammar & clarity.

f"{arch} architecture in not supported"f"{arch} architecture is not supported"

-    raise ValueError(f"{arch} architecture in not supported")
+    raise ValueError(f"{arch} architecture is not supported")
utilities/os_utils.py (3)

155-166: Inconsistent error message (win vs windows).

The function accepts "windows" but the exception advertises "win".
Align them to avoid user confusion.

-    else:
-        raise ValueError(f"Unsupported OS: {os_name}. Supported: rhel, win, fedora")
+    else:
+        raise ValueError(
+            f"Unsupported OS: {os_name}. Supported values: 'rhel', 'windows', 'fedora', 'centos'"
+        )

173-197: No guard for an empty supported_operating_systems list.

Calling generate_os_matrix_dict("rhel", []) silently returns [], which is probably unintended.
Fail fast to surface configuration errors.

-    unsupported_versions = []
+    if not supported_operating_systems:
+        raise ValueError("supported_operating_systems must contain at least one version")
+
+    unsupported_versions = []

185-188: Template labels fall back to constants but ignore per-OS overrides.

If a version overrides only WORKLOAD_STR but not FLAVOR_STR, the current logic overrides both.
Switch to independent dict.get calls to allow partial overrides:

-        WORKLOAD_STR: base_version_dict.get(WORKLOAD_STR, base_dict[WORKLOAD_STR]),
-        FLAVOR_STR: base_version_dict.get(FLAVOR_STR, base_dict[FLAVOR_STR]),
+        WORKLOAD_STR: base_version_dict.get(WORKLOAD_STR, base_dict.get(WORKLOAD_STR)),
+        FLAVOR_STR: base_version_dict.get(FLAVOR_STR, base_dict.get(FLAVOR_STR)),
tests/global_config_x86.py (1)

78-78: Remove unnecessary noqa comment.

If you've implemented the suggested fixes above, this noqa comment can be removed as the config variable will be properly initialized.

-    config[_dir] = locals()[_dir]  # noqa: F821
+    config[_dir] = locals()[_dir]
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1c798f8 and b1d827a.

📒 Files selected for processing (9)
  • README.md (1 hunks)
  • conftest.py (1 hunks)
  • tests/conftest.py (1 hunks)
  • tests/global_config.py (1 hunks)
  • tests/global_config_x86.py (1 hunks)
  • tests/os_params.py (1 hunks)
  • utilities/constants.py (1 hunks)
  • utilities/os_utils.py (1 hunks)
  • utilities/virt.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
tests/os_params.py (1)
utilities/virt.py (1)
  • get_windows_os_dict (1552-1564)
conftest.py (1)
utilities/infra.py (1)
  • generate_latest_os_dict (196-214)
tests/conftest.py (1)
utilities/storage.py (1)
  • get_test_artifact_server_url (596-617)
utilities/os_utils.py (1)
libs/vm/spec.py (1)
  • Template (16-18)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: can-be-merged
  • GitHub Check: can-be-merged
  • GitHub Check: build-container
  • GitHub Check: tox
🔇 Additional comments (16)
README.md (1)

92-92: Documentation update for s390x architecture support looks good.

The addition of s390x as a supported architecture with the "currently work in progress" note aligns well with the broader changes in this PR to support different architectures in the OS matrix.

tests/os_params.py (3)

7-9: Good improvement to defensive coding practices.

The use of .get() with default empty dictionaries provides better error handling for missing keys in the configuration, making the code more robust against KeyError exceptions.


12-21: Consistent application of safer dictionary access.

The consistent use of the .get() method across all Windows OS configuration access points is a good practice, especially when interacting with configuration data that might be incomplete.


23-25: Maintaining consistency for Fedora configuration access.

The changes follow the same pattern of safer access through .get() method for Fedora configurations, ensuring a consistent approach throughout the file.

utilities/virt.py (2)

1553-1564: Enhanced error handling for Windows OS configuration.

The function now safely checks for the existence of the Windows OS matrix in the configuration and provides a graceful fallback (empty dictionary) when it's not present. This is a good improvement to prevent runtime exceptions.


1568-1579: Improved robustness for RHEL OS configuration retrieval.

Similarly to the Windows OS function, this change adds proper checks for RHEL OS matrix existence and provides a graceful fallback when missing. The consistent approach across both OS matrix functions is commendable.

tests/conftest.py (1)

1884-1891: Improved error handling in rhel_latest_os_params fixture.

The change safely handles the possibility of a missing "latest_rhel_os_dict" key in py_config using the walrus operator with get(), preventing KeyError exceptions during fixture setup and returning an empty dictionary instead.

conftest.py (2)

588-593: Safer handling of OS matrix configuration.

These changes use the walrus operator with .get() to safely handle cases where OS matrix keys might be missing in py_config, preventing potential KeyError exceptions during session startup.


595-606: Added defensive checks when updating OS matrices.

Good addition of null checks before attempting to generate latest OS dictionaries, ensuring the code only updates matrices when they exist, preventing potential errors during OS matrix generation.

tests/global_config.py (1)

181-188: Verify CentOS Stream 10 entries really exist.

centos-stream10 images and templates are listed but are still in Early Preview upstream.
Please confirm:

• A matching DataImportCron template lives in the cluster
• The centos.stream10 preference exists in common-templates

Otherwise this entry will break nightly jobs.

tests/global_config_x86.py (6)

20-30: RHEL OS matrix definition looks good.

The OS matrix for RHEL is well-defined using the new generate_os_matrix_dict utility function. The supported operating systems list contains specific versions which aligns with the refactoring goal to support different architectures.


32-42: Windows OS matrix definition looks good.

The Windows OS matrix is correctly defined with a comprehensive list of supported versions. The use of the centralized generate_os_matrix_dict function ensures consistency across different OS matrices.


44-46: Fedora and CentOS OS matrix definitions look good.

Both OS matrices are concisely defined with their respective supported versions. The single-line style is appropriate for these simpler definitions with only one supported OS version each.


48-59: Special RHEL 10 instance type matrix is well-defined.

The specialized instance type matrix for RHEL 10 includes all necessary attributes with clear structure. This provides good configuration for tests that require specific instance type settings.


61-66: Efficient latest OS dictionary retrieval.

The use of tuple unpacking for the return value of get_latest_os_dict_list is clear and concise. This correctly retrieves the latest OS dictionaries for all defined OS matrices.


72-77: Appropriate filtering in config construction.

The type checking and key exclusion logic for constructing the config dictionary is well-implemented. This ensures that only relevant configuration values are included in the final config dictionary.

Copy link
Collaborator

@polarion-jenkins polarion-jenkins left a comment

Choose a reason for hiding this comment

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

D/S test tox -e verify-bugs-are-open failed: cnv-tests-tox-executor/11098

@rnetser
Copy link
Collaborator Author

rnetser commented Jun 10, 2025

/build-and-push-container

@openshift-virtualization-qe-bot

New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-983 published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.