1515)
1616from 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_upgrade_path ,
2524 perform_cnv_upgrade ,
2625 run_ocp_upgrade_command ,
2726 set_workload_update_methods_hco ,
4948 get_data_collector_base_directory ,
5049)
5150from utilities .infra import (
51+ 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 ,
6665
6766LOGGER = logging .getLogger (__name__ )
6867POD_STR_NOT_MANAGED_BY_HCO = "hostpath-"
68+ EUS_ERROR_CODE = 98
6969
7070
7171@pytest .fixture (scope = "session" )
@@ -323,64 +323,25 @@ def fired_alerts_during_upgrade(
323323
324324
325325@pytest .fixture (scope = "session" )
326- def eus_shortest_upgrade_path_info (eus_target_cnv_version , cnv_current_version ):
327- # if cant get from stable - try candidate
328- if upgrade_paths_target_version := get_upgrade_path (target_version = eus_target_cnv_version ):
329- target_channel = "stable"
330- else :
331- target_channel = "candidate"
332- upgrade_paths_target_version = get_upgrade_path (target_version = eus_target_cnv_version , channel = target_channel )
333- assert upgrade_paths_target_version , f"Couldn't find upgrade path for { eus_target_cnv_version } version"
334-
335- sorted_upgrade_paths = sorted (
336- upgrade_paths_target_version , key = lambda path : Version (version = str (path ["startVersion" ])), reverse = True
337- )
338- for path in sorted_upgrade_paths :
339- if intermediate_upgrade_paths := get_upgrade_path (target_version = path ["startVersion" ]):
340- if intermediate_path_dict := next (
341- (item for item in intermediate_upgrade_paths if item ["startVersion" ] == f"v{ cnv_current_version } " ), None
342- ):
343- return {
344- "target_versions" : path ["versions" ],
345- "intermediate_versions" : intermediate_path_dict ["versions" ],
346- "target_channel" : target_channel ,
347- }
348- raise AssertionError (f"Couldn't find upgrade path for { eus_target_cnv_version } version from { cnv_current_version } " )
349-
350-
351- @pytest .fixture (scope = "session" )
352- def eus_target_channel (eus_shortest_upgrade_path_info ):
353- return eus_shortest_upgrade_path_info ["target_channel" ]
354-
355-
356- @pytest .fixture (scope = "session" )
357- def eus_cnv_upgrade_path (eus_shortest_upgrade_path_info , eus_target_channel ):
358- if not (
359- target_paths := get_iib_images_of_cnv_versions (
360- versions = eus_shortest_upgrade_path_info ["target_versions" ],
361- target_channel = eus_target_channel ,
362- )
363- ):
364- target_paths = get_iib_images_of_cnv_versions (
365- versions = eus_shortest_upgrade_path_info ["target_versions" ],
366- errata_status = "false" ,
367- target_channel = eus_target_channel ,
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 :
333+ exit_pytest_execution (
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" ,
368337 )
369- intermediate_paths = get_iib_images_of_cnv_versions (
370- versions = eus_shortest_upgrade_path_info [ "intermediate_versions" ] ,
371- )
372- assert intermediate_paths , (
373- f"Couldn't find build info for { eus_shortest_upgrade_path_info [ 'intermediate_versions' ] } versions"
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 ,
374343 )
375344
376- # Return a dictionary with the versions and images for the EUS-to-EUS upgrade
377- upgrade_path_dict = {
378- EUS : target_paths ,
379- "non-eus" : intermediate_paths ,
380- }
381- LOGGER .info (f"Upgrade path for EUS-to-EUS upgrade: { upgrade_path_dict } " )
382- return upgrade_path_dict
383-
384345
385346@pytest .fixture (scope = "session" )
386347def default_workload_update_strategy (hyperconverged_resource_scope_session ):
@@ -564,18 +525,25 @@ def source_eus_to_non_eus_cnv_upgraded(
564525 admin_client ,
565526 hco_namespace ,
566527 eus_cnv_upgrade_path ,
567- eus_target_channel ,
528+ cnv_subscription_scope_session ,
529+ cnv_registry_source ,
568530 hyperconverged_resource_scope_function ,
569- updated_cnv_subscription_source ,
570531):
571- for version , cnv_image in sorted (eus_cnv_upgrade_path ["non-eus" ].items ()):
532+ for version , build_info in sorted (
533+ eus_cnv_upgrade_path ["non-eus" ].items (),
534+ key = lambda item : Version (version = item [0 ]),
535+ ):
536+ cnv_image = build_info ["cnv_image_url" ]
572537 LOGGER .info (f"Cnv upgrade to version { version } using image: { cnv_image } " )
573538 perform_cnv_upgrade (
574539 admin_client = admin_client ,
575540 cnv_image_url = cnv_image ,
576541 cr_name = hyperconverged_resource_scope_function .name ,
577542 hco_namespace = hco_namespace ,
578- cnv_target_version = version .lstrip ("v" ),
543+ cnv_target_version = version ,
544+ subscription = cnv_subscription_scope_session ,
545+ subscription_source = cnv_registry_source ["cnv_subscription_source" ],
546+ subscription_channel = build_info ["channel" ],
579547 )
580548 LOGGER .info ("Successfully performed cnv upgrades from source EUS to non-EUS version." )
581549
@@ -585,32 +553,27 @@ def non_eus_to_target_eus_cnv_upgraded(
585553 admin_client ,
586554 hco_namespace ,
587555 eus_cnv_upgrade_path ,
588- eus_target_channel ,
589556 cnv_subscription_scope_session ,
590557 cnv_registry_source ,
591558 hyperconverged_resource_scope_function ,
592559):
593- version , cnv_image = next (iter (eus_cnv_upgrade_path [EUS ].items ()))
594- LOGGER .info (f"Cnv upgrade to version { version } using image: { cnv_image } " )
595- perform_cnv_upgrade (
596- admin_client = admin_client ,
597- cnv_image_url = cnv_image ,
598- cr_name = hyperconverged_resource_scope_function .name ,
599- hco_namespace = hco_namespace ,
600- cnv_target_version = version .lstrip ("v" ),
601- subscription = cnv_subscription_scope_session ,
602- subscription_source = cnv_registry_source ["cnv_subscription_source" ],
603- subscription_channel = eus_target_channel ,
604- )
605-
606-
607- @pytest .fixture ()
608- def eus_created_target_hco_csv (admin_client , hco_namespace , eus_hco_target_csv_name ):
609- return get_csv_by_name (
610- csv_name = eus_hco_target_csv_name ,
611- admin_client = admin_client ,
612- namespace = hco_namespace .name ,
613- )
560+ for version , build_info in sorted (
561+ eus_cnv_upgrade_path [EUS ].items (),
562+ key = lambda item : Version (version = item [0 ]),
563+ ):
564+ cnv_image = build_info ["cnv_image_url" ]
565+ LOGGER .info (f"Cnv upgrade to version { version } using image: { cnv_image } " )
566+ perform_cnv_upgrade (
567+ admin_client = admin_client ,
568+ cnv_image_url = cnv_image ,
569+ cr_name = hyperconverged_resource_scope_function .name ,
570+ hco_namespace = hco_namespace ,
571+ cnv_target_version = version ,
572+ subscription = cnv_subscription_scope_session ,
573+ subscription_source = cnv_registry_source ["cnv_subscription_source" ],
574+ subscription_channel = build_info ["channel" ],
575+ )
576+ LOGGER .info ("Successfully performed cnv upgrades from non-EUS to target EUS version." )
614577
615578
616579@pytest .fixture ()
0 commit comments