Skip to content
51 changes: 51 additions & 0 deletions tests/data_protection/oadp/test_velero_backup_hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""
Comment thread
ema-aka-young marked this conversation as resolved.
Comment thread
ema-aka-young marked this conversation as resolved.
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
Jira: https://redhat.atlassian.net/browse/CNV-79727 # <skip-jira-utils-check>
"""

import pytest


class TestVeleroBackupHookOptOut:
"""
Tests for Velero backup hook opt-out with backup/restore operations.

Preconditions:
- VM with backup hooks disabled
"""

__test__ = False

@pytest.mark.polarion("CNV-16267")
def test_backup_paused_vm_hooks_disabled(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need both of these tests? I'm not sure I fully understand the difference between them, aside from the restore part in the second test. Could you clarify the intent?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The main difference is the VM state. In this one we are performing the backup of a paused VM to provide coverage for this use case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not to restore the VM?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

From the STP:

  • [CNV-79727] — As a cluster administrator, I want to verify that the opt-out annotation is honored for a paused VM, confirming hooks are not injected regardless of VM state
    • Test Scenario: [Tier 2] Deploy a VM configured to opt out of backup hooks and pause it. Run a Velero backup. Confirm no hooks were attempted and the backup completed successfully.

This case proves the annotation is honored for a paused state, while the next one proves the full backup/restore works without hooks. From my understanding, the restore doesn't know or care if the state of VM when backing up was paused or running.

"""
Test that backup of paused VM completes with hooks disabled.

Preconditions:
- VM with backup hooks disabled, paused

Steps:
1. Run Velero backup

Expected:
Backup completes successfully without freeze/unfreeze hook execution
"""

@pytest.mark.polarion("CNV-16268")
def test_full_backup_restore_hooks_disabled(self):
"""
Test that full backup/restore cycle completes with hooks disabled.

Preconditions:
- Running VM with backup hooks disabled

Steps:
1. Run Velero backup
2. Delete VM and namespace
3. Restore from backup

Expected:
VM is restored and running after backup/restore cycle
"""