Robot Tests: Add basic snapshot testing#2747
Conversation
2b42700 to
397ce5e
Compare
Add basic tests for creating/deleting snapshots to the Robot framework based test suite. Signed-off-by: Moritz Röhrich <[email protected]>
397ce5e to
2e3e9aa
Compare
|
This looks good to me. cc: @albinsun (on automation duty) |
There was a problem hiding this comment.
Pull request overview
Adds initial VM snapshot coverage to the Harvester Robot Framework suite by introducing a new regression test and a new snapshot “component + keywords” implementation backed by a Harvester CRD.
Changes:
- Add a VM regression test that creates, waits for readiness, deletes, and waits for deletion of a VM snapshot.
- Introduce a new
snapshotlibrary (component + CRD implementation + REST placeholder) and Robot keyword wrappers/resources to drive snapshot operations. - Extend constants with the
virtualmachinebackupsplural used by the snapshot CRD implementation.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| harvester_robot_tests/tests/regression/vm/test_vm_snapshots.robot | New Robot regression test for basic VM snapshot create/delete flow. |
| harvester_robot_tests/libs/snapshot/snapshot.py | Snapshot component delegating to CRD/REST implementation. |
| harvester_robot_tests/libs/snapshot/rest.py | REST strategy placeholder for snapshot operations. |
| harvester_robot_tests/libs/snapshot/crd.py | CRD-backed implementation for creating/deleting snapshots and waiting for states. |
| harvester_robot_tests/libs/snapshot/base.py | Abstract base interface for snapshot implementations. |
| harvester_robot_tests/libs/snapshot/init.py | Package export for Snapshot. |
| harvester_robot_tests/libs/keywords/snapshot_keywords.py | Robot keyword wrapper delegating snapshot operations to the Snapshot component. |
| harvester_robot_tests/libs/constant.py | Adds VIRTUALMACHINEBACKUP_PLURAL constant. |
| harvester_robot_tests/keywords/snapshot.resource | Robot resource keywords for snapshot operations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| finally: | ||
| if time.time() > endtime: | ||
| raise AssertionError( | ||
| f"Snapshot {namespace}/{snapshot_name} not ready within {timeout}s" | ||
| ) | ||
| time.sleep(self.retry_interval) |
- Apply test operation strategy from environment variable - Raise proper exceptions for non-yet-implemented REST strategy - Remove unnecessary VM lookup - Propagate error messages - Fix paths and imports - Remove superfluous List Snapshots keyword Signed-off-by: Moritz Röhrich <[email protected]>
Move timeout check outside of the exception handling. This is ok, because the timeout checking was in a `finally` block, which would be executed only after returning from either the `try` or the `except` blocks, but on some return paths, we can omit the check. Namely, when there was an error and we abort anyways and when the wait was successful and the wait condition has been met already. All other paths out of the `try` and `except` blocks just continue the iteration of the for-loop, therefore don't need a `finally` block to execute. This is where we want to do the timeout check, so the timeout check is moved to just after the try/except blocks into the loop. Signed-off-by: Moritz Röhrich <[email protected]>
|
I moved the contents of the |
| Suite Setup Set up test environment | ||
| Test Teardown Cleanup test resources | ||
| Suite Teardown Common Suite Teardown | ||
|
|
||
|
|
||
| *** Test Cases *** | ||
| Test Basic VM Snapshot | ||
| [Tags] coretest p0 snapshot | ||
| [Documentation] Test basic VM snapshot creation | ||
|
|
||
| # Generate unique name for vm, image and snapshot | ||
| ${suffix}= Generate Unique Name | ||
| ${image_name}= Set Variable image-0-${suffix} | ||
| ${vm_name}= Set Variable vm-0-${suffix} | ||
| ${snapshot_name}= Set Variable snap-0-${suffix} | ||
|
|
||
| Given Image is available for VM creation ${image_name} ${OPENSUSE_IMAGE_URL} | ||
| When VM is created ${vm_name} ${image_name} | ||
| Then VM should be running ${vm_name} | ||
| When Snapshot is created ${vm_name} ${snapshot_name} | ||
| Then Snapshot should be ready ${snapshot_name} | ||
| When Snapshot is deleted ${snapshot_name} | ||
| Then Snapshot should be deleted ${snapshot_name} |
| except ApiException as err: | ||
| if err.status == 404: | ||
| return True | ||
| logging(f"error checing snapshot {namespace}/{snapshot_name}: {err}") | ||
|
|
| except ApiException as err: | ||
| logging(f"failed to create snapshot {namespace}/{snapshot_name}: {err}") | ||
| raise | ||
| self._wait_for_ready(namespace, snapshot_name) |
| except ApiException as err: | ||
| logging(f"failed to delete snapshot {namespace}/{snapshot_name}: {err}") | ||
| raise | ||
| self._wait_for_deleted(namespace, snapshot_name) |
|
Tick the box to add this pull request to the merge queue (same as
|
Which issue(s) this PR fixes:
Issue #
What this PR does / why we need it:
Add basic tests for creating/deleting snapshots to the Robot framework based test suite.
This increases the coverage of the Robot framework based test suite.
Special notes for your reviewer:
Additional documentation or context