-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathtest_velero.py
More file actions
155 lines (136 loc) · 4.6 KB
/
test_velero.py
File metadata and controls
155 lines (136 loc) · 4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import pytest
from ocp_resources.datavolume import DataVolume
from tests.data_protection.oadp.utils import FILE_PATH_FOR_WINDOWS_BACKUP, wait_for_restored_dv
from utilities.constants import (
FILE_NAME_FOR_BACKUP,
TEXT_TO_TEST,
TIMEOUT_10SEC,
TIMEOUT_15MIN,
Images,
)
from utilities.oadp import check_file_in_running_vm
from utilities.virt import verify_file_in_windows_vm, wait_for_running_vm
pytestmark = pytest.mark.usefixtures("skip_if_no_storage_class_for_snapshot")
@pytest.mark.s390x
@pytest.mark.parametrize(
"velero_backup_single_namespace",
[
pytest.param(
{
"wait_complete": False,
},
marks=pytest.mark.polarion("CNV-8580"),
),
],
indirect=True,
)
def test_backup_while_dv_create(
imported_dv_in_progress_second_namespace,
velero_backup_single_namespace,
):
velero_backup_single_namespace.wait_for_status(status="PartiallyFailed")
@pytest.mark.s390x
@pytest.mark.parametrize(
"rhel_vm_with_data_volume_template",
[
pytest.param(
{
"dv_name": "dv-8695",
"vm_name": "vm-8695",
"volume_mode": DataVolume.VolumeMode.BLOCK,
"rhel_image": Images.Rhel.RHEL9_3_IMG,
},
marks=pytest.mark.polarion("CNV-8695"),
),
],
indirect=True,
)
def test_restore_multiple_namespaces(
imported_dv_second_namespace,
rhel_vm_with_data_volume_template,
velero_restore_multiple_namespaces,
):
imported_dv_second_namespace.wait_for_status(
status=DataVolume.Status.SUCCEEDED,
timeout=TIMEOUT_10SEC,
stop_status=DataVolume.Status.IMPORT_IN_PROGRESS,
)
check_file_in_running_vm(
vm=rhel_vm_with_data_volume_template, file_name=FILE_NAME_FOR_BACKUP, file_content=TEXT_TO_TEST
)
@pytest.mark.s390x
@pytest.mark.parametrize(
"rhel_vm_with_data_volume_template",
[
pytest.param(
{
"dv_name": "block-dv",
"vm_name": "block-vm",
"volume_mode": DataVolume.VolumeMode.BLOCK,
"rhel_image": Images.Rhel.RHEL9_3_IMG,
},
marks=pytest.mark.polarion("CNV-10564"),
),
pytest.param(
{
"dv_name": "filesystem-dv",
"vm_name": "filesystem-vm",
"volume_mode": DataVolume.VolumeMode.FILE,
"rhel_image": Images.Rhel.RHEL9_3_IMG,
},
marks=pytest.mark.polarion("CNV-10565"),
),
],
indirect=True,
)
@pytest.mark.usefixtures("velero_restore_first_namespace_with_datamover")
def test_backup_vm_data_volume_template_with_datamover(rhel_vm_with_data_volume_template):
check_file_in_running_vm(
vm=rhel_vm_with_data_volume_template, file_name=FILE_NAME_FOR_BACKUP, file_content=TEXT_TO_TEST
)
@pytest.mark.tier3
@pytest.mark.polarion("CNV-8696")
@pytest.mark.usefixtures("velero_restore_first_namespace_without_datamover")
def test_backup_and_restore_windows_vm(windows_vm_with_data_volume_template):
"""
Test Windows VM backup and restore without Data Mover using Velero snapshot.
Preconditions:
- Windows VM with a marker file containing test data
- Velero backup created without Data Mover
- Velero restore completed
Steps:
1. Wait for Windows VM to reach Running state
2. Verify marker file exists at expected path
3. Verify file content matches pre-backup text
Expected:
- Windows VM is Running
- Marker file content equals TEXT_TO_TEST
"""
wait_for_running_vm(
vm=windows_vm_with_data_volume_template,
wait_until_running_timeout=TIMEOUT_15MIN,
)
verify_file_in_windows_vm(
windows_vm=windows_vm_with_data_volume_template,
file_name_with_path=FILE_PATH_FOR_WINDOWS_BACKUP,
file_content=TEXT_TO_TEST,
)
@pytest.mark.s390x
@pytest.mark.polarion("CNV-10589")
@pytest.mark.usefixtures("velero_restore_second_namespace_with_datamover")
def test_restore_vm_with_existing_dv(rhel_vm_from_existing_dv):
check_file_in_running_vm(vm=rhel_vm_from_existing_dv, file_name=FILE_NAME_FOR_BACKUP, file_content=TEXT_TO_TEST)
@pytest.mark.s390x
@pytest.mark.polarion("CNV-10590")
def test_restore_cloned_dv(
cloned_rhel_dv,
velero_restore_second_namespace_with_datamover,
):
wait_for_restored_dv(dv=cloned_rhel_dv)
@pytest.mark.s390x
@pytest.mark.polarion("CNV-10591")
def test_restore_uploaded_dv(
uploaded_rhel_dv,
velero_restore_second_namespace_with_datamover,
):
wait_for_restored_dv(dv=uploaded_rhel_dv)