-
Notifications
You must be signed in to change notification settings - Fork 69
[IUO] Install plan upgrade test #4394
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,19 +6,49 @@ | |
| verify_upgrade_cnv, | ||
| verify_upgrade_ocp, | ||
| ) | ||
| from tests.install_upgrade_operators.utils import wait_for_install_plan | ||
| from tests.upgrade_params import IUO_UPGRADE_TEST_DEPENDENCY_NODE_ID | ||
|
|
||
| pytestmark = pytest.mark.usefixtures( | ||
| "nodes_taints_before_upgrade", | ||
| "nodes_labels_before_upgrade", | ||
| ) | ||
| pytestmark = [ | ||
| pytest.mark.product_upgrade_test, | ||
| pytest.mark.sno, | ||
| pytest.mark.upgrade, | ||
| pytest.mark.upgrade_custom, | ||
| pytest.mark.usefixtures( | ||
| "nodes_taints_before_upgrade", | ||
| "nodes_labels_before_upgrade", | ||
| ), | ||
| ] | ||
| LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| @pytest.mark.product_upgrade_test | ||
| @pytest.mark.sno | ||
| @pytest.mark.upgrade | ||
| @pytest.mark.upgrade_custom | ||
| @pytest.mark.gating | ||
| @pytest.mark.cnv_upgrade | ||
| @pytest.mark.order("first") | ||
| @pytest.mark.polarion("CNV-12451") | ||
| @pytest.mark.usefixtures( | ||
| "cnv_upgrade_stream", | ||
| "disabled_default_sources_in_operatorhub", | ||
| "updated_konflux_idms", | ||
| "updated_custom_hco_catalog_source_image", | ||
| "updated_cnv_subscription_source", | ||
| ) | ||
| def test_cnv_upgrade_install_plan_creation( | ||
| admin_client, | ||
| hco_namespace, | ||
| hco_target_csv_name, | ||
| is_production_source, | ||
| cnv_subscription_scope_session, | ||
| ): | ||
| wait_for_install_plan( | ||
| client=admin_client, | ||
| hco_namespace=hco_namespace.name, | ||
| hco_target_csv_name=hco_target_csv_name, | ||
| is_production_source=is_production_source, | ||
| cnv_subscription=cnv_subscription_scope_session, | ||
| ) | ||
|
Comment on lines
+25
to
+49
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HIGH: This precheck is ordered first, but the downstream CNV tests now depend on its side effects. After moving As per coding guidelines "Tests MUST be independent; use 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| class TestUpgrade: | ||
| @pytest.mark.ocp_upgrade | ||
| @pytest.mark.polarion("CNV-8381") | ||
|
|
@@ -53,29 +83,21 @@ def test_cnv_upgrade_process( | |
| cnv_target_version, | ||
| cnv_upgrade_stream, | ||
| fired_alerts_before_upgrade, | ||
| disabled_default_sources_in_operatorhub, | ||
| updated_konflux_idms, | ||
| updated_custom_hco_catalog_source_image, | ||
| updated_cnv_subscription_source, | ||
| approved_cnv_upgrade_install_plan, | ||
| started_cnv_upgrade, | ||
| created_target_hco_csv, | ||
| related_images_from_target_csv, | ||
| upgraded_cnv, | ||
| ): | ||
| """ | ||
| Test the CNV upgrade process (using OSBS/fbc sources). The main steps of the test are: | ||
| Test the CNV upgrade process. The main steps of the test are: | ||
|
|
||
| 1. Disable the default sources in operatorhub in order to be able to upgrade usg a custom catalog source. | ||
| 2. Generate a new ICSP for the IIB image being used. | ||
| 3. Update HCO CatalogSource with the image being used. | ||
| 4. Update the CNV Subscription source. | ||
| 5. Wait for the upgrade InstallPlan to be created and approve it. | ||
| 6. Wait until the upgrade has finished: | ||
| 6.1. Wait for CSV to be created and reach status SUCCEEDED. | ||
| 6.2. Wait for HCO OperatorCondition to reach status Upgradeable=True. | ||
| 6.3. Wait until all the pods have been replaced. | ||
| 6.4. Wait until HCO is stable and its version is updated. | ||
| 1. Approve the upgrade InstallPlan (created by test_cnv_upgrade_install_plan_creation). | ||
| 2. Wait until the upgrade has finished: | ||
| 2.1. Wait for CSV to be created and reach status SUCCEEDED. | ||
| 2.2. Wait for HCO OperatorCondition to reach status Upgradeable=True. | ||
| 2.3. Wait until all the pods have been replaced. | ||
| 2.4. Wait until HCO is stable and its version is updated. | ||
| """ | ||
| verify_upgrade_cnv( | ||
| client=admin_client, | ||
|
|
@@ -94,7 +116,6 @@ def test_production_source_cnv_upgrade_process( | |
| cnv_target_version, | ||
| cnv_upgrade_stream, | ||
| fired_alerts_before_upgrade, | ||
| updated_cnv_subscription_source, | ||
| approved_cnv_upgrade_install_plan, | ||
| started_cnv_upgrade, | ||
| created_target_hco_csv, | ||
|
|
@@ -103,8 +124,8 @@ def test_production_source_cnv_upgrade_process( | |
| ): | ||
| """ | ||
| Test the CNV upgrade process using the production source. | ||
| The main steps of the test are the same as for osbs/fbc source, | ||
| but it is not needed to disable the default sources, create a new ICSP or update the HCO CatalogSource. | ||
| The main steps are the same as for custom source, | ||
| but source configuration is handled by test_cnv_upgrade_install_plan_creation. | ||
| """ | ||
| verify_upgrade_cnv( | ||
| client=admin_client, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,19 +14,18 @@ | |||||||||||||||||||
| from ocp_resources.node import Node | ||||||||||||||||||||
| from ocp_resources.operator_condition import OperatorCondition | ||||||||||||||||||||
| from ocp_resources.resource import Resource, ResourceEditor | ||||||||||||||||||||
| from ocp_resources.subscription import Subscription | ||||||||||||||||||||
| from timeout_sampler import TimeoutExpiredError, TimeoutSampler | ||||||||||||||||||||
|
|
||||||||||||||||||||
| from tests.install_upgrade_operators.constants import KEY_PATH_SEPARATOR | ||||||||||||||||||||
| from utilities.constants import ( | ||||||||||||||||||||
| HCO_SUBSCRIPTION, | ||||||||||||||||||||
| PRODUCTION_CATALOG_SOURCE, | ||||||||||||||||||||
| TIMEOUT_1MIN, | ||||||||||||||||||||
| TIMEOUT_5SEC, | ||||||||||||||||||||
| TIMEOUT_10SEC, | ||||||||||||||||||||
| TIMEOUT_30MIN, | ||||||||||||||||||||
| TIMEOUT_40MIN, | ||||||||||||||||||||
| ) | ||||||||||||||||||||
| from utilities.infra import get_subscription | ||||||||||||||||||||
| from utilities.operator import wait_for_mcp_update_completion | ||||||||||||||||||||
|
|
||||||||||||||||||||
| LOGGER = logging.getLogger(__name__) | ||||||||||||||||||||
|
|
@@ -68,7 +67,21 @@ def wait_for_install_plan( | |||||||||||||||||||
| hco_namespace: str, | ||||||||||||||||||||
| hco_target_csv_name: str, | ||||||||||||||||||||
| is_production_source: bool, | ||||||||||||||||||||
| cnv_subscription: Subscription, | ||||||||||||||||||||
| ) -> Any: | ||||||||||||||||||||
| """Waits for the upgrade InstallPlan to be created and returns it. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Args: | ||||||||||||||||||||
| client: Kubernetes dynamic client. | ||||||||||||||||||||
| hco_namespace: HCO namespace name. | ||||||||||||||||||||
| hco_target_csv_name: Expected target CSV name. | ||||||||||||||||||||
| is_production_source: Whether upgrading from production source. | ||||||||||||||||||||
| cnv_subscription: CNV subscription resource. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Returns: | ||||||||||||||||||||
| The matching InstallPlan resource. | ||||||||||||||||||||
| """ | ||||||||||||||||||||
| LOGGER.info(f"Waiting for the upgrade install plan. hco_target_csv_name: {hco_target_csv_name}") | ||||||||||||||||||||
| install_plan_sampler = TimeoutSampler( | ||||||||||||||||||||
| wait_timeout=TIMEOUT_40MIN, | ||||||||||||||||||||
| sleep=TIMEOUT_10SEC, | ||||||||||||||||||||
|
|
@@ -81,16 +94,11 @@ def wait_for_install_plan( | |||||||||||||||||||
| hco_namespace=hco_namespace, | ||||||||||||||||||||
| hco_target_version=hco_target_csv_name, | ||||||||||||||||||||
| ) | ||||||||||||||||||||
| subscription = get_subscription( | ||||||||||||||||||||
| admin_client=client, | ||||||||||||||||||||
| namespace=hco_namespace, | ||||||||||||||||||||
| subscription_name=HCO_SUBSCRIPTION, | ||||||||||||||||||||
| ) | ||||||||||||||||||||
| install_plan_name_in_subscription = None | ||||||||||||||||||||
| try: | ||||||||||||||||||||
| for install_plan_samples in install_plan_sampler: | ||||||||||||||||||||
| # wait for the install plan to be created and updated in the subscription. | ||||||||||||||||||||
| install_plan_name_in_subscription = getattr(subscription.instance.status.installplan, "name", None) | ||||||||||||||||||||
| install_plan_name_in_subscription = getattr(cnv_subscription.instance.status.installplan, "name", None) | ||||||||||||||||||||
|
Comment on lines
99
to
+101
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CRITICAL: Guard the subscription InstallPlan lookup while it is still unset. Line 101 still dereferences Proposed fix- install_plan_name_in_subscription = getattr(cnv_subscription.instance.status.installplan, "name", None)
+ subscription_status = getattr(cnv_subscription.instance, "status", None)
+ install_plan_ref = getattr(subscription_status, "installplan", None)
+ install_plan_name_in_subscription = getattr(install_plan_ref, "name", None)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| for ip in install_plan_samples: | ||||||||||||||||||||
| # If we find a not-approved install plan that is associated with production catalogsource, we need | ||||||||||||||||||||
| # to delete it. Deleting the install plan associated with production catalogsource, would cause | ||||||||||||||||||||
|
|
@@ -115,7 +123,7 @@ def wait_for_install_plan( | |||||||||||||||||||
| ): | ||||||||||||||||||||
| return ip | ||||||||||||||||||||
| LOGGER.info( | ||||||||||||||||||||
| f"Subscription: {subscription.name}, is associated with install plan:" | ||||||||||||||||||||
| f"Subscription: {cnv_subscription.name}, is associated with install plan:" | ||||||||||||||||||||
| f" {install_plan_name_in_subscription}" | ||||||||||||||||||||
| ) | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CRITICAL: This reverses the IDMS setup condition.
updated_konflux_idmsused to apply mirrors only for disconnected clusters, which is where the IDMS is needed. The new early return onis_disconnected_clusterskips the patch in exactly that environment, so the install-plan precheck and later upgrade flow run without the required mirror configuration.Proposed fix
🧰 Tools
🪛 Ruff (0.15.9)
[warning] 141-141: Logging statement uses f-string
(G004)
🤖 Prompt for AI Agents