From 3efcf8055131fb6f5d7bcaa8eeaf203374cb0157 Mon Sep 17 00:00:00 2001 From: Liora Milbaum Date: Sun, 24 Mar 2024 23:16:09 +0200 Subject: [PATCH] playground tests --- .devcontainer/Containerfile | 9 +++++++++ .devcontainer/devcontainer.json | 8 ++++++++ playground/Containerfile | 3 +-- playground/Makefile | 3 +++ playground/requirements.txt | 3 ++- playground/tests/__init__.py | 0 playground/tests/conftest.py | 7 +++++++ playground/tests/requirements.txt | 4 ++++ playground/tests/test_alive.py | 5 +++++ 9 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 .devcontainer/Containerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 playground/Makefile create mode 100644 playground/tests/__init__.py create mode 100644 playground/tests/conftest.py create mode 100644 playground/tests/requirements.txt create mode 100644 playground/tests/test_alive.py diff --git a/.devcontainer/Containerfile b/.devcontainer/Containerfile new file mode 100644 index 000000000..0289dffb6 --- /dev/null +++ b/.devcontainer/Containerfile @@ -0,0 +1,9 @@ +FROM registry.access.redhat.com/ubi9/python-311:1-52 + +USER root + +COPY playground/tests/requirements.txt . + +RUN pip3 install -r requirements.txt && \ + dnf install -y podman buildah && \ + dnf clean all diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..14e893dc2 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,8 @@ +{ + "name": "playground", + "build": { + "dockerfile": "Containerfile", + "context": ".." + }, + "privileged": true +} diff --git a/playground/Containerfile b/playground/Containerfile index e47b81dd9..ec1cbe5d4 100644 --- a/playground/Containerfile +++ b/playground/Containerfile @@ -1,8 +1,7 @@ FROM registry.access.redhat.com/ubi9/python-39:latest WORKDIR /locallm COPY requirements.txt /locallm/requirements.txt -RUN pip install --upgrade pip -RUN pip install --no-cache-dir --upgrade -r /locallm/requirements.txt +RUN pip install --no-cache-dir -r /locallm/requirements.txt COPY run.sh run.sh EXPOSE 8001 ENTRYPOINT [ "sh", "run.sh" ] diff --git a/playground/Makefile b/playground/Makefile new file mode 100644 index 000000000..98cc63cac --- /dev/null +++ b/playground/Makefile @@ -0,0 +1,3 @@ +.PHONY: build +build: + buildah bud -f Containerfile --no-cache -t playground . \ No newline at end of file diff --git a/playground/requirements.txt b/playground/requirements.txt index bbea3dd85..4e78064c7 100644 --- a/playground/requirements.txt +++ b/playground/requirements.txt @@ -1 +1,2 @@ -llama-cpp-python[server] \ No newline at end of file +llama-cpp-python[server]==0.2.57 +pip==24.0 \ No newline at end of file diff --git a/playground/tests/__init__.py b/playground/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/playground/tests/conftest.py b/playground/tests/conftest.py new file mode 100644 index 000000000..d1b733056 --- /dev/null +++ b/playground/tests/conftest.py @@ -0,0 +1,7 @@ +import pytest_container + +TW = pytest_container.Container(url="containers-storage:localhost/playground",forwarded_ports=[pytest_container.PortForwarding(container_port=8001)]) +CONTAINER_IMAGES = [TW] + +def pytest_generate_tests(metafunc): + pytest_container.auto_container_parametrize(metafunc) diff --git a/playground/tests/requirements.txt b/playground/tests/requirements.txt new file mode 100644 index 000000000..fd4236b64 --- /dev/null +++ b/playground/tests/requirements.txt @@ -0,0 +1,4 @@ +pip==24.0 +pytest-container==0.3.0 +pytest-testinfra==10.1.0 +pytest==8.1.1 diff --git a/playground/tests/test_alive.py b/playground/tests/test_alive.py new file mode 100644 index 000000000..0183fef0b --- /dev/null +++ b/playground/tests/test_alive.py @@ -0,0 +1,5 @@ +import pytest_container + + +def test_alive(auto_container: pytest_container.container.ContainerData, host): + res = host.run_expect([0],f"curl localhost:{auto_container.forwarded_ports[0].host_port}",).stdout.strip()