Skip to content

Commit dd9cd42

Browse files
committed
[4.21] eus upgrade alignment
Signed-off-by: Harel Meir <hmeir@redhat.com>
1 parent 88a2a7f commit dd9cd42

11 files changed

Lines changed: 262 additions & 128 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.network_config_openshift_io import Network
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
@@ -161,7 +162,6 @@ def pytest_addoption(parser):
161162
"--eus-ocp-images",
162163
help="Comma-separated OCP images to use for EUS-to-EUS upgrade.",
163164
)
164-
install_upgrade_group.addoption("--eus-cnv-target-version", help="target CNV version for eus upgrade")
165165
install_upgrade_group.addoption(
166166
"--upgrade-skip-default-sc-setup",
167167
help="Skip the fixture that changes the default sc in upgrade lane",
@@ -377,18 +377,21 @@ def pytest_cmdline_main(config):
377377
if upgrade_option == "ocp" and not config.getoption("ocp_image"):
378378
raise ValueError("Running with --upgrade ocp: Missing --ocp-image")
379379

380-
if upgrade_option == "cnv":
380+
if upgrade_option in ("cnv", "eus"):
381381
if not config.getoption("cnv_version"):
382382
raise ValueError("Missing --cnv-version")
383383
if not config.getoption("cnv_image"):
384-
if config.getoption("cnv_source") != "production":
384+
if upgrade_option == "eus" or config.getoption("cnv_source") != "production":
385385
raise ValueError("Missing --cnv-image")
386386

387-
if upgrade_option == "eus":
387+
if upgrade_option == "eus" and not config.option.collectonly:
388+
cnv_version = config.getoption("cnv_version")
389+
if Version(version=cnv_version).minor % 2:
390+
raise ValueError(f"EUS target version {cnv_version} must have an even minor version")
388391
eus_ocp_images = config.getoption("eus_ocp_images")
389392
if not (eus_ocp_images and len(eus_ocp_images.split(",")) == 2):
390393
raise ValueError(
391-
f"Two OCP images are needed to perform EUS-to-EUS upgrade with --eus-ocp-images."
394+
f"Two OCP images are needed for EUS-to-EUS upgrade with --eus-ocp-images."
392395
f" Provided images: {eus_ocp_images}"
393396
)
394397

@@ -905,7 +908,7 @@ def is_skip_must_gather(node: Node) -> bool:
905908

906909
def get_inspect_command_namespace_string(node: Node, test_name: str) -> str:
907910
namespace_str = ""
908-
components = [key for key in NAMESPACE_COLLECTION.keys() if f"tests/{key}/" in test_name]
911+
components = [key for key in NAMESPACE_COLLECTION if f"tests/{key}/" in test_name]
909912
if not components:
910913
LOGGER.warning(f"{test_name} does not require special data collection on failure")
911914
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
@@ -63,7 +63,7 @@
6363
from ocp_resources.virtual_machine_instancetype import VirtualMachineInstancetype
6464
from ocp_resources.virtual_machine_preference import VirtualMachinePreference
6565
from ocp_utilities.monitoring import Prometheus
66-
from packaging.version import Version, parse
66+
from packaging.version import parse
6767
from pytest_testconfig import config as py_config
6868
from timeout_sampler import TimeoutSampler
6969

@@ -1751,28 +1751,14 @@ def hco_target_csv_name(cnv_target_version):
17511751
return get_hco_csv_name_by_version(cnv_target_version=cnv_target_version) if cnv_target_version else None
17521752

17531753

1754-
@pytest.fixture(scope="session")
1755-
def eus_hco_target_csv_name(eus_target_cnv_version):
1756-
if eus_target_cnv_version is None:
1757-
LOGGER.warning("Cannot determine EUS HCO target CSV name: EUS target version is None (non-EUS version)")
1758-
return None
1759-
return get_hco_csv_name_by_version(cnv_target_version=eus_target_cnv_version)
1760-
1761-
17621754
@pytest.fixture(scope="session")
17631755
def cnv_target_version(pytestconfig):
17641756
return pytestconfig.option.cnv_version
17651757

17661758

17671759
@pytest.fixture(scope="session")
1768-
def eus_target_cnv_version(pytestconfig, cnv_current_version):
1769-
cnv_current_version = Version(version=cnv_current_version)
1770-
minor = cnv_current_version.minor
1771-
# EUS-to-EUS upgrades are only viable between even-numbered minor versions, return None if non-eus version
1772-
if minor % 2:
1773-
LOGGER.warning(f"EUS upgrade can not be performed from non-eus version: {cnv_current_version}")
1774-
return None
1775-
return pytestconfig.option.eus_cnv_target_version or f"{cnv_current_version.major}.{minor + 2}.0"
1760+
def cnv_channel(pytestconfig):
1761+
return pytestconfig.option.cnv_channel
17761762

17771763

17781764
@pytest.fixture()

tests/install_upgrade_operators/product_upgrade/conftest.py

Lines changed: 52 additions & 45 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,14 +41,14 @@
4241
from utilities.constants import (
4342
HCO_CATALOG_SOURCE,
4443
TIMEOUT_10MIN,
44+
TIMEOUT_180MIN,
4545
NamespacesNames,
4646
)
4747
from utilities.data_collector import (
4848
get_data_collector_base_directory,
4949
)
5050
from utilities.infra import (
5151
generate_openshift_pull_secret_file,
52-
get_csv_by_name,
5352
get_prometheus_k8s_token,
5453
get_related_images_name_and_version,
5554
get_subscription,
@@ -324,27 +323,26 @@ def fired_alerts_during_upgrade(
324323

325324

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

349347

350348
@pytest.fixture(scope="session")
@@ -376,6 +374,7 @@ def eus_unpaused_worker_mcp(
376374
machine_config_pools_list=worker_machine_config_pools,
377375
initial_mcp_conditions=worker_machine_config_pools_conditions,
378376
nodes=workers,
377+
timeout=TIMEOUT_180MIN,
379378
)
380379

381380

@@ -493,7 +492,7 @@ def triggered_non_eus_to_target_eus_ocp_upgrade(eus_ocp_image_urls):
493492
@pytest.fixture()
494493
def source_eus_to_non_eus_ocp_upgraded(
495494
admin_client,
496-
masters,
495+
control_plane_nodes,
497496
master_machine_config_pools,
498497
ocp_version_eus_to_non_eus_from_image_url,
499498
triggered_source_eus_to_non_eus_ocp_upgrade,
@@ -503,14 +502,14 @@ def source_eus_to_non_eus_ocp_upgraded(
503502
machine_config_pools_list=master_machine_config_pools,
504503
target_ocp_version=ocp_version_eus_to_non_eus_from_image_url,
505504
initial_mcp_conditions=get_machine_config_pools_conditions(machine_config_pools=master_machine_config_pools),
506-
nodes=masters,
505+
nodes=control_plane_nodes,
507506
)
508507

509508

510509
@pytest.fixture()
511510
def non_eus_to_target_eus_ocp_upgraded(
512511
admin_client,
513-
masters,
512+
control_plane_nodes,
514513
master_machine_config_pools,
515514
ocp_version_non_eus_to_eus_from_image_url,
516515
triggered_non_eus_to_target_eus_ocp_upgrade,
@@ -520,7 +519,7 @@ def non_eus_to_target_eus_ocp_upgraded(
520519
machine_config_pools_list=master_machine_config_pools,
521520
target_ocp_version=ocp_version_non_eus_to_eus_from_image_url,
522521
initial_mcp_conditions=get_machine_config_pools_conditions(machine_config_pools=master_machine_config_pools),
523-
nodes=masters,
522+
nodes=control_plane_nodes,
524523
)
525524

526525

@@ -529,17 +528,25 @@ def source_eus_to_non_eus_cnv_upgraded(
529528
admin_client,
530529
hco_namespace,
531530
eus_cnv_upgrade_path,
531+
cnv_subscription_scope_session,
532+
cnv_registry_source,
532533
hyperconverged_resource_scope_function,
533-
updated_cnv_subscription_source,
534534
):
535-
for version, cnv_image in sorted(eus_cnv_upgrade_path["non-eus"].items()):
535+
for version, build_info in sorted(
536+
eus_cnv_upgrade_path["non-eus"].items(),
537+
key=lambda item: Version(version=item[0]),
538+
):
539+
cnv_image = build_info["cnv_image_url"]
536540
LOGGER.info(f"Cnv upgrade to version {version} using image: {cnv_image}")
537541
perform_cnv_upgrade(
538542
admin_client=admin_client,
539543
cnv_image_url=cnv_image,
540544
cr_name=hyperconverged_resource_scope_function.name,
541545
hco_namespace=hco_namespace,
542-
cnv_target_version=version.lstrip("v"),
546+
cnv_target_version=version,
547+
subscription=cnv_subscription_scope_session,
548+
subscription_source=cnv_registry_source["cnv_subscription_source"],
549+
subscription_channel=build_info["channel"],
543550
)
544551
LOGGER.info("Successfully performed cnv upgrades from source EUS to non-EUS version.")
545552

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

574581

575582
@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
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)