-
Notifications
You must be signed in to change notification settings - Fork 77
[4.21][Storage] Manual Cherry-Pick: Add Velero backup hooks opt-out tests #5924
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
Merged
rnetser
merged 2 commits into
RedHatQE:cnv-4.21
from
ema-aka-young:velero-hooks-automation-cnv-4.21
Aug 11, 2026
Merged
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| """ | ||
| Velero Backup Hook Opt-Out Tests | ||
|
|
||
| STP: | ||
| https://github.com/RedHatQE/openshift-virtualization-tests-design-docs/blob/main/stps/ | ||
| sig-storage/remove-velero-hooks-stp.md | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| Jira: https://redhat.atlassian.net/browse/CNV-79727 # <skip-jira-utils-check> | ||
| """ | ||
|
|
||
| import logging | ||
|
|
||
| import pytest | ||
|
|
||
| from tests.data_protection.oadp.utils import assert_velero_backup_hooks_not_injected | ||
| from utilities.oadp import VeleroBackup | ||
|
|
||
| LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class TestVeleroBackupHookOptOut: | ||
| """ | ||
| Tests for Velero backup hook opt-out. | ||
|
|
||
| The skip-backup-hooks annotation is intended for metadata-only backup workflows where | ||
| third-party solutions handle the actual data protection. These tests verify that | ||
| freeze/unfreeze hooks are not injected and that Velero backup completes when the | ||
| annotation is set. | ||
|
|
||
| Preconditions: | ||
| - Under-test VM with ``kubevirt.io/skip-backup-hooks`` set to ``"true"`` | ||
| """ | ||
|
|
||
| @pytest.mark.polarion("CNV-16267") | ||
| def test_backup_paused_vm_hooks_disabled( | ||
| self, | ||
| admin_client, | ||
| namespace_for_hooks_backup, | ||
| paused_rhel_vm_with_hooks_opt_out, | ||
| ): | ||
| """ | ||
| Test that backup of paused VM completes with hooks disabled. | ||
|
|
||
| Preconditions: | ||
| - Under-test VM with ``kubevirt.io/skip-backup-hooks`` set to ``"true"``, paused | ||
|
|
||
| Steps: | ||
| 1. Run Velero backup | ||
| 2. Inspect virt-launcher pod for Velero hook annotations | ||
|
|
||
| Expected: | ||
| - No freeze/unfreeze hooks are injected on the virt-launcher pod | ||
| - Backup completes successfully | ||
| """ | ||
| with VeleroBackup( | ||
| name="backup-paused-optout", | ||
| client=admin_client, | ||
| included_namespaces=[namespace_for_hooks_backup.name], | ||
| teardown=True, | ||
| ) as backup: | ||
|
ema-aka-young marked this conversation as resolved.
|
||
| assert_velero_backup_hooks_not_injected(vm=paused_rhel_vm_with_hooks_opt_out, admin_client=admin_client) | ||
| LOGGER.info(f"Backup {backup.name} completed for paused VM with opt-out annotation") | ||
|
|
||
| @pytest.mark.polarion("CNV-16268") | ||
| def test_backup_running_vm_hooks_disabled( | ||
| self, | ||
| admin_client, | ||
| namespace_for_hooks_backup, | ||
| rhel_vm_with_hooks_opt_out, | ||
| ): | ||
| """ | ||
| Test that backup of a running VM completes with hooks disabled. | ||
|
|
||
| Preconditions: | ||
| - Under-test VM with ``kubevirt.io/skip-backup-hooks`` set to ``"true"``, running | ||
|
|
||
| Steps: | ||
| 1. Run Velero backup | ||
| 2. Inspect virt-launcher pod for Velero hook annotations | ||
|
|
||
| Expected: | ||
| - No freeze/unfreeze hooks are injected on the virt-launcher pod | ||
| - Backup completes successfully | ||
| """ | ||
| with VeleroBackup( | ||
| name="backup-hooks-opt-out", | ||
| client=admin_client, | ||
| included_namespaces=[namespace_for_hooks_backup.name], | ||
| teardown=True, | ||
| ) as backup: | ||
| assert_velero_backup_hooks_not_injected(vm=rhel_vm_with_hooks_opt_out, admin_client=admin_client) | ||
| LOGGER.info(f"Backup {backup.name} completed for running VM with opt-out annotation") | ||
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
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.