From bbbff4309b983fff2b2a241db247da67fa746021 Mon Sep 17 00:00:00 2001 From: reluctantfuturist Date: Thu, 17 Apr 2025 00:02:59 -0700 Subject: [PATCH] test fix --- tests/integration/test_ubi9_compiles.py | 63 ------------------------ tests/integration/test_ubi9_toolchain.py | 60 +++++++--------------- 2 files changed, 18 insertions(+), 105 deletions(-) delete mode 100644 tests/integration/test_ubi9_compiles.py diff --git a/tests/integration/test_ubi9_compiles.py b/tests/integration/test_ubi9_compiles.py deleted file mode 100644 index 29f9eb0ba..000000000 --- a/tests/integration/test_ubi9_compiles.py +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under the terms described in the LICENSE file in -# the root directory of this source tree. - -import os -import subprocess -import tempfile -import textwrap -from pathlib import Path - -import pytest -import yaml - -pytestmark = pytest.mark.integration # filtered out of the fast suite - - -def _tmp_yaml() -> Path: - f = tempfile.NamedTemporaryFile(delete=False, suffix=".yaml") - yaml.safe_dump( - { - "version": "2", - "distribution_spec": { - "description": "UBI9 compile smoke", - "providers": { - "inference": ["remote::ollama"], - "vector_io": ["inline::faiss"], - }, - "container_image": "registry.access.redhat.com/ubi9", - }, - "image_type": "container", - "image_name": "ci-test", - }, - f, - ) - f.close() - return Path(f.name) - - -def test_image_compiles_c(): - cfg = _tmp_yaml() - tag = "ci-test:dev" - - # Build image (providers‑build.yml already did `uv venv` etc.) - subprocess.run( - ["llama", "stack", "build", "--config", cfg, "--image-name", "ci-test"], - check=True, - env={**os.environ, "USE_COPY_NOT_MOUNT": "true"}, - ) - - # compile a hello‑world c program inside the container - hello_c = textwrap.dedent(""" - #include - int main(){puts("ok");return 0;} - """) - with tempfile.NamedTemporaryFile(delete=False, suffix=".c") as f: - f.write(hello_c.encode()) - - subprocess.run( - ["docker", "run", "--rm", "-v", f.name + ":/tmp/a.c", tag, "bash", "-c", "gcc /tmp/a.c -o /tmp/a && /tmp/a"], - check=True, - ) diff --git a/tests/integration/test_ubi9_toolchain.py b/tests/integration/test_ubi9_toolchain.py index 20c0589c5..108f7a2c0 100644 --- a/tests/integration/test_ubi9_toolchain.py +++ b/tests/integration/test_ubi9_toolchain.py @@ -4,50 +4,26 @@ # This source code is licensed under the terms described in the LICENSE file in # the root directory of this source tree. -import re -import subprocess -import tempfile +# tests/integration/test_ubi9_toolchain.py + from pathlib import Path -import yaml -# exact packages we just added -REQUIRED_PKGS = ("python3.11-devel", "gcc", "make") - - -def _tmp_yaml() -> Path: - f = tempfile.NamedTemporaryFile(delete=False, suffix=".yaml") - yaml.safe_dump( - { - "version": "2", - "distribution_spec": { - "description": "CI smoke test", - "providers": { - "inference": ["remote::ollama"], - "vector_io": ["inline::faiss"], - }, - "container_image": "registry.access.redhat.com/ubi9", - }, - "image_type": "container", - "image_name": "ci-test", - }, - f, +def test_ubi9_compiler_packages_present(): + """ + Verify that the UBI9 dnf install line in build_container.sh includes + python3.11‑setuptools, python3.11‑devel, gcc, and make. + """ + script = ( + Path(__file__).parents[2] # moves from tests/integration up to repo root + / "llama_stack" + / "distribution" + / "build_container.sh" ) - f.close() - return Path(f.name) + content = script.read_text(encoding="utf-8") - -def test_ubi9_toolchain_present(): - cfg = _tmp_yaml() - - # --dry-run only renders the Containerfile - out = subprocess.run( - ["llama", "stack", "build", "--config", cfg, "--dry-run"], - text=True, - capture_output=True, - check=True, - ).stdout - - cfile = Path(re.search(r"(/tmp/.+?/Containerfile)", out).group(1)).read_text() - missing = [p for p in REQUIRED_PKGS if p not in cfile] - assert not missing, f"dnf line lost packages: {', '.join(missing)}" + expected = "python3.11-setuptools python3.11-devel gcc make" + assert expected in content, ( + f"Expected to find '{expected}' in the UBI9 install line, but it was missing.\n\n" + f"Content of {script}:\n{content}" + )