Repository navigation
feat: Simplify source provider config to single CLI arg (#292) - #294
Conversation
Replace --tc=source_provider_type and --tc=source_provider_version with a single --tc=source_provider arg that maps directly to the key in .providers.json (e.g., vsphere-8.0.1). - Add load_source_providers() utility function - Update conftest.py to use single source_provider config key - Update skipif markers to resolve provider type from .providers.json - Update README.md and copyoffload docs with new CLI examples
Remove unused TimeoutSampler import, fix import ordering, and normalize blank lines.
WalkthroughConsolidates separate provider_type/provider_version into a single Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Container Operations
Cherry-pick Operations
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
💡 Tool usage guide:Overview: The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
See the review usage page for a comprehensive guide on using this tool. |
PR Code Suggestions ✨Latest suggestions up to e315581
Previous suggestions✅ Suggestions up to commit 46e6b63
✅ Suggestions up to commit 5ff9eae
|
||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In `@conftest.py`:
- Around line 559-572: The fixture source_provider_data currently does a direct
dict lookup using py_config["source_provider"], which raises an unhelpful
KeyError on mismatch; change it to catch the missing-key case and raise a
ValueError with a clear diagnostic that includes the requested key and the list
of available keys (use source_providers.keys() or check with
source_providers.get), ensure fixture_store is only set when a valid provider is
found, and update the docstring to include a Raises section documenting the
ValueError on invalid/missing provider.
In `@tests/test_copyoffload_migration.py`:
- Line 46: The test is silently defaulting source_provider; replace the safe
.get default with direct access so missing config fails fast: change the
assignment for _SOURCE_PROVIDER_TYPE to read py_config['source_provider'] (not
py_config.get(...)) and use that value to look up load_source_providers() (via
load_source_providers()[py_config['source_provider']] or similar) before
extracting the 'type' field, so a missing py_config['source_provider'] raises
immediately; reference the existing symbols _SOURCE_PROVIDER_TYPE,
load_source_providers and py_config when making this change.
In `@tests/test_mtv_warm_migration.py`:
- Line 18: The code silently defaults when source_provider is missing: replace
the safe-get pattern in the _SOURCE_PROVIDER_TYPE assignment by directly
indexing py_config['source_provider'] and accessing load_source_providers() to
avoid using .get(..., ""); if the key is absent raise a clear ConfigurationError
(or ValueError) with a descriptive message so tests fail fast; update references
around _SOURCE_PROVIDER_TYPE, load_source_providers, and py_config to use
explicit access and add the explicit error handling when the provider is not
found.
In `@utilities/utils.py`:
- Around line 42-56: Update the load_source_providers function docstring to
include an Args section (documenting providers_file: Path or that it reads from
".providers.json"), a Returns section (already present but ensure format matches
project style), and a Raises section (already present but ensure format matches
style), and remove the redundant explicit open mode by changing the file open
call from open(providers_file, "r") to open(providers_file) in the function
body; reference symbols: load_source_providers, providers_file,
MissingProvidersFileError.
…gather during setupplan - Skip must-gather in pytest_exception_interact when running with --setupplan or --collectonly - Move MissingProvidersFileError validation to source_provider_data fixture for earlier, clearer errors - Return empty dict from load_source_providers when .providers.json is missing instead of raising - Add default message to MissingProvidersFileError for consistent error output - Add explicit check for requested provider existence with available providers list
The default mode for open() is already "r", so the explicit argument is unnecessary.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
💡 Tool usage guide:Overview: The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
See the review usage page for a comprehensive guide on using this tool. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@utilities/utils.py`:
- Around line 47-52: The function that reads providers_file (providers_file =
Path(".providers.json") ... with open(providers_file) as fd: return
json.load(fd)) can raise json.JSONDecodeError for an empty or invalid file; wrap
the json.load call in a try/except that catches json.JSONDecodeError (and
optionally ValueError) and returns an empty dict {} on decode errors so callers
get {} instead of an exception; reference the providers_file variable and the
json.load call when applying the change.
Return empty dict when .providers.json exists but is empty, preventing json.JSONDecodeError.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
💡 Tool usage guide:Overview: The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
See the review usage page for a comprehensive guide on using this tool. |
|
Failed to build and push ghcr.io/redhatqe/mtv-api-tests:latest |
PR Type
Enhancement
Description
Simplify source provider configuration from two CLI args to single unified arg
--tc=source_provider_typeand--tc=source_provider_versionwith--tc=source_provider.providers.jsonentry (e.g.,vsphere-8.0.1)Extract provider loading logic into reusable
load_source_providers()utility functionUpdate test markers to resolve provider type dynamically from
.providers.jsonUpdate documentation and examples across README and copyoffload guides
Clean up unused imports and normalize whitespace in test files
Diagram Walkthrough
File Walkthrough
conftest.py
Consolidate provider config and use utility functionconftest.py
MissingProvidersFileErrorimport and replace inline providerloading with
load_source_providers()utilitysource_providerkeysource_provider_datafixture to directly lookup providerusing single config key
source_providerinstead ofseparate type and version
source_provider_datafixturetest_copyoffload_migration.py
Update imports and provider type resolutiontests/test_copyoffload_migration.py
TimeoutSamplerimportload_source_providers()import and create module-level_SOURCE_PROVIDER_TYPEvariableinstead of direct config access
test_mtv_warm_migration.py
Update provider type resolution from configtests/test_mtv_warm_migration.py
load_source_providers()importpy_config.get("source_provider_type")with dynamiclookup from loaded providers
SOURCE_PROVIDER_TYPEvariable to_SOURCE_PROVIDER_TYPEfor consistencyutils.py
Add load_source_providers utility functionutilities/utils.py
jsonimport for provider file parsingMissingProvidersFileErrorimport from exceptionsload_source_providers()function to load and returnprovider configurations from
.providers.jsoncomprehensive docstring
README.md
Update documentation with simplified provider configREADME.md
--tc=source_provider:vsphere-8.0.1instead of separate type andversion args
.providers.jsonis used directly in CLIconfiguration
argument
separate type/version
how-to-run-copyoffload-tests.md
Simplify provider key documentationdocs/copyoffload/how-to-run-copyoffload-tests.md
from
.providers.json--tc=source_providerargument
separate version
Summary by CodeRabbit
Documentation
Bug Fixes
Chores