Skip to content

Commit 040ff6b

Browse files
committed
refactor: improve architecture detection and feature support handling in tests
Signed-off-by: Nishan Acharya <[email protected]>
1 parent dff8aff commit 040ff6b

File tree

3 files changed

+51
-9
lines changed

3 files changed

+51
-9
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""Centralized configuration for architecture-specific feature limitations."""
2+
3+
ARCHITECTURE_LIMITATIONS = {
4+
"s390x": {"pdf_export": False, "pdf_export_reason": "TexLive and Pandoc dependencies not available on s390x"},
5+
"x86_64": {"pdf_export": True, "pdf_export_reason": "Full support available"},
6+
"aarch64": {"pdf_export": True, "pdf_export_reason": "Full support available"},
7+
"ppc64le": {"pdf_export": True, "pdf_export_reason": "Full support available"},
8+
}
9+
10+
# Architecture mapping from uname -m to common names
11+
ARCHITECTURE_NAMES = {"x86_64": "x86_64", "aarch64": "arm64", "ppc64le": "ppc64le", "s390x": "s390x"}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""Architecture detection utilities for container tests."""
2+
3+
import pytest
4+
5+
from tests.containers import docker_utils
6+
from tests.containers.architecture_support import ARCHITECTURE_LIMITATIONS
7+
from tests.containers.workbenches.workbench_image_test import WorkbenchContainer
8+
9+
10+
@pytest.fixture(scope="function")
11+
def container_architecture(jupyterlab_image):
12+
"""Cache architecture detection per test function."""
13+
container = WorkbenchContainer(image=jupyterlab_image.name, user=4321, group_add=[0])
14+
container.start(wait_for_readiness=False)
15+
try:
16+
exit_code, arch_output = container.exec(["uname", "-m"])
17+
if exit_code == 0:
18+
return arch_output.decode().strip()
19+
return None
20+
finally:
21+
docker_utils.NotebookContainer(container).stop(timeout=0)
22+
23+
24+
def is_feature_supported(architecture: str, feature: str) -> bool:
25+
"""Check if a feature is supported on the given architecture."""
26+
return ARCHITECTURE_LIMITATIONS.get(architecture, {}).get(feature, True)
27+
28+
29+
def get_architecture_limitation_reason(architecture: str, feature: str) -> str:
30+
"""Get the reason why a feature is not supported on the given architecture."""
31+
return ARCHITECTURE_LIMITATIONS.get(architecture, {}).get(f"{feature}_reason", "Unknown limitation")

tests/containers/workbenches/jupyterlab/jupyterlab_test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
import requests
99

1010
from tests.containers import conftest, docker_utils
11+
from tests.containers.architecture_utils import (
12+
get_architecture_limitation_reason,
13+
is_feature_supported,
14+
)
1115
from tests.containers.workbenches.workbench_image_test import WorkbenchContainer
1216

1317

@@ -56,16 +60,12 @@ def test_spinner_html_loaded(self, jupyterlab_image: conftest.Image) -> None:
5660

5761
@allure.issue("RHOAIENG-16568")
5862
@allure.description("Check that PDF export is working correctly")
59-
def test_pdf_export(self, jupyterlab_image: conftest.Image) -> None:
63+
def test_pdf_export(self, jupyterlab_image: conftest.Image, container_architecture) -> None:
64+
# Skip if PDF export is not supported on this architecture
65+
if not is_feature_supported(container_architecture, "pdf_export"):
66+
reason = get_architecture_limitation_reason(container_architecture, "pdf_export")
67+
pytest.skip(f"PDF export functionality is not supported on {container_architecture} architecture: {reason}")
6068
container = WorkbenchContainer(image=jupyterlab_image.name, user=4321, group_add=[0])
61-
# Skip if we're running on s390x architecture
62-
container.start(wait_for_readiness=False)
63-
try:
64-
exit_code, arch_output = container.exec(["uname", "-m"])
65-
if exit_code == 0 and arch_output.decode().strip() == "s390x":
66-
pytest.skip("PDF export functionality is not supported on s390x architecture")
67-
finally:
68-
docker_utils.NotebookContainer(container).stop(timeout=0)
6969
test_file_name = "test.ipybn"
7070
test_file_content = """{
7171
"cells": [

0 commit comments

Comments
 (0)