Skip to content

Commit fc226b0

Browse files
committed
Merge branch 'main' into testCustomCliDownload
2 parents 6828df3 + a8b43d8 commit fc226b0

5 files changed

Lines changed: 42 additions & 37 deletions

File tree

tests/install_upgrade_operators/console_cli_download/conftest.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222
@pytest.fixture()
23-
def virtctl_console_cli_downloads_spec_links(admin_client):
23+
def virtctl_console_cli_downloads_spec_links_scope_function(admin_client):
2424
"""
2525
Get console cli downloads spec links
2626
@@ -31,7 +31,7 @@ def virtctl_console_cli_downloads_spec_links(admin_client):
3131

3232

3333
@pytest.fixture(scope="class")
34-
def virtctl_console_cli_downloads_spec_links_scope_class(admin_client):
34+
def original_virtctl_console_cli_downloads_spec_links_scope_class(admin_client):
3535
"""
3636
Get console cli downloads spec links
3737
@@ -42,15 +42,19 @@ def virtctl_console_cli_downloads_spec_links_scope_class(admin_client):
4242

4343

4444
@pytest.fixture()
45-
def all_virtctl_urls_scope_function(virtctl_console_cli_downloads_spec_links):
45+
def all_virtctl_urls_scope_function(virtctl_console_cli_downloads_spec_links_scope_function):
4646
"""This fixture returns URLs for the various OSs to download virtctl"""
47-
return get_all_console_links(console_cli_downloads_spec_links=virtctl_console_cli_downloads_spec_links)
47+
return get_all_console_links(
48+
console_cli_downloads_spec_links=virtctl_console_cli_downloads_spec_links_scope_function
49+
)
4850

4951

5052
@pytest.fixture(scope="class")
51-
def all_virtctl_urls_scope_class(virtctl_console_cli_downloads_spec_links_scope_class):
53+
def all_virtctl_urls_scope_class(original_virtctl_console_cli_downloads_spec_links_scope_class):
5254
"""This fixture returns URLs for the various OSs to download virtctl"""
53-
return get_all_console_links(console_cli_downloads_spec_links=virtctl_console_cli_downloads_spec_links_scope_class)
55+
return get_all_console_links(
56+
console_cli_downloads_spec_links=original_virtctl_console_cli_downloads_spec_links_scope_class
57+
)
5458

5559

5660
@pytest.fixture()

tests/install_upgrade_operators/console_cli_download/test_custom_console_cli_download.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from tests.install_upgrade_operators.console_cli_download.utils import (
44
CUSTOMIZED_VIRT_DL,
55
validate_custom_cli_downloads_urls_updated,
6-
validate_custom_cli_urls_downloaded,
76
)
7+
from utilities.infra import download_and_extract_file_from_cluster
88

99

