mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-03 09:21:45 +00:00
test fix
This commit is contained in:
parent
2396b1e13a
commit
bbbff4309b
2 changed files with 18 additions and 105 deletions
|
@ -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 <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,
|
|
||||||
)
|
|
|
@ -4,50 +4,26 @@
|
||||||
# This source code is licensed under the terms described in the LICENSE file in
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
# the root directory of this source tree.
|
# the root directory of this source tree.
|
||||||
|
|
||||||
import re
|
# tests/integration/test_ubi9_toolchain.py
|
||||||
import subprocess
|
|
||||||
import tempfile
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import yaml
|
|
||||||
|
|
||||||
# exact packages we just added
|
def test_ubi9_compiler_packages_present():
|
||||||
REQUIRED_PKGS = ("python3.11-devel", "gcc", "make")
|
"""
|
||||||
|
Verify that the UBI9 dnf install line in build_container.sh includes
|
||||||
|
python3.11‑setuptools, python3.11‑devel, gcc, and make.
|
||||||
def _tmp_yaml() -> Path:
|
"""
|
||||||
f = tempfile.NamedTemporaryFile(delete=False, suffix=".yaml")
|
script = (
|
||||||
yaml.safe_dump(
|
Path(__file__).parents[2] # moves from tests/integration up to repo root
|
||||||
{
|
/ "llama_stack"
|
||||||
"version": "2",
|
/ "distribution"
|
||||||
"distribution_spec": {
|
/ "build_container.sh"
|
||||||
"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()
|
content = script.read_text(encoding="utf-8")
|
||||||
return Path(f.name)
|
|
||||||
|
|
||||||
|
expected = "python3.11-setuptools python3.11-devel gcc make"
|
||||||
def test_ubi9_toolchain_present():
|
assert expected in content, (
|
||||||
cfg = _tmp_yaml()
|
f"Expected to find '{expected}' in the UBI9 install line, but it was missing.\n\n"
|
||||||
|
f"Content of {script}:\n{content}"
|
||||||
# --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)}"
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue