Skip to content

Commit e4eed74

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

File tree

3 files changed

+61
-10
lines changed

3 files changed

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

tests/containers/workbenches/jupyterlab/jupyterlab_test.py

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

1010
from tests.containers import conftest, docker_utils
1111
from tests.containers.workbenches.workbench_image_test import WorkbenchContainer
12-
12+
from tests.containers.architecture_utils import (is_feature_supported, get_architecture_limitation_reason, container_architecture)
1313

1414
class TestJupyterLabImage:
1515
"""Tests for JupyterLab Workbench images in this repository."""
@@ -56,16 +56,12 @@ def test_spinner_html_loaded(self, jupyterlab_image: conftest.Image) -> None:
5656

5757
@allure.issue("RHOAIENG-16568")
5858
@allure.description("Check that PDF export is working correctly")
59-
def test_pdf_export(self, jupyterlab_image: conftest.Image) -> None:
59+
def test_pdf_export(self, jupyterlab_image: conftest.Image, container_architecture) -> None:
60+
# Skip if PDF export is not supported on this architecture
61+
if not is_feature_supported(container_architecture,"pdf_export"):
62+
reason = get_architecture_limitation_reason(container_architecture, "pdf_export")
63+
pytest.skip(f"PDF export functionality is not supported on {container_architecture} architecture: {reason}")
6064
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)
6965
test_file_name = "test.ipybn"
7066
test_file_content = """{
7167
"cells": [

0 commit comments

Comments
 (0)