-
Notifications
You must be signed in to change notification settings - Fork 67
integration: Move destination device initialization to the provider #447
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
claudiubelu
wants to merge
2
commits into
cloudbase:master
Choose a base branch
from
claudiubelu:integration-provider-agnosticism
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # Copyright 2026 Cloudbase Solutions Srl | ||
| # All Rights Reserved. | ||
|
|
||
| """ | ||
| Abstract base class for provider harnesses. | ||
|
|
||
| A harness encapsulates all provider-specific logic that cannot be expressed | ||
| through static YAML configuration: per-transfer resource allocation, | ||
| end-of-session leak assertions, VM finalization, etc. | ||
| """ | ||
|
|
||
| import abc | ||
|
|
||
| from oslo_log import log as logging | ||
|
|
||
| LOG = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class ImportProviderHarness(abc.ABC): | ||
| # Subclasses must set this to the import provider class they wrap. | ||
| # The framework derives the dotted provider path from it automatically. | ||
| provider_class = None | ||
|
|
||
| def __init__(self, harness): | ||
| self._deferred_errors = [] | ||
|
|
||
| def _record_error(self, exc): | ||
| """Stash *exc* for deferred reporting after all teardown completes.""" | ||
| self._deferred_errors.append(exc) | ||
|
|
||
| def teardown(self): | ||
| """One-time teardown called at atexit.""" | ||
|
|
||
| def check_prerequisites(self): | ||
| """Raise ``unittest.SkipTest`` if required infrastructure is absent.""" | ||
|
|
||
| @abc.abstractmethod | ||
| def get_connection_info(self) -> dict: | ||
| """Return ``connection_info`` for the destination endpoint.""" | ||
|
|
||
| def prepare_transfer(self, test_instance) -> dict: | ||
| """Allocate per-transfer destination resources. | ||
|
|
||
| Returns a dict merged into ``destination_environment`` for this | ||
| transfer. Must register ``addCleanup()`` on *test_instance* for | ||
| every resource created, so it is released even on test failure. | ||
| """ | ||
| return {} | ||
|
|
||
| @property | ||
| def are_disks_local(self) -> bool: | ||
| """True if destination disks are local block devices on the test host. | ||
|
|
||
| When True, tests may directly read / mount the destination device to | ||
| verify contents. | ||
| """ | ||
| return False | ||
|
|
||
| def check_no_resources_leaked(self): | ||
| """Check for resources left behind by this test session. | ||
|
|
||
| Subclasses record each leak via ``_record_error()``, and log errors | ||
| rather than raising, so that all checks and teardowns run regardless of | ||
| earlier failures. | ||
| """ | ||
|
|
||
| def cleanup_deployed_instance(self, instance_name: str): | ||
| """Destroy the VM created at the destination by a completed deployment. | ||
|
|
||
| Called during integration test cleanup after each deployment test, so | ||
| that finalized VMs do not accumulate across runs and cause failures in | ||
| later tests (e.g. name collisions, resource exhaustion). | ||
|
|
||
| The default is a no-op; harnesses that create real VMs must override | ||
| this method. Implementations should be idempotent: if the VM is | ||
| already gone the method must return without raising. | ||
| """ | ||
|
|
||
| def get_minion_pool_config(self) -> dict | None: | ||
| """Return minion-pool creation kwargs, or None.""" | ||
| return None | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
I don't like this design. It doesn't really matter if the disks are local, provider agnostic tests shouldn't directly touch resources created by the providers, otherwise they're no longer provider agnostic.
We should clearly separate provider agnostic tests from those that rely on the "test provider" and interact with the created resources (e.g. scsi debug devices).
Without a proper design and clear limitations, our tests are going to become a mess and we'll refactor them every other week. We don't want that.
For what is worth, Openstack's Tempest tests are completely driver agnostic. They do have "functional tests" that call directly into the provider, but hose are completely separate.
https://github.com/openstack/nova/tree/master/nova/tests/functional/libvirt