diff --git a/tests/install_upgrade_operators/launcher_updates/test_default_launcher_updates.py b/tests/install_upgrade_operators/launcher_updates/test_default_launcher_updates.py deleted file mode 100644 index 49c17dbfb3..0000000000 --- a/tests/install_upgrade_operators/launcher_updates/test_default_launcher_updates.py +++ /dev/null @@ -1,67 +0,0 @@ -import logging - -import pytest - -from tests.install_upgrade_operators.constants import WORKLOAD_UPDATE_STRATEGY_KEY_NAME, WORKLOADUPDATEMETHODS -from tests.install_upgrade_operators.launcher_updates.constants import ( - DEFAULT_BATCH_EVICTION_INTERVAL, - DEFAULT_BATCH_EVICTION_SIZE, - DEFAULT_WORKLOAD_UPDATE_METHODS, -) -from tests.install_upgrade_operators.utils import wait_for_spec_change -from utilities.hco import get_hco_spec, wait_for_hco_conditions -from utilities.virt import get_hyperconverged_kubevirt - -pytestmark = [pytest.mark.sno, pytest.mark.arm64, pytest.mark.s390x] -LOGGER = logging.getLogger(__name__) - - -@pytest.mark.parametrize( - "resource_name, expected", - [ - pytest.param( - "hyperconverged", - { - "batchEvictionInterval": DEFAULT_BATCH_EVICTION_INTERVAL, - "batchEvictionSize": DEFAULT_BATCH_EVICTION_SIZE, - WORKLOADUPDATEMETHODS: DEFAULT_WORKLOAD_UPDATE_METHODS, - }, - marks=(pytest.mark.polarion("CNV-6911"),), - id="test_hyperconverged_default_workload_update_strategy", - ), - pytest.param( - "kubevirt", - { - "batchEvictionInterval": DEFAULT_BATCH_EVICTION_INTERVAL, - "batchEvictionSize": DEFAULT_BATCH_EVICTION_SIZE, - WORKLOADUPDATEMETHODS: DEFAULT_WORKLOAD_UPDATE_METHODS, - }, - marks=pytest.mark.polarion("CNV-6912"), - id="test_kubevirt_default_workload_update_strategy", - ), - ], -) -def test_default_workload_update_strategy(admin_client, hco_namespace, resource_name, expected): - """Validates by default, hyperconverged's and kubevirt's spec.workloadUpdateStrategy is set to correct values""" - LOGGER.info("Ensure HCO is is in stable condition before checking for spec.workloadUpdateStrategy") - LOGGER.info(f"Validating default values:{expected} for :{resource_name}") - wait_for_hco_conditions( - admin_client=admin_client, - hco_namespace=hco_namespace, - ) - if resource_name == "hyperconverged": - wait_for_spec_change( - expected=expected, - get_spec_func=lambda: get_hco_spec(admin_client=admin_client, hco_namespace=hco_namespace), - base_path=[WORKLOAD_UPDATE_STRATEGY_KEY_NAME], - ) - elif resource_name == "kubevirt": - wait_for_spec_change( - expected=expected, - get_spec_func=lambda: get_hyperconverged_kubevirt(admin_client=admin_client, hco_namespace=hco_namespace) - .instance.to_dict() - .get("spec"), - base_path=[WORKLOAD_UPDATE_STRATEGY_KEY_NAME], - ) - else: - raise AssertionError(f"Unexpected resource name: {resource_name}") diff --git a/tests/install_upgrade_operators/product_uninstall/test_remove_kubevirt.py b/tests/install_upgrade_operators/product_uninstall/test_remove_kubevirt.py index e762a78e4c..6eaeda5d7a 100644 --- a/tests/install_upgrade_operators/product_uninstall/test_remove_kubevirt.py +++ b/tests/install_upgrade_operators/product_uninstall/test_remove_kubevirt.py @@ -34,15 +34,6 @@ def remove_kubevirt_vm(unprivileged_client, namespace): yield vm -@pytest.mark.polarion("CNV-3738") -@pytest.mark.s390x -def test_validate_default_uninstall_strategy(kubevirt_resource): - strategy = kubevirt_resource.instance.spec.uninstallStrategy - assert strategy == "BlockUninstallIfWorkloadsExist", ( - f"Default uninstall strategy is incorrect.Expected 'BlockUninstallIfWorkloadsExist', found '{strategy}'" - ) - - @pytest.mark.polarion("CNV-3718") @pytest.mark.destructive def test_block_removal(kubevirt_resource, remove_kubevirt_vm): diff --git a/tests/install_upgrade_operators/relationship_labels/constants.py b/tests/install_upgrade_operators/relationship_labels/constants.py index a413838ea2..84352b6200 100644 --- a/tests/install_upgrade_operators/relationship_labels/constants.py +++ b/tests/install_upgrade_operators/relationship_labels/constants.py @@ -81,12 +81,6 @@ MANAGED_BY_LABEL_KEY = f"{Resource.ApiGroup.APP_KUBERNETES_IO}/managed-by" COMPONENT_LABEL_KEY = f"{Resource.ApiGroup.APP_KUBERNETES_IO}/component" PART_OF_LABEL_KEY = f"{Resource.ApiGroup.APP_KUBERNETES_IO}/part-of" -ALL_LABEL_KEYS = [ - MANAGED_BY_LABEL_KEY, - VERSION_LABEL_KEY, - COMPONENT_LABEL_KEY, - PART_OF_LABEL_KEY, -] # Daemonset expected labels EXPECTED_VIRT_DAEMONSETS_LABELS_DICT_MAP = { BRIDGE_MARKER: { diff --git a/tests/install_upgrade_operators/relationship_labels/test_all_cnv_resources.py b/tests/install_upgrade_operators/relationship_labels/test_all_cnv_resources.py deleted file mode 100644 index c50ec91ef4..0000000000 --- a/tests/install_upgrade_operators/relationship_labels/test_all_cnv_resources.py +++ /dev/null @@ -1,150 +0,0 @@ -import logging -import subprocess - -import pytest - -from tests.install_upgrade_operators.relationship_labels.constants import ALL_LABEL_KEYS -from tests.install_upgrade_operators.utils import ( - get_ocp_resource_module_name, - get_resource, -) -from utilities.exceptions import ResourceValueError -from utilities.infra import is_jira_open - -pytestmark = [pytest.mark.arm64, pytest.mark.s390x] - -ALLOWLIST_STRING_LIST = [ - "dockercfg", - "token", - "openshift-service-ca.crt", - "kube-root-ca.crt", - "builder", - "default", - "deployer", - "system:image-pullers", - "system:image-builders", - "virt-template-validator-certs", - "plugin-serving-cert", - "console-proxy-serving-cert", - "hyperconverged-cluster-operator-lock", - "kubevirt-ipam-controller-webhook-service", - "istio-ca-root-cert", - "istio-ca-crl", -] -PRINT_COMMAND = '{printf "%s%s",sep,$0;sep=","}' -AWK_COMMAND = f"awk '{PRINT_COMMAND}'" -COLUMNS = "KIND:.kind,NAME:.metadata.name,NAMESPACE:.metadata.namespace" -COMMAND_OPT = f"--ignore-not-found {{namespace}} -o=custom-columns={COLUMNS} --sort-by='.metadata.namespace'" -ALL_RESOURCE_COMMAND = f"oc get $(oc api-resources --verbs=list -o name | {AWK_COMMAND})" - -SKIP_LABEL_CHECKS = [ - "OperatorCondition", - "Subscription", - "InstallPlan", - "ClusterServiceVersion", - "Event", - "PackageManifest", - "HyperConverged", - "OperatorGroup", - "CSIStorageCapacity", - "Lease", - "ReclaimSpaceJob", - "ReclaimSpaceCronJob", -] -LOGGER = logging.getLogger(__name__) -OPEN_JIRA = { - "Endpoints": { - "CNV-28182": ["virt-controller", "virt-operator"], - }, - "ConfigMap": { - "CNV-28182": ["kubevirt-install-strategy"], - "CNV-75722": ["kubevirt-migration-controller-config"], - }, -} - - -def is_jira_allowlisted(kind: str, resource_name: str) -> bool: - for jira_key, allowed_names in OPEN_JIRA.get(kind, {}).items(): - if is_jira_open(jira_id=jira_key) and any( - resource_name.startswith(allowed_name) for allowed_name in allowed_names - ): - return True - return False - - -def get_all_api_resources( - namespace_opt, -): - resources_dict = {} - command = f"{ALL_RESOURCE_COMMAND} {COMMAND_OPT.format(namespace=namespace_opt)} --no-headers 2>/dev/null" - output = subprocess.getoutput(command).splitlines() - hco_namespace = namespace_opt.split()[-1] - for line in output: - kind, name, namespace = " ".join(line.split()).split(" ") - if namespace == hco_namespace: - resources_dict.setdefault(kind, []).append(name) - - return resources_dict - - -@pytest.fixture() -def cnv_resources(hco_namespace): - return get_all_api_resources(namespace_opt=f"-n {hco_namespace.name}") - - -@pytest.mark.polarion("CNV-10307") -def test_relationship_labels_all_cnv_resources( - ocp_resources_submodule_list, admin_client, cnv_resources, hco_namespace -): - errors = {} - for kind in cnv_resources: - LOGGER.debug(f"Looking at kind: {kind}") - if kind in SKIP_LABEL_CHECKS: - LOGGER.warning(f"Skip checking for kind: {kind}") - continue - for name in cnv_resources[kind]: - if any(substring in name for substring in ALLOWLIST_STRING_LIST): - LOGGER.debug(f"{kind}, {name} is allowlisted") - continue - LOGGER.debug(f"Looking at element: {name}, kind: {kind}") - resource_obj = get_resource( - related_obj={ - "kind": kind, - "name": name, - "namespace": hco_namespace.name, - }, - module_name=get_ocp_resource_module_name( - related_object_kind=kind, - list_submodules=ocp_resources_submodule_list, - ), - admin_client=admin_client, - ) - if resource_obj.exists: - labels = resource_obj.instance.metadata.labels - if not labels: - if not is_jira_allowlisted(kind=kind, resource_name=name): - errors.setdefault(kind, []).append(f"{name} has no labels") - else: - if set(ALL_LABEL_KEYS).issubset(set(labels.keys())): - continue - else: - # Some labels are missing, we need to check if the resources are olm managed or - # allowlisted. - LOGGER.debug( - f"Checking for kind: {kind} resource: {name} for allowlisting: {set(labels.keys())}" - ) - if (labels.get("olm.managed") and labels["olm.managed"] == "true") or is_jira_allowlisted( - kind=kind, resource_name=name - ): - LOGGER.warning(f"kind: {kind} resource: {name} is olm managed or allowlisted by jira") - continue - - else: - errors.setdefault(kind, []).append( - f'{name} has missing labels. Current labels are "{labels}" and is not managed by olm' - ) - else: - errors.setdefault(kind, []).append(f"{name} resource not found") - if errors: - LOGGER.error(errors) - raise ResourceValueError(errors) diff --git a/tests/install_upgrade_operators/strict_reconciliation/conftest.py b/tests/install_upgrade_operators/strict_reconciliation/conftest.py index 70b47d9436..484ed9d010 100644 --- a/tests/install_upgrade_operators/strict_reconciliation/conftest.py +++ b/tests/install_upgrade_operators/strict_reconciliation/conftest.py @@ -130,21 +130,6 @@ def hco_with_non_default_feature_gates( yield -@pytest.fixture() -def cr_func_map( - hco_spec, - kubevirt_hyperconverged_spec_scope_function, - cdi_spec, - network_addons_config_scope_session, -): - yield { - "hco": hco_spec, - "kubevirt": kubevirt_hyperconverged_spec_scope_function, - "cdi": cdi_spec, - "cnao": network_addons_config_scope_session.instance.to_dict(), - } - - @pytest.fixture() def hco_status_related_objects_scope_function(hyperconverged_resource_scope_function): """ diff --git a/tests/install_upgrade_operators/strict_reconciliation/test_hco_cr_defaults_on_stanza_deletion.py b/tests/install_upgrade_operators/strict_reconciliation/test_hco_cr_defaults_on_stanza_deletion.py deleted file mode 100644 index e02ce968cb..0000000000 --- a/tests/install_upgrade_operators/strict_reconciliation/test_hco_cr_defaults_on_stanza_deletion.py +++ /dev/null @@ -1,440 +0,0 @@ -import logging - -import pytest -from benedict import benedict -from ocp_resources.cdi import CDI -from ocp_resources.kubevirt import KubeVirt -from ocp_resources.network_addons_config import NetworkAddonsConfig - -from tests.install_upgrade_operators.constants import ( - HCO_CR_CERT_CONFIG_CA_KEY, - HCO_CR_CERT_CONFIG_DURATION_KEY, - HCO_CR_CERT_CONFIG_KEY, - HCO_CR_CERT_CONFIG_RENEW_BEFORE_KEY, - HCO_CR_CERT_CONFIG_SERVER_KEY, -) -from tests.install_upgrade_operators.strict_reconciliation.constants import ( - CERTC_CUSTOM_18H, - CERTC_CUSTOM_36H, - CERTC_CUSTOM_96H, - COMPLETION_TIMEOUT_PER_GIB_KEY, - EXPCT_CERTC_CUSTOM_CA_DUR, - EXPCT_CERTC_CUSTOM_CA_RB, - EXPCT_CERTC_CUSTOM_SERVER_DUR, - EXPCT_CERTC_CUSTOM_SERVER_RB, - EXPCT_CERTC_DEFAULTS, - EXPCT_LM_CUSTOM_C, - EXPCT_LM_CUSTOM_PM, - EXPCT_LM_CUSTOM_PO, - EXPCT_LM_CUSTOM_PT, - EXPCT_LM_DEFAULTS, - LIVE_MIGRATION_CONFIG_KEY, - LM_COMPLETIONTIMEOUTPERGIB_CUSTOM, - LM_PARALLELMIGRATIONSPERCLUSTER_CUSTOM, - LM_PARALLELOUTBOUNDMIGRATIONSPERNODE_CUSTOM, - LM_PROGRESSTIMEOUT_CUSTOM, - PARALLEL_MIGRATIONS_PER_CLUSTER_KEY, - PARALLEL_OUTBOUND_MIGRATIONS_PER_NODE_KEY, - PROGRESS_TIMEOUT_KEY, -) -from utilities.hco import wait_for_hco_conditions - -pytestmark = [pytest.mark.post_upgrade, pytest.mark.sno, pytest.mark.arm64, pytest.mark.s390x] - -LOGGER = logging.getLogger(__name__) - - -class TestCRDefaultsOnStanzaDeletion: - @pytest.mark.parametrize( - "deleted_stanza_on_hco_cr, expected", - [ - pytest.param( - { - "rpatch": { - "spec": { - HCO_CR_CERT_CONFIG_KEY: {HCO_CR_CERT_CONFIG_CA_KEY: {HCO_CR_CERT_CONFIG_DURATION_KEY: None}} - } - }, - }, - EXPCT_CERTC_DEFAULTS, - id="defaults_cr_ca_duration_none", - marks=(pytest.mark.polarion("CNV-6377")), - ), - pytest.param( - { - "rpatch": { - "spec": { - HCO_CR_CERT_CONFIG_KEY: { - HCO_CR_CERT_CONFIG_CA_KEY: {HCO_CR_CERT_CONFIG_RENEW_BEFORE_KEY: None} - } - } - }, - }, - EXPCT_CERTC_DEFAULTS, - id="defaults_cr_ca_renewbefore_none", - marks=(pytest.mark.polarion("CNV-6378")), - ), - pytest.param( - { - "rpatch": {"spec": {HCO_CR_CERT_CONFIG_KEY: {HCO_CR_CERT_CONFIG_CA_KEY: {}}}}, - }, - EXPCT_CERTC_DEFAULTS, - id="defaults_cr_ca_empty", - marks=(pytest.mark.polarion("CNV-6379")), - ), - pytest.param( - { - "rpatch": {"spec": {HCO_CR_CERT_CONFIG_KEY: {HCO_CR_CERT_CONFIG_CA_KEY: None}}}, - }, - EXPCT_CERTC_DEFAULTS, - id="defaults_cr_ca_none", - marks=(pytest.mark.polarion("CNV-6380")), - ), - pytest.param( - { - "rpatch": { - "spec": { - HCO_CR_CERT_CONFIG_KEY: { - HCO_CR_CERT_CONFIG_SERVER_KEY: {HCO_CR_CERT_CONFIG_DURATION_KEY: None} - } - } - }, - }, - EXPCT_CERTC_DEFAULTS, - id="defaults_cr_server_duration_none", - marks=(pytest.mark.polarion("CNV-6381")), - ), - pytest.param( - { - "rpatch": { - "spec": { - HCO_CR_CERT_CONFIG_KEY: { - HCO_CR_CERT_CONFIG_SERVER_KEY: {HCO_CR_CERT_CONFIG_RENEW_BEFORE_KEY: None} - } - } - }, - }, - EXPCT_CERTC_DEFAULTS, - id="defaults_cr_server_renewbefore_none", - marks=(pytest.mark.polarion("CNV-6382")), - ), - pytest.param( - { - "rpatch": {"spec": {HCO_CR_CERT_CONFIG_KEY: {HCO_CR_CERT_CONFIG_SERVER_KEY: {}}}}, - }, - EXPCT_CERTC_DEFAULTS, - id="defaults_cr_server_empty", - marks=(pytest.mark.polarion("CNV-6383")), - ), - pytest.param( - { - "rpatch": {"spec": {HCO_CR_CERT_CONFIG_KEY: {HCO_CR_CERT_CONFIG_SERVER_KEY: None}}}, - }, - EXPCT_CERTC_DEFAULTS, - id="defaults_cr_server_none", - marks=(pytest.mark.polarion("CNV-6384")), - ), - pytest.param( - { - "rpatch": {"spec": {HCO_CR_CERT_CONFIG_KEY: {}}}, - }, - EXPCT_CERTC_DEFAULTS, - id="defaults_cr_empty", - marks=(pytest.mark.polarion("CNV-6385")), - ), - pytest.param( - { - "rpatch": {"spec": {HCO_CR_CERT_CONFIG_KEY: None}}, - }, - EXPCT_CERTC_DEFAULTS, - id="defaults_cr_none", - marks=(pytest.mark.polarion("CNV-6386")), - ), - pytest.param( - { - "rpatch": {"spec": {}}, - }, - EXPCT_CERTC_DEFAULTS, - id="defaults_cr_spec_empty", - marks=(pytest.mark.polarion("CNV-6387")), - ), - pytest.param( - { - "rpatch": {"spec": None}, - }, - EXPCT_CERTC_DEFAULTS, - id="defaults_cr_spec_none", - marks=(pytest.mark.polarion("CNV-6388")), - ), - pytest.param( - { - "rpatch": {}, - }, - EXPCT_CERTC_DEFAULTS, - id="defaults_cr_empty", - marks=(pytest.mark.polarion("CNV-6389")), - ), - pytest.param( - { - "rpatch": { - "spec": { - HCO_CR_CERT_CONFIG_KEY: { - HCO_CR_CERT_CONFIG_CA_KEY: {HCO_CR_CERT_CONFIG_DURATION_KEY: CERTC_CUSTOM_96H} - } - } - }, - "list_resource_reconcile": [NetworkAddonsConfig, CDI], - }, - EXPCT_CERTC_CUSTOM_CA_DUR, - id="defaults_cr_custom_ca_dur", - marks=(pytest.mark.polarion("CNV-6390")), - ), - pytest.param( - { - "rpatch": { - "spec": { - HCO_CR_CERT_CONFIG_KEY: { - HCO_CR_CERT_CONFIG_CA_KEY: {HCO_CR_CERT_CONFIG_RENEW_BEFORE_KEY: CERTC_CUSTOM_36H} - } - } - }, - "list_resource_reconcile": [NetworkAddonsConfig, CDI], - }, - EXPCT_CERTC_CUSTOM_CA_RB, - id="defaults_cr_custom_ca_rb", - marks=(pytest.mark.polarion("CNV-6391")), - ), - pytest.param( - { - "rpatch": { - "spec": { - HCO_CR_CERT_CONFIG_KEY: { - HCO_CR_CERT_CONFIG_SERVER_KEY: {HCO_CR_CERT_CONFIG_DURATION_KEY: CERTC_CUSTOM_36H} - } - } - }, - "list_resource_reconcile": [NetworkAddonsConfig, CDI], - }, - EXPCT_CERTC_CUSTOM_SERVER_DUR, - id="defaults_cr_custom_server_dur", - marks=(pytest.mark.polarion("CNV-6392")), - ), - pytest.param( - { - "rpatch": { - "spec": { - HCO_CR_CERT_CONFIG_KEY: { - HCO_CR_CERT_CONFIG_SERVER_KEY: {HCO_CR_CERT_CONFIG_RENEW_BEFORE_KEY: CERTC_CUSTOM_18H} - } - } - }, - "list_resource_reconcile": [NetworkAddonsConfig, CDI], - }, - EXPCT_CERTC_CUSTOM_SERVER_RB, - id="defaults_cr_custom_server_rb", - marks=(pytest.mark.polarion("CNV-6393")), - ), - ], - indirect=["deleted_stanza_on_hco_cr"], - ) - def test_certconfig_defaults_on_stanza_delete( - self, - deleted_stanza_on_hco_cr, - hyperconverged_resource_scope_function, - expected, - ): - assert ( - hyperconverged_resource_scope_function.instance.to_dict().get("spec").get(HCO_CR_CERT_CONFIG_KEY) - == expected - ) - - @pytest.mark.parametrize( - "deleted_stanza_on_hco_cr, expected", - [ - pytest.param( - { - "rpatch": {"spec": {"featureGates": None}}, - }, - {"featureGates": None}, - id="defaults_fg_none", - marks=(pytest.mark.polarion("CNV-6397")), - ), - pytest.param( - { - "rpatch": {"spec": None}, - }, - {"spec": None}, - id="defaults_fg_spec_none", - marks=(pytest.mark.polarion("CNV-6399")), - ), - ], - indirect=["deleted_stanza_on_hco_cr"], - ) - def test_featuregates_defaults_on_stanza_delete( - self, - admin_client, - hco_namespace, - hco_spec_scope_module, - deleted_stanza_on_hco_cr, - hyperconverged_resource_scope_function, - expected, - ): - wait_for_hco_conditions( - admin_client=admin_client, - hco_namespace=hco_namespace, - consecutive_checks_count=6, - ) - for key, value in expected.items(): - current_spec = benedict(hyperconverged_resource_scope_function.instance.to_dict()["spec"]) - current_value = current_spec if key == "spec" else current_spec.get(key) - if value is not None: - assert current_value == value, f"Expected value of hco.{key}: {value}, actual: {current_value}" - else: - default_value = benedict(hco_spec_scope_module) - default_value = default_value if key == "spec" else default_value.get(key) - assert current_value == default_value, ( - f"Default value for hco.{key}: {default_value} does not match actual value: {current_value}" - ) - - @pytest.mark.parametrize( - "deleted_stanza_on_hco_cr, expected", - [ - pytest.param( - { - "rpatch": {"spec": {LIVE_MIGRATION_CONFIG_KEY: {PARALLEL_MIGRATIONS_PER_CLUSTER_KEY: None}}}, - }, - EXPCT_LM_DEFAULTS, - id="defaults_lm_pm_none", - marks=(pytest.mark.polarion("CNV-6403")), - ), - pytest.param( - { - "rpatch": {"spec": {LIVE_MIGRATION_CONFIG_KEY: {PARALLEL_OUTBOUND_MIGRATIONS_PER_NODE_KEY: None}}}, - }, - EXPCT_LM_DEFAULTS, - id="defaults_lm_po_none", - marks=(pytest.mark.polarion("CNV-6404")), - ), - pytest.param( - { - "rpatch": {"spec": {LIVE_MIGRATION_CONFIG_KEY: {COMPLETION_TIMEOUT_PER_GIB_KEY: None}}}, - }, - EXPCT_LM_DEFAULTS, - id="defaults_lm_c_none", - marks=(pytest.mark.polarion("CNV-6406")), - ), - pytest.param( - { - "rpatch": {"spec": {LIVE_MIGRATION_CONFIG_KEY: {PROGRESS_TIMEOUT_KEY: None}}}, - }, - EXPCT_LM_DEFAULTS, - id="defaults_lm_pt_none", - marks=(pytest.mark.polarion("CNV-6407")), - ), - pytest.param( - { - "rpatch": {"spec": {LIVE_MIGRATION_CONFIG_KEY: {}}}, - }, - EXPCT_LM_DEFAULTS, - id="defaults_lm_empty", - marks=(pytest.mark.polarion("CNV-6408")), - ), - pytest.param( - { - "rpatch": {"spec": {LIVE_MIGRATION_CONFIG_KEY: None}}, - }, - EXPCT_LM_DEFAULTS, - id="defaults_lm_none", - marks=(pytest.mark.polarion("CNV-6409")), - ), - pytest.param( - { - "rpatch": {"spec": {}}, - }, - EXPCT_LM_DEFAULTS, - id="defaults_lm_spec_empty", - marks=(pytest.mark.polarion("CNV-6410")), - ), - pytest.param( - { - "rpatch": {"spec": None}, - }, - EXPCT_LM_DEFAULTS, - id="defaults_lm_spec_none", - marks=(pytest.mark.polarion("CNV-6411")), - ), - pytest.param( - { - "rpatch": {}, - }, - EXPCT_LM_DEFAULTS, - id="defaults_lm_cr_empty", - marks=(pytest.mark.polarion("CNV-6412")), - ), - pytest.param( - { - "rpatch": { - "spec": { - LIVE_MIGRATION_CONFIG_KEY: { - PARALLEL_MIGRATIONS_PER_CLUSTER_KEY: LM_PARALLELMIGRATIONSPERCLUSTER_CUSTOM - } - }, - }, - "list_resource_reconcile": [KubeVirt], - }, - EXPCT_LM_CUSTOM_PM, - id="defaults_lm_custom_pm", - marks=(pytest.mark.polarion("CNV-6413")), - ), - pytest.param( - { - "rpatch": { - "spec": { - LIVE_MIGRATION_CONFIG_KEY: { - PARALLEL_OUTBOUND_MIGRATIONS_PER_NODE_KEY: LM_PARALLELOUTBOUNDMIGRATIONSPERNODE_CUSTOM - } - } - }, - "list_resource_reconcile": [KubeVirt], - }, - EXPCT_LM_CUSTOM_PO, - id="defaults_lm_custom_po", - marks=(pytest.mark.polarion("CNV-6414")), - ), - pytest.param( - { - "rpatch": { - "spec": { - LIVE_MIGRATION_CONFIG_KEY: { - COMPLETION_TIMEOUT_PER_GIB_KEY: LM_COMPLETIONTIMEOUTPERGIB_CUSTOM - } - } - }, - "list_resource_reconcile": [KubeVirt], - }, - EXPCT_LM_CUSTOM_C, - id="defaults_lm_custom_c", - marks=(pytest.mark.polarion("CNV-6416")), - ), - pytest.param( - { - "rpatch": {"spec": {LIVE_MIGRATION_CONFIG_KEY: {PROGRESS_TIMEOUT_KEY: LM_PROGRESSTIMEOUT_CUSTOM}}}, - "list_resource_reconcile": [KubeVirt], - }, - EXPCT_LM_CUSTOM_PT, - id="defaults_lm_custom_pt", - marks=(pytest.mark.polarion("CNV-6417")), - ), - ], - indirect=["deleted_stanza_on_hco_cr"], - ) - def test_livemigrationconfig_defaults_on_stanza_delete( - self, - deleted_stanza_on_hco_cr, - hyperconverged_resource_scope_function, - expected, - ): - assert ( - hyperconverged_resource_scope_function.instance.to_dict().get("spec").get(LIVE_MIGRATION_CONFIG_KEY) - == expected - ) diff --git a/tests/install_upgrade_operators/strict_reconciliation/test_operator_defaults.py b/tests/install_upgrade_operators/strict_reconciliation/test_operator_defaults.py deleted file mode 100644 index e000a4e6b5..0000000000 --- a/tests/install_upgrade_operators/strict_reconciliation/test_operator_defaults.py +++ /dev/null @@ -1,186 +0,0 @@ -import functools -import logging - -import pytest - -from tests.install_upgrade_operators.constants import HCO_CR_CERT_CONFIG_KEY -from tests.install_upgrade_operators.strict_reconciliation.constants import ( - CERTC_DEFAULT_12H, - CERTC_DEFAULT_24H, - CERTC_DEFAULT_48H, - CNAO_CR_CERT_CONFIG_CA_DURATION_KEY, - CNAO_CR_CERT_CONFIG_KEY_CA_RENEW_BEFORE_KEY, - CNAO_CR_CERT_CONFIG_KEY_SERVER_RENEW_BEFORE_KEY, - CNAO_CR_CERT_CONFIG_SERVER_DURATION_KEY, - EXPCT_LM_DEFAULTS, - KUBEVIRT_CR_CERT_CONFIG_SELF_SIGNED_KEY, - LIVE_MIGRATION_CONFIG_BANDWIDTH_PER_MIGRATION_KEY, - LIVE_MIGRATION_CONFIG_KEY, -) -from tests.install_upgrade_operators.strict_reconciliation.utils import ( - compare_expected_with_cr, - expected_certconfig_stanza, -) - -pytestmark = [ - pytest.mark.post_upgrade, - pytest.mark.sno, - pytest.mark.gating, - pytest.mark.arm64, - pytest.mark.s390x, - pytest.mark.conformance, -] - -LOGGER = logging.getLogger(__name__) - - -class TestOperatorsDefaults: - @pytest.mark.parametrize( - ("expected", "resource_kind_str", "subkeys_list"), - [ - pytest.param( - expected_certconfig_stanza(), - "hco", - [HCO_CR_CERT_CONFIG_KEY], - marks=(pytest.mark.polarion("CNV-6108"),), - id="verify_defaults_certconfig_hco_cr", - ), - pytest.param( - expected_certconfig_stanza(), - "cdi", - [HCO_CR_CERT_CONFIG_KEY], - marks=(pytest.mark.polarion("CNV-6109"),), - id="verify_defaults_certconfig_cdi_cr", - ), - pytest.param( - expected_certconfig_stanza(), - "kubevirt", - [ - "certificateRotateStrategy", - KUBEVIRT_CR_CERT_CONFIG_SELF_SIGNED_KEY, - ], - marks=(pytest.mark.polarion("CNV-6111"),), - id="verify_defaults_certconfig_kubevirt_cr", - ), - pytest.param( - { - "spec": { - "selfSignConfiguration": { - CNAO_CR_CERT_CONFIG_CA_DURATION_KEY: CERTC_DEFAULT_48H, - CNAO_CR_CERT_CONFIG_KEY_CA_RENEW_BEFORE_KEY: CERTC_DEFAULT_24H, - CNAO_CR_CERT_CONFIG_SERVER_DURATION_KEY: CERTC_DEFAULT_24H, - CNAO_CR_CERT_CONFIG_KEY_SERVER_RENEW_BEFORE_KEY: CERTC_DEFAULT_12H, - } - } - }, - "cnao", - [], - marks=(pytest.mark.polarion("CNV-6112"),), - id="verify_defaults_certconfig_cnao_cr", - ), - pytest.param( - { - LIVE_MIGRATION_CONFIG_KEY: EXPCT_LM_DEFAULTS, - }, - "hco", - [], - marks=(pytest.mark.polarion("CNV-6122"),), - id="verify_defaults_livemigrationconfig_hco_cr", - ), - pytest.param( - { - "configuration": { - "migrations": EXPCT_LM_DEFAULTS, - } - }, - "kubevirt", - [], - marks=(pytest.mark.polarion("CNV-6652"),), - id="verify_defaults_livemigrationconfig_kubevirt_cr", - ), - pytest.param( - { - "obsoleteCPUModels": { - "486": True, - "Conroe": True, - "athlon": True, - "core2duo": True, - "coreduo": True, - "kvm32": True, - "kvm64": True, - "n270": True, - "pentium": True, - "pentium2": True, - "pentium3": True, - "pentiumpro": True, - "phenom": True, - "qemu32": True, - "qemu64": True, - }, - }, - "kubevirt", - ["configuration"], - marks=(pytest.mark.polarion("CNV-6125"),), - id="verify_defaults_obsoleteCPUModels_kubevirt_cr", - ), - ], - ) - def test_verify_expected_config_in_crs( - self, - expected, - resource_kind_str, - subkeys_list, - cr_func_map, - ): - """ - Verify the default values for all stanzas that have defaults in all CRs - """ - assert not compare_expected_with_cr( - expected=expected, - actual=functools.reduce( - lambda spec, subkeys: spec[subkeys], - subkeys_list, - cr_func_map[resource_kind_str], - ), - ) - - @pytest.mark.parametrize( - "expected_to_be_absent, resource_kind_str", - [ - pytest.param( - "obsoletecpu", - "hco", - marks=(pytest.mark.polarion("CNV-6124"),), - id="verify_no_defaults_obsoletecpu_hco_cr", - ), - pytest.param( - "permitted", - "hco", - marks=(pytest.mark.polarion("CNV-6653"),), - id="verify_no_defaults_permittedhostdevices_hco_cr", - ), - pytest.param( - "permitted", - "kubevirt", - marks=(pytest.mark.polarion("CNV-6654"),), - id="verify_no_defaults_permittedhostdevices_kubevirt_cr", - ), - ], - ) - def test_no_defaults_in_cr_for_permittedhostdevices_and_obsoletecpu( - self, - expected_to_be_absent, - resource_kind_str, - cr_func_map, - ): - assert expected_to_be_absent not in str(cr_func_map[resource_kind_str]).lower() - - @pytest.mark.polarion("CNV-7312") - def test_bandwidthpermigration_does_not_exist_in_hco_cr( - self, - hco_spec, - ): - assert LIVE_MIGRATION_CONFIG_BANDWIDTH_PER_MIGRATION_KEY not in hco_spec[LIVE_MIGRATION_CONFIG_KEY], ( - "the key exists, not as expected: " - f"key={LIVE_MIGRATION_CONFIG_BANDWIDTH_PER_MIGRATION_KEY} spec={hco_spec[LIVE_MIGRATION_CONFIG_KEY]}" - ) diff --git a/tests/install_upgrade_operators/strict_reconciliation/utils.py b/tests/install_upgrade_operators/strict_reconciliation/utils.py index 537faec0fa..84f049ec54 100644 --- a/tests/install_upgrade_operators/strict_reconciliation/utils.py +++ b/tests/install_upgrade_operators/strict_reconciliation/utils.py @@ -3,17 +3,6 @@ from dictdiffer import diff from timeout_sampler import TimeoutExpiredError, TimeoutSampler -from tests.install_upgrade_operators.constants import ( - HCO_CR_CERT_CONFIG_CA_KEY, - HCO_CR_CERT_CONFIG_DURATION_KEY, - HCO_CR_CERT_CONFIG_RENEW_BEFORE_KEY, - HCO_CR_CERT_CONFIG_SERVER_KEY, -) -from tests.install_upgrade_operators.strict_reconciliation.constants import ( - CERTC_DEFAULT_12H, - CERTC_DEFAULT_24H, - CERTC_DEFAULT_48H, -) from tests.install_upgrade_operators.utils import ( get_function_name, get_network_addon_config, @@ -106,19 +95,6 @@ def compare_expected_with_cr(expected, actual): ) -def expected_certconfig_stanza(): - return { - HCO_CR_CERT_CONFIG_CA_KEY: { - HCO_CR_CERT_CONFIG_DURATION_KEY: CERTC_DEFAULT_48H, - HCO_CR_CERT_CONFIG_RENEW_BEFORE_KEY: CERTC_DEFAULT_24H, - }, - HCO_CR_CERT_CONFIG_SERVER_KEY: { - HCO_CR_CERT_CONFIG_DURATION_KEY: CERTC_DEFAULT_24H, - HCO_CR_CERT_CONFIG_RENEW_BEFORE_KEY: CERTC_DEFAULT_12H, - }, - } - - def wait_for_fg_update(admin_client, hco_namespace, expected_fg, validate_func): """ Waits for featuregate updates to get propagated