This commit is contained in:
reluctantfuturist 2025-04-17 00:02:59 -07:00
parent 2396b1e13a
commit bbbff4309b
2 changed files with 18 additions and 105 deletions

View file

@ -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 (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

@ -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.11setuptools, python3.11devel, 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}"
)