llama-stack-mirror/tests/integration/test_ubi9_toolchain.py
reluctantfuturist 2396b1e13a fix(build): add UBI 9 compiler tool‑chain and split fast/slow tests (#1970)
* build_container.sh
  - append `python3.11‑devel gcc make` to UBI 9 dnf line so C‑ext wheels build.
* tests/integration
  - + test_ubi9_toolchain.py   (fast; asserts pkgs exist in Containerfile)
  - + test_ubi9_compiles.py    (slow; @integration, compiles hello‑world in built image)
  - – test_container_build.py  (removed heavyweight test)
* pytest.ini
  - register `integration` marker.
* CI
  - tests.yml ⇒ `pytest -m "not integration"`
  - providers_build.yml ⇒ run integration compiler smoke for container jobs
2025-04-16 23:34:29 -07:00

53 lines
1.4 KiB
Python

# 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 re
import subprocess
import tempfile
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,
)
f.close()
return Path(f.name)
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)}"