-
Notifications
You must be signed in to change notification settings - Fork 71
Support multi-arch cpu_arch in py_config and schedulable_nodes #4972
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
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 |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |
| from utilities.bitwarden import get_cnv_tests_secret_by_name | ||
| from utilities.constants import ( | ||
| AMD_64, | ||
| MULTIARCH, | ||
| QUARANTINED, | ||
| SETUP_ERROR, | ||
| TIMEOUT_5MIN, | ||
|
|
@@ -558,6 +559,15 @@ def filter_sno_only_tests(items: list[Item], config: Config) -> list[Item]: | |
| return items | ||
|
|
||
|
|
||
| def filter_multiarch_tests(items: list[Item], config: Config) -> list[Item]: | ||
| if py_config.get("cluster_type") == MULTIARCH: | ||
| return items | ||
| discard_tests, items_to_return = remove_tests_from_list(items=items, filter_str="multiarch") | ||
| if discard_tests: | ||
| config.hook.pytest_deselected(items=discard_tests) | ||
| return items_to_return | ||
|
Comment on lines
+562
to
+568
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: Keep non-fixture helpers out of Line 562 adds ♻️ Suggested refactor# conftest.py
from utilities.pytest_utils import (
...
+ filter_multiarch_tests,
...
)
- def filter_multiarch_tests(items: list[Item], config: Config) -> list[Item]:
- if py_config.get("cluster_type") == MULTIARCH:
- return items
- discard_tests, items_to_return = remove_tests_from_list(items=items, filter_str="multiarch")
- if discard_tests:
- config.hook.pytest_deselected(items=discard_tests)
- return items_to_return# utilities/pytest_utils.py
from _pytest.config import Config
from pytest import Item
from pytest_testconfig import config as py_config
from utilities.constants import MULTIARCH
def filter_multiarch_tests(items: list[Item], config: Config) -> list[Item]:
if py_config.get("cluster_type") == MULTIARCH:
return items
discard_tests = [item for item in items if "multiarch" in item.keywords]
kept_items = [item for item in items if "multiarch" not in item.keywords]
if discard_tests:
config.hook.pytest_deselected(items=discard_tests)
return kept_itemsAs per coding guidelines: " 🤖 Prompt for AI Agents✅ Confirmed as addressed by @hmeir
Contributor
Author
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. all other similar functions are there
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.
✏️ Learnings added
🧠 Learnings used
Collaborator
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. @hmeir please move, as commented by coderabbit, to pytest_utils.
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.
Collaborator
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. not addressed |
||
|
|
||
|
|
||
| def remove_tests_from_list(items: list[Item], filter_str: str) -> tuple[list[Item], list[Item]]: | ||
| discard_tests: list[Item] = [] | ||
| items_to_return: list[Item] = [] | ||
|
|
@@ -635,6 +645,7 @@ def pytest_collection_modifyitems(session, config, items): | |
| config.hook.pytest_deselected(items=discard) | ||
| items[:] = filter_deprecated_api_tests(items=items, config=config) | ||
| items[:] = filter_sno_only_tests(items=items, config=config) | ||
| items[:] = filter_multiarch_tests(items=items, config=config) | ||
| items[:] = mark_nmstate_dependent_tests(items=items) | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,7 @@ | |
| from libs.net.ip import filter_link_local_addresses, random_ipv4_address, random_ipv6_address | ||
| from libs.net.vmspec import lookup_iface_status | ||
| from tests.utils import download_and_extract_tar | ||
| from utilities.architecture import get_cluster_architecture | ||
| from utilities.artifactory import get_artifactory_header, get_http_image_url, get_test_artifact_server_url | ||
| from utilities.bitwarden import get_cnv_tests_secret_by_name | ||
| from utilities.cluster import cache_admin_client, get_oc_whoami_username | ||
|
|
@@ -446,6 +447,7 @@ def schedulable_nodes(nodes): | |
| """ | ||
| schedulable_label = "kubevirt.io/schedulable" | ||
| cpu_arch = py_config.get("cpu_arch") | ||
| cpu_archs = [cpu_arch] if isinstance(cpu_arch, str) else cpu_arch | ||
|
hmeir marked this conversation as resolved.
|
||
| schedulable = [ | ||
| node | ||
| for node in nodes | ||
|
|
@@ -454,7 +456,7 @@ def schedulable_nodes(nodes): | |
| and not node.instance.spec.unschedulable | ||
| and not kubernetes_taint_exists(node) | ||
| and node.kubelet_ready | ||
| and (not cpu_arch or node.labels.get(KUBERNETES_ARCH_LABEL) == cpu_arch) | ||
| and (not cpu_archs or node.labels.get(KUBERNETES_ARCH_LABEL) in cpu_archs) | ||
| ] | ||
|
|
||
| LOGGER.info(f"Schedulable nodes: {[node.name for node in schedulable]}, node architecture: {cpu_arch or 'all'}") | ||
|
|
@@ -1026,7 +1028,7 @@ def mac_pool(admin_client, hco_namespace): | |
|
|
||
| @pytest.fixture(scope="session") | ||
| def nodes_cpu_architecture(): | ||
| return py_config["cpu_arch"] | ||
| return py_config.get("cpu_arch") | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
|
|
@@ -1478,7 +1480,7 @@ def cluster_info( | |
| f"\tOCS version: {ocs_current_version}\n" | ||
| f"\tCNI type: {get_cluster_cni_type(admin_client=admin_client)}\n" | ||
| f"\tWorkers type: {workers_type}\n" | ||
| f"\tCluster CPU Architecture: {nodes_cpu_architecture}\n" | ||
| f"\tCluster CPU Architecture: {nodes_cpu_architecture or ', '.join(sorted(get_cluster_architecture()))}\n" | ||
|
Collaborator
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. why not use py_config["cluster_arch"]? |
||
| f"\tIPv4 cluster: {ipv4_supported_cluster()}\n" | ||
| f"\tIPv6 cluster: {ipv6_supported_cluster()}\n" | ||
| f"\tVirtctl version: \n\t{virtctl_client_version}\n\t{virtctl_server_version}\n" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.