Skip to content

Commit 9c06df0

Browse files
committed
merge to main
2 parents 16f4613 + ab8668b commit 9c06df0

File tree

2 files changed

+61
-7
lines changed

2 files changed

+61
-7
lines changed

tests/infrastructure/golden_images/update_boot_source/test_ssp_data_import_crons.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616
CUSTOM_DATA_SOURCE_NAME,
1717
DEFAULT_FEDORA_REGISTRY_URL,
1818
)
19-
from tests.infrastructure.golden_images.update_boot_source.utils import (
20-
template_labels,
19+
from utilities.constants import (
20+
BIND_IMMEDIATE_ANNOTATION,
21+
TIMEOUT_1MIN,
22+
TIMEOUT_2MIN,
23+
TIMEOUT_5MIN,
24+
TIMEOUT_10MIN,
25+
Images,
2126
)
22-
from utilities.constants import BIND_IMMEDIATE_ANNOTATION, TIMEOUT_1MIN, TIMEOUT_2MIN, TIMEOUT_5MIN, TIMEOUT_10MIN
2327
from utilities.hco import ResourceEditorValidateHCOReconcile
2428
from utilities.infra import create_ns
2529
from utilities.ssp import (
@@ -32,7 +36,7 @@
3236
DATA_IMPORT_CRON_SUFFIX,
3337
data_volume_template_with_source_ref_dict,
3438
)
35-
from utilities.virt import DV_DISK, VirtualMachineForTests, VirtualMachineForTestsFromTemplate, running_vm
39+
from utilities.virt import DV_DISK, VirtualMachineForTests, running_vm
3640

3741
LOGGER = logging.getLogger(__name__)
3842

@@ -157,12 +161,12 @@ def reconciled_custom_data_source(custom_data_source_scope_function):
157161

158162
@pytest.fixture()
159163
def vm_from_custom_data_import_cron(custom_data_source_scope_function, namespace, local_unprivileged_client):
160-
with VirtualMachineForTestsFromTemplate(
164+
with VirtualMachineForTests(
161165
name=f"{custom_data_source_scope_function.name}-vm",
162166
namespace=namespace.name,
163167
client=local_unprivileged_client,
164-
labels=template_labels(os="fedora40"),
165-
data_source=custom_data_source_scope_function,
168+
memory_guest=Images.Fedora.DEFAULT_MEMORY_SIZE,
169+
data_volume_template=data_volume_template_with_source_ref_dict(data_source=custom_data_source_scope_function),
166170
) as vm:
167171
running_vm(vm=vm)
168172
yield vm
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Test to verify all HCO deployments have 'openshift.io/required-scc' annotation.
4+
"""
5+
6+
import pytest
7+
from ocp_resources.deployment import Deployment
8+
9+
from utilities.constants import ALL_CNV_DEPLOYMENTS_NO_HPP_POOL
10+
11+
REQUIRED_SCC_ANNOTATION = "openshift.io/required-scc"
12+
REQUIRED_SCC_VALUE = "restricted-v2"
13+
14+
15+
@pytest.fixture(scope="module")
16+
def required_scc_deployment_check(admin_client, hco_namespace):
17+
missing_required_scc_annotation = []
18+
incorrect_required_scc_annotation_value = {}
19+
20+
for dp in (
21+
Deployment(client=admin_client, name=name, namespace=hco_namespace.name)
22+
for name in ALL_CNV_DEPLOYMENTS_NO_HPP_POOL
23+
):
24+
scc = dp.instance.spec.template.metadata.annotations.get(REQUIRED_SCC_ANNOTATION)
25+
26+
if scc is None:
27+
missing_required_scc_annotation.append(dp.name)
28+
elif scc != REQUIRED_SCC_VALUE:
29+
incorrect_required_scc_annotation_value[dp.name] = scc
30+
31+
return {
32+
"missing_required_scc_annotation": missing_required_scc_annotation,
33+
"incorrect_required_scc_annotation_value": incorrect_required_scc_annotation_value,
34+
}
35+
36+
37+
@pytest.mark.polarion("CNV-11964")
38+
def test_deployments_missing_required_scc_annotation(required_scc_deployment_check):
39+
assert not required_scc_deployment_check["missing_required_scc_annotation"], (
40+
f"Deployments missing {REQUIRED_SCC_ANNOTATION} annotation: "
41+
f"{required_scc_deployment_check['missing_required_scc_annotation']}"
42+
)
43+
44+
45+
@pytest.mark.polarion("CNV-11965")
46+
def test_deployments_with_incorrect_required_scc(required_scc_deployment_check):
47+
assert not required_scc_deployment_check["incorrect_required_scc_annotation_value"], (
48+
f"Deployments incorrect {REQUIRED_SCC_ANNOTATION} annotation : "
49+
f"{required_scc_deployment_check['incorrect_required_scc_annotation_value']}"
50+
)

0 commit comments

Comments
 (0)