1010
@pytest.mark.parametrize(
@@ -44,11 +44,12 @@ def test_custom_console_cli_download(
4444
@pytest.mark.polarion("CNV-12278")
4545
def test_custom_console_cli_download_links_downloadable(
4646
self,
47-
admin_client,
4847
tmpdir,
4948
all_virtctl_urls_scope_function,
5049
):
51-
validate_custom_cli_urls_downloaded(
52-
urls=all_virtctl_urls_scope_function,
53-
dest_dir=tmpdir,
54-
)
50+
not_valid_urls = [
51+
url
52+
for url in all_virtctl_urls_scope_function
53+
if not download_and_extract_file_from_cluster(tmpdir=tmpdir, url=url)
54+
]
55+
assert not not_valid_urls, f"Some urls is not valid, {not_valid_urls}"

tests/install_upgrade_operators/console_cli_download/test_disconnected_virtctl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def test_download_and_execute_virtcli_binary_linux(self, downloaded_and_extracte
9494
@pytest.mark.arm64
9595
class TestDisconnectedVirtctlAllLinksInternal:
9696
@pytest.mark.polarion("CNV-6915")
97-
def test_all_links_internal(self, all_virtctl_urls_scope_function, non_internal_fqdns):
97+
def test_all_links_internal(self, all_virtctl_urls_scope_class, non_internal_fqdns):
9898
assert not non_internal_fqdns, (
9999
"Found virtctl URLs that do not point to the cluster internally: "
100-
f"violating_fqdns={non_internal_fqdns} all_virtctl_urls={all_virtctl_urls_scope_function}"
100+
f"violating_fqdns={non_internal_fqdns} all_virtctl_urls={all_virtctl_urls_scope_class}"
101101
)

tests/install_upgrade_operators/console_cli_download/utils.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import logging
22

3-
from _pytest._py.path import LocalPath
43
from kubernetes.dynamic import DynamicClient
54
from timeout_sampler import TimeoutExpiredError, TimeoutSampler
65

76
from utilities.constants import TIMEOUT_1MIN, TIMEOUT_5SEC, VIRTCTL_CLI_DOWNLOADS
8-
from utilities.infra import download_and_extract_file_from_cluster, get_console_spec_links
7+
from utilities.infra import get_console_spec_links
98

109
LOGGER = logging.getLogger(__name__)
1110
CUSTOMIZED_VIRT_DL = "customized-virt-dl"
@@ -27,23 +26,26 @@ def validate_custom_cli_downloads_urls_updated(
2726
admin_client (DynamicClient): Kubernetes dynamic client for API operations
2827
new_hostname (str, optional): New hostname that should be present in all URLs.
2928
If provided, validates that all URLs contain this hostname.
29+
Mutually exclusive with original_virtctl_console_cli_downloads_spec_links.
3030
original_virtctl_console_cli_downloads_spec_links (list[str], optional):
3131
Original list of CLI download URLs. If provided, validates that current
3232
URLs match these original URLs.
33-
34-
Returns:
35-
None: Function returns when validation succeeds
33+
Mutually exclusive with new_hostname.
3634
3735
Raises:
3836
TimeoutExpiredError: If validation fails within the timeout period (1 minute).
3937
This can occur when:
4038
- URLs don't revert to original state within timeout
4139
- URLs don't get updated with new hostname within timeout
42-
43-
Note:
44-
- Exactly one of new_hostname or original_virtctl_console_cli_downloads_spec_links
45-
should be provided, not both
40+
ValueError: If both new_hostname and original_virtctl_console_cli_downloads_spec_links
41+
are provided, or if neither is provided.
4642
"""
43+
if (new_hostname is None) == (original_virtctl_console_cli_downloads_spec_links is None):
44+
raise ValueError(
45+
"Exactly one of 'new_hostname' or 'original_virtctl_console_cli_downloads_spec_links' "
46+
"must be provided, not both or neither."
47+
)
48+
4749
samples = TimeoutSampler(
4850
wait_timeout=TIMEOUT_1MIN,
4951
sleep=TIMEOUT_5SEC,
@@ -64,17 +66,15 @@ def validate_custom_cli_downloads_urls_updated(
6466
if not urls_not_updated_with_new_hostname:
6567
return
6668
except TimeoutExpiredError:
67-
LOGGER.error(
68-
f"Failed to update cluster ingress downloads spec links to the original links: "
69-
f"original_cli_spec_links: {original_virtctl_console_cli_downloads_spec_links}, "
70-
f"current_cli_spec_links: {current_cli_spec_links}"
71-
) if original_virtctl_console_cli_downloads_spec_links else (
72-
f"Failed to get console spec links: {current_cli_spec_links}, "
73-
f"There are urls that are not updated with new hostname: {urls_not_updated_with_new_hostname}"
74-
)
69+
if original_virtctl_console_cli_downloads_spec_links:
70+
LOGGER.error(
71+
f"Failed to update cluster ingress downloads spec links to the original links: "
72+
f"original_cli_spec_links: {original_virtctl_console_cli_downloads_spec_links}, "
73+
f"current_cli_spec_links: {current_cli_spec_links}"
74+
)
75+
else:
76+
LOGGER.error(
77+
f"Failed to get console spec links: {current_cli_spec_links}, "
78+
f"There are urls that are not updated with new hostname: {urls_not_updated_with_new_hostname}"
79+
)
7580
raise
76-
77-
78-
def validate_custom_cli_urls_downloaded(urls: list[str], dest_dir: LocalPath) -> None:
79-
not_valid_urls = [url for url in urls if not download_and_extract_file_from_cluster(tmpdir=dest_dir, url=url)]
80-
assert not not_valid_urls, f"Some urls is not valid, {not_valid_urls}"

tests/install_upgrade_operators/product_install/test_install_openshift_virtualization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
CNV_ALERT_CLEANUP_TEST = "test_cnv_installation_alert_cleanup"
3232
LOGGER = logging.getLogger(__name__)
3333

34-
pytestmark = [pytest.mark.install]
34+
pytestmark = [pytest.mark.install, pytest.mark.s390x]
3535

3636

3737
@pytest.mark.polarion("CNV-10072")

0 commit comments

Comments
 (0)