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
This commit is contained in:
reluctantfuturist 2025-04-16 23:34:29 -07:00
parent 712c6758c6
commit 2396b1e13a
6 changed files with 130 additions and 1 deletions

View file

@ -76,6 +76,11 @@ jobs:
# LLAMA_STACK_DIR is set to the current directory so we are building from the source
USE_COPY_NOT_MOUNT=true LLAMA_STACK_DIR=. uv run llama stack build --template ${{ matrix.template }} --image-type ${{ matrix.image-type }} --image-name test
- name: Integration compiler smoke
if: matrix.image-type == 'container'
run: |
pytest -m integration tests/integration/test_ubi9_compiles.py
- name: Print dependencies in the image
if: matrix.image-type == 'venv'
run: |

View file

@ -35,6 +35,10 @@ jobs:
pip install -r requirements.txt pytest
pip install -e .
- name: Run fast unit & smoke tests
run: |
pytest -m "not integration"
- name: Build providers
run: |
llama stack build --template ${{ matrix.provider }} --image-type venv

View file

@ -74,7 +74,8 @@ WORKDIR /app
RUN dnf -y update && dnf install -y iputils net-tools wget \
vim-minimal python3.11 python3.11-pip python3.11-wheel \
python3.11-setuptools && ln -s /bin/pip3.11 /bin/pip && ln -s /bin/python3.11 /bin/python && dnf clean all
python3.11-setuptools python3.11-devel gcc make && \
ln -s /bin/pip3.11 /bin/pip && ln -s /bin/python3.11 /bin/python && dnf clean all
ENV UV_SYSTEM_PYTHON=1
RUN pip install uv

View file

@ -0,0 +1,63 @@
# 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 (providersbuild.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 helloworld c program inside the container
hello_c = textwrap.dedent("""
#include <stdio.h>
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,
)

View file

@ -0,0 +1,53 @@
# 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)}"

3
tests/pytest.ini Normal file
View file

@ -0,0 +1,3 @@
[pytest]
markers =
integration: slow / dockerdependent tests