Skip to content

Commit 753896d

Browse files
committed
[4.19] eus upgrade alignment
Signed-off-by: Harel Meir <hmeir@redhat.com>
1 parent 11845f9 commit 753896d

11 files changed

Lines changed: 289 additions & 187 deletions

File tree

conftest.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from _pytest.runner import CallInfo
2323
from kubernetes.dynamic.exceptions import ConflictError
2424
from ocp_resources.resource import get_client
25+
from packaging.version import Version
2526
from pyhelper_utils.shell import run_command
2627
from pytest import Item
2728
from pytest_testconfig import config as py_config
@@ -151,7 +152,6 @@ def pytest_addoption(parser):
151152
"--eus-ocp-images",
152153
help="Comma-separated OCP images to use for EUS-to-EUS upgrade.",
153154
)
154-
install_upgrade_group.addoption("--eus-cnv-target-version", help="target CNV version for eus upgrade")
155155
install_upgrade_group.addoption(
156156
"--upgrade-skip-default-sc-setup",
157157
help="Skip the fixture that changes the default sc in upgrade lane",
@@ -328,18 +328,21 @@ def pytest_cmdline_main(config):
328328
if upgrade_option == "ocp" and not config.getoption("ocp_image"):
329329
raise ValueError("Running with --upgrade ocp: Missing --ocp-image")
330330

331-
if upgrade_option == "cnv":
331+
if upgrade_option in ("cnv", "eus"):
332332
if not config.getoption("cnv_version"):
333333
raise ValueError("Missing --cnv-version")
334334
if not config.getoption("cnv_image"):
335-
if config.getoption("cnv_source") != "production":
335+
if upgrade_option == "eus" or config.getoption("cnv_source") != "production":
336336
raise ValueError("Missing --cnv-image")
337337

338-
if upgrade_option == "eus":
338+
if upgrade_option == "eus" and not config.option.collectonly:
339+
cnv_version = config.getoption("cnv_version")
340+
if Version(version=cnv_version).minor % 2:
341+
raise ValueError(f"EUS target version {cnv_version} must have an even minor version")
339342
eus_ocp_images = config.getoption("eus_ocp_images")
340343
if not (eus_ocp_images and len(eus_ocp_images.split(",")) == 2):
341344
raise ValueError(
342-
f"Two OCP images are needed to perform EUS-to-EUS upgrade with --eus-ocp-images."
345+
f"Two OCP images are needed for EUS-to-EUS upgrade with --eus-ocp-images."
343346
f" Provided images: {eus_ocp_images}"
344347
)
345348

@@ -834,7 +837,7 @@ def is_skip_must_gather(node: Node) -> bool:
834837

835838
def get_inspect_command_namespace_string(node: Node, test_name: str) -> str:
836839
namespace_str = ""
837-
components = [key for key in NAMESPACE_COLLECTION.keys() if f"tests/{key}/" in test_name]
840+
components = [key for key in NAMESPACE_COLLECTION if f"tests/{key}/" in test_name]
838841
if not components:
839842
LOGGER.warning(f"{test_name} does not require special data collection on failure")
840843
else:

docs/INSTALL_AND_UPGRADE.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,27 @@ To upgrade to cnv 4.Y.z, using the cnv image that has been shipped, following co
9696
```
9797

9898
#### EUS upgrade
99-
You must provide --eus-ocp-images via cli, which is two comma separated ocp images for EUS upgrade.
100-
The default target cnv version will be 4.Y+2.0. Optionally, --eus-csv-target-version can be provided for 4.Y+2.z version.
99+
EUS-to-EUS upgrades are only viable between even-numbered minor versions (e.g., 4.20 -> 4.22).
100+
101+
Parameters:
102+
103+
| Parameter Name | Requirement | Default Value | Possible Value |
104+
|:------------------|:---------------:|:-------------:|:----------------------------:|
105+
| `--cnv-version` | **Required** | - | 4.Y.z |
106+
| `--cnv-image` | **Required** | - | -image path- |
107+
| `--cnv-channel` | **Optional** | stable | stable, candidate, nightly |
108+
| `--eus-ocp-images` | **Required** | - | comma-separated OCP images |
109+
101110
Command to run entire upgrade test suite for EUS upgrade, including pre and post upgrade validation:
102111

103112
```bash
104-
--upgrade eus --eus-ocp-images <ocp_image_version_4.y+1.z>,<ocp_image_version_4.y+2.z> --eus-cnv-target-version <4.Y+2.z|None>
113+
--upgrade eus --cnv-version <target_version> --cnv-image <cnv_image_to_upgrade_to> --eus-ocp-images <ocp_image_4.y+1.z>,<ocp_image_4.y+2.z>
114+
```
115+
116+
Command to run only EUS upgrade test, without any pre/post validation:
117+
118+
```bash
119+
-m eus_upgrade --upgrade eus --cnv-version <target_version> --cnv-image <cnv_image_to_upgrade_to> --eus-ocp-images <ocp_image_4.y+1.z>,<ocp_image_4.y+2.z>
105120
```
106121
#### Custom upgrade lanes
107122

tests/conftest.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
from ocp_resources.virtual_machine_instancetype import VirtualMachineInstancetype
6565
from ocp_resources.virtual_machine_preference import VirtualMachinePreference
6666
from ocp_utilities.monitoring import Prometheus
67-
from packaging.version import Version, parse
67+
from packaging.version import parse
6868
from pytest_testconfig import config as py_config
6969
from timeout_sampler import TimeoutSampler
7070

@@ -1895,28 +1895,14 @@ def hco_target_csv_name(cnv_target_version):
18951895
return get_hco_csv_name_by_version(cnv_target_version=cnv_target_version) if cnv_target_version else None
18961896

18971897

1898-
@pytest.fixture(scope="session")
1899-
def eus_hco_target_csv_name(eus_target_cnv_version):
1900-
if eus_target_cnv_version is None:
1901-
LOGGER.warning("Cannot determine EUS HCO target CSV name: EUS target version is None (non-EUS version)")
1902-
return None
1903-
return get_hco_csv_name_by_version(cnv_target_version=eus_target_cnv_version)
1904-
1905-
19061898
@pytest.fixture(scope="session")
19071899
def cnv_target_version(pytestconfig):
19081900
return pytestconfig.option.cnv_version
19091901

19101902

19111903
@pytest.fixture(scope="session")
1912-
def eus_target_cnv_version(pytestconfig, cnv_current_version):
1913-
cnv_current_version = Version(version=cnv_current_version)
1914-
minor = cnv_current_version.minor
1915-
# EUS-to-EUS upgrades are only viable between even-numbered minor versions, return None if non-eus version
1916-
if minor % 2:
1917-
LOGGER.warning(f"EUS upgrade can not be performed from non-eus version: {cnv_current_version}")
1918-
return None
1919-
return pytestconfig.option.eus_cnv_target_version or f"{cnv_current_version.major}.{minor + 2}.0"
1904+
def cnv_channel(pytestconfig):
1905+
return pytestconfig.option.cnv_channel
19201906

19211907

19221908
@pytest.fixture()

tests/install_upgrade_operators/product_upgrade/conftest.py

Lines changed: 52 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@
1515
)
1616
from tests.install_upgrade_operators.product_upgrade.utils import (
1717
approve_cnv_upgrade_install_plan,
18+
build_eus_upgrade_path_dict,
1819
extract_ocp_version_from_ocp_image,
1920
get_alerts_fired_during_upgrade,
2021
get_all_firing_cnv_alerts,
21-
get_iib_images_of_cnv_versions,
2222
get_nodes_labels,
2323
get_nodes_taints,
24-
get_shortest_upgrade_path,
2524
perform_cnv_upgrade,
2625
run_ocp_upgrade_command,
2726
set_workload_update_methods_hco,
@@ -42,6 +41,7 @@
4241
from utilities.constants import (
4342
HCO_CATALOG_SOURCE,
4443
TIMEOUT_10MIN,
44+
TIMEOUT_180MIN,
4545
NamespacesNames,
4646
)
4747
from utilities.data_collector import (
@@ -50,7 +50,6 @@
5050
from utilities.infra import (
5151
exit_pytest_execution,
5252
generate_openshift_pull_secret_file,
53-
get_csv_by_name,
5453
get_prometheus_k8s_token,
5554
get_related_images_name_and_version,
5655
get_subscription,
@@ -324,24 +323,24 @@ def fired_alerts_during_upgrade(
324323

325324

326325
@pytest.fixture(scope="session")
327-
def eus_cnv_upgrade_path(eus_target_cnv_version):
328-
if eus_target_cnv_version is None:
326+
def eus_cnv_upgrade_path(
327+
cnv_target_version,
328+
cnv_current_version,
329+
cnv_channel,
330+
cnv_image_url,
331+
):
332+
if Version(version=cnv_current_version).minor % 2:
329333
exit_pytest_execution(
330-
message="EUS upgrade can not be performed from non-eus version", return_code=EUS_ERROR_CODE
334+
message=f"EUS upgrade can not be performed from non-eus version: {cnv_current_version}",
335+
return_code=EUS_ERROR_CODE,
336+
filename="eus_upgrade_failure.txt",
331337
)
332-
# Get the shortest path to the target (EUS) version
333-
upgrade_path_to_target_version = get_shortest_upgrade_path(target_version=eus_target_cnv_version)
334-
# Get the shortest path to the intermediate (non-EUS) version
335-
upgrade_path_to_intermediate_version = get_shortest_upgrade_path(
336-
target_version=upgrade_path_to_target_version["startVersion"]
338+
return build_eus_upgrade_path_dict(
339+
current_cnv_version=cnv_current_version,
340+
target_cnv_version=cnv_target_version,
341+
target_channel=cnv_channel,
342+
target_cnv_image_url=cnv_image_url,
337343
)
338-
# Return a dictionary with the versions and images for the EUS-to-EUS upgrade
339-
upgrade_path = {
340-
"non-eus": get_iib_images_of_cnv_versions(versions=upgrade_path_to_intermediate_version["versions"]),
341-
EUS: get_iib_images_of_cnv_versions(versions=upgrade_path_to_target_version["versions"], errata_status="false"),
342-
}
343-
LOGGER.info(f"Upgrade path for EUS-to-EUS upgrade: {upgrade_path}")
344-
return upgrade_path
345344

346345

347346
@pytest.fixture(scope="session")
@@ -373,6 +372,7 @@ def eus_unpaused_worker_mcp(
373372
machine_config_pools_list=worker_machine_config_pools,
374373
initial_mcp_conditions=worker_machine_config_pools_conditions,
375374
nodes=workers,
375+
timeout=TIMEOUT_180MIN,
376376
)
377377

378378

@@ -490,7 +490,7 @@ def triggered_non_eus_to_target_eus_ocp_upgrade(eus_ocp_image_urls):
490490
@pytest.fixture()
491491
def source_eus_to_non_eus_ocp_upgraded(
492492
admin_client,
493-
masters,
493+
control_plane_nodes,
494494
master_machine_config_pools,
495495
ocp_version_eus_to_non_eus_from_image_url,
496496
triggered_source_eus_to_non_eus_ocp_upgrade,
@@ -500,14 +500,14 @@ def source_eus_to_non_eus_ocp_upgraded(
500500
machine_config_pools_list=master_machine_config_pools,
501501
target_ocp_version=ocp_version_eus_to_non_eus_from_image_url,
502502
initial_mcp_conditions=get_machine_config_pools_conditions(machine_config_pools=master_machine_config_pools),
503-
nodes=masters,
503+
nodes=control_plane_nodes,
504504
)
505505

506506

507507
@pytest.fixture()
508508
def non_eus_to_target_eus_ocp_upgraded(
509509
admin_client,
510-
masters,
510+
control_plane_nodes,
511511
master_machine_config_pools,
512512
ocp_version_non_eus_to_eus_from_image_url,
513513
triggered_non_eus_to_target_eus_ocp_upgrade,
@@ -517,7 +517,7 @@ def non_eus_to_target_eus_ocp_upgraded(
517517
machine_config_pools_list=master_machine_config_pools,
518518
target_ocp_version=ocp_version_non_eus_to_eus_from_image_url,
519519
initial_mcp_conditions=get_machine_config_pools_conditions(machine_config_pools=master_machine_config_pools),
520-
nodes=masters,
520+
nodes=control_plane_nodes,
521521
)
522522

523523

@@ -526,17 +526,25 @@ def source_eus_to_non_eus_cnv_upgraded(
526526
admin_client,
527527
hco_namespace,
528528
eus_cnv_upgrade_path,
529+
cnv_subscription_scope_session,
530+
cnv_registry_source,
529531
hyperconverged_resource_scope_function,
530-
updated_cnv_subscription_source,
531532
):
532-
for version, cnv_image in sorted(eus_cnv_upgrade_path["non-eus"].items()):
533+
for version, build_info in sorted(
534+
eus_cnv_upgrade_path["non-eus"].items(),
535+
key=lambda item: Version(version=item[0]),
536+
):
537+
cnv_image = build_info["cnv_image_url"]
533538
LOGGER.info(f"Cnv upgrade to version {version} using image: {cnv_image}")
534539
perform_cnv_upgrade(
535540
admin_client=admin_client,
536541
cnv_image_url=cnv_image,
537542
cr_name=hyperconverged_resource_scope_function.name,
538543
hco_namespace=hco_namespace,
539-
cnv_target_version=version.lstrip("v"),
544+
cnv_target_version=version,
545+
subscription=cnv_subscription_scope_session,
546+
subscription_source=cnv_registry_source["cnv_subscription_source"],
547+
subscription_channel=build_info["channel"],
540548
)
541549
LOGGER.info("Successfully performed cnv upgrades from source EUS to non-EUS version.")
542550

@@ -546,27 +554,27 @@ def non_eus_to_target_eus_cnv_upgraded(
546554
admin_client,
547555
hco_namespace,
548556
eus_cnv_upgrade_path,
557+
cnv_subscription_scope_session,
558+
cnv_registry_source,
549559
hyperconverged_resource_scope_function,
550-
updated_cnv_subscription_source,
551560
):
552-
version, cnv_image = next(iter(eus_cnv_upgrade_path[EUS].items()))
553-
LOGGER.info(f"Cnv upgrade to version {version} using image: {cnv_image}")
554-
perform_cnv_upgrade(
555-
admin_client=admin_client,
556-
cnv_image_url=cnv_image,
557-
cr_name=hyperconverged_resource_scope_function.name,
558-
hco_namespace=hco_namespace,
559-
cnv_target_version=version.lstrip("v"),
560-
)
561-
562-
563-
@pytest.fixture()
564-
def eus_created_target_hco_csv(admin_client, hco_namespace, eus_hco_target_csv_name):
565-
return get_csv_by_name(
566-
csv_name=eus_hco_target_csv_name,
567-
admin_client=admin_client,
568-
namespace=hco_namespace.name,
569-
)
561+
for version, build_info in sorted(
562+
eus_cnv_upgrade_path[EUS].items(),
563+
key=lambda item: Version(version=item[0]),
564+
):
565+
cnv_image = build_info["cnv_image_url"]
566+
LOGGER.info(f"Cnv upgrade to version {version} using image: {cnv_image}")
567+
perform_cnv_upgrade(
568+
admin_client=admin_client,
569+
cnv_image_url=cnv_image,
570+
cr_name=hyperconverged_resource_scope_function.name,
571+
hco_namespace=hco_namespace,
572+
cnv_target_version=version,
573+
subscription=cnv_subscription_scope_session,
574+
subscription_source=cnv_registry_source["cnv_subscription_source"],
575+
subscription_channel=build_info["channel"],
576+
)
577+
LOGGER.info("Successfully performed cnv upgrades from non-EUS to target EUS version.")
570578

571579

572580
@pytest.fixture()

tests/install_upgrade_operators/product_upgrade/test_eus_upgrade.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
LOGGER = logging.getLogger(__name__)
1010

11+
pytestmark = pytest.mark.usefixtures(
12+
"nodes_taints_before_upgrade",
13+
"nodes_labels_before_upgrade",
14+
)
15+
1116

1217
@pytest.mark.product_upgrade_test
1318
@pytest.mark.upgrade
@@ -20,7 +25,6 @@ def test_eus_upgrade_process(
2025
self,
2126
admin_client,
2227
hco_namespace,
23-
eus_target_cnv_version,
2428
eus_cnv_upgrade_path,
2529
eus_paused_worker_mcp,
2630
eus_paused_workload_update,
@@ -29,14 +33,14 @@ def test_eus_upgrade_process(
2933
upgraded_odf,
3034
non_eus_to_target_eus_ocp_upgraded,
3135
non_eus_to_target_eus_cnv_upgraded,
32-
eus_created_target_hco_csv,
36+
created_target_hco_csv,
3337
eus_unpaused_workload_update,
3438
eus_unpaused_worker_mcp,
3539
):
3640
LOGGER.info("Validate EUS to EUS upgrade process")
3741
verify_upgrade_cnv(
3842
dyn_client=admin_client,
3943
hco_namespace=hco_namespace,
40-
expected_images=get_related_images_name_and_version(csv=eus_created_target_hco_csv).values(),
44+
expected_images=get_related_images_name_and_version(csv=created_target_hco_csv).values(),
4145
)
4246
LOGGER.info("EUS post upgrade validation completed.")

0 commit comments

Comments
 (0)