Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit c1c7283

Browse files
committed
chore: clean e2e tests
1 parent e8b4cdc commit c1c7283

13 files changed

+132
-295
lines changed

engine/e2e-test/main.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,16 @@
22
import sys
33

44
### e2e tests are expensive, have to keep engines tests in order
5-
from test_api_engine_list import TestApiEngineList
6-
from test_api_engine_install import TestApiEngineInstall
7-
from test_api_engine_get import TestApiEngineGet
8-
9-
### models, keeps in order, note that we only uninstall engine after finishing all models test
10-
from test_api_model_pull_direct_url import TestApiModelPullDirectUrl
11-
from test_api_model_start_stop import TestApiModelStartStop
12-
from test_api_model_get import TestApiModelGet
13-
from test_api_model_list import TestApiModelList
14-
from test_api_model_update import TestApiModelUpdate
15-
from test_api_model_delete import TestApiModelDelete
5+
from test_api_engine import TestApiEngine
6+
from test_api_model import TestApiModel
167
from test_api_model_import import TestApiModelImport
17-
from test_api_engine_uninstall import TestApiEngineUninstall
188

199
###
2010
from test_cli_engine_get import TestCliEngineGet
2111
from test_cli_engine_install import TestCliEngineInstall
2212
from test_cli_engine_list import TestCliEngineList
2313
from test_cli_engine_uninstall import TestCliEngineUninstall
24-
from test_cli_model_delete import TestCliModelDelete
25-
from test_cli_model_pull_direct_url import TestCliModelPullDirectUrl
14+
from test_cli_model import TestCliModel
2615
from test_cli_server_start import TestCliServerStart
2716
from test_cortex_update import TestCortexUpdate
2817
from test_create_log_folder import TestCreateLogFolder

engine/e2e-test/test_api_engine_uninstall.py renamed to engine/e2e-test/test_api_engine.py

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,54 @@
1-
import time
2-
31
import pytest
42
import requests
3+
import time
54
from test_runner import (
6-
run,
7-
start_server_if_needed,
5+
start_server,
86
stop_server,
97
wait_for_websocket_download_success_event,
108
)
119

12-
13-
class TestApiEngineUninstall:
10+
class TestApiEngine:
1411

1512
@pytest.fixture(autouse=True)
1613
def setup_and_teardown(self):
1714
# Setup
18-
start_server_if_needed()
15+
success = start_server()
16+
if not success:
17+
raise Exception("Failed to start server")
1918

2019
yield
2120

2221
# Teardown
2322
stop_server()
2423

24+
# engines list
25+
def test_engines_list_api_run_successfully(self):
26+
response = requests.get("http://localhost:3928/engines")
27+
assert response.status_code == 200
28+
29+
# engines get
30+
def test_engines_get_llamacpp_should_be_successful(self):
31+
response = requests.get("http://localhost:3928/engines/llama-cpp")
32+
assert response.status_code == 200
33+
34+
# engines install
35+
def test_engines_install_llamacpp_specific_version_and_variant(self):
36+
data = {"version": "v0.1.35-27.10.24", "variant": "linux-amd64-avx-cuda-11-7"}
37+
response = requests.post(
38+
"http://localhost:3928/v1/engines/llama-cpp/install", json=data
39+
)
40+
assert response.status_code == 200
41+
42+
def test_engines_install_llamacpp_specific_version_and_null_variant(self):
43+
data = {"version": "v0.1.35-27.10.24"}
44+
response = requests.post(
45+
"http://localhost:3928/v1/engines/llama-cpp/install", json=data
46+
)
47+
assert response.status_code == 200
48+
49+
# engines uninstall
2550
@pytest.mark.asyncio
26-
async def test_engines_uninstall_llamacpp_should_be_successful(self):
51+
async def test_engines_install_uninstall_llamacpp_should_be_successful(self):
2752
response = requests.post("http://localhost:3928/v1/engines/llama-cpp/install")
2853
assert response.status_code == 200
2954
await wait_for_websocket_download_success_event(timeout=None)
@@ -33,7 +58,7 @@ async def test_engines_uninstall_llamacpp_should_be_successful(self):
3358
assert response.status_code == 200
3459

3560
@pytest.mark.asyncio
36-
async def test_engines_uninstall_llamacpp_with_only_version_should_be_failed(self):
61+
async def test_engines_install_uninstall_llamacpp_with_only_version_should_be_failed(self):
3762
# install first
3863
data = {"variant": "mac-arm64"}
3964
install_response = requests.post(
@@ -50,7 +75,7 @@ async def test_engines_uninstall_llamacpp_with_only_version_should_be_failed(sel
5075
assert response.json()["message"] == "No variant provided"
5176

5277
@pytest.mark.asyncio
53-
async def test_engines_uninstall_llamacpp_with_variant_should_be_successful(self):
78+
async def test_engines_install_uninstall_llamacpp_with_variant_should_be_successful(self):
5479
# install first
5580
data = {"variant": "mac-arm64"}
5681
install_response = requests.post(
@@ -62,7 +87,7 @@ async def test_engines_uninstall_llamacpp_with_variant_should_be_successful(self
6287
response = requests.delete("http://127.0.0.1:3928/v1/engines/llama-cpp/install")
6388
assert response.status_code == 200
6489

65-
def test_engines_uninstall_llamacpp_with_specific_variant_and_version_should_be_successful(
90+
def test_engines_install_uninstall_llamacpp_with_specific_variant_and_version_should_be_successful(
6691
self,
6792
):
6893
data = {"variant": "mac-arm64", "version": "v0.1.35"}
@@ -76,3 +101,5 @@ def test_engines_uninstall_llamacpp_with_specific_variant_and_version_should_be_
76101
"http://localhost:3928/v1/engines/llama-cpp/install", json=data
77102
)
78103
assert response.status_code == 200
104+
105+

engine/e2e-test/test_api_engine_get.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

engine/e2e-test/test_api_engine_install.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

engine/e2e-test/test_api_engine_list.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

engine/e2e-test/test_api_model_pull_direct_url.py renamed to engine/e2e-test/test_api_model.py

Lines changed: 73 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
11
import pytest
22
import requests
3+
import time
34
from test_runner import (
45
run,
56
start_server,
67
stop_server,
78
wait_for_websocket_download_success_event,
89
)
910

10-
11-
class TestApiModelPullDirectUrl:
11+
class TestApiModel:
1212
@pytest.fixture(autouse=True)
1313
def setup_and_teardown(self):
14-
# Setup
15-
stop_server()
14+
# Setup
1615
success = start_server()
1716
if not success:
1817
raise Exception("Failed to start server")
1918
# Delete model if exists
20-
run(
21-
"Delete model",
22-
[
23-
"models",
24-
"delete",
25-
"afrideva:zephyr-smol_llama-100m-sft-full-GGUF:zephyr-smol_llama-100m-sft-full.q2_k.gguf",
26-
],
27-
)
2819
yield
2920

3021
# Teardown
22+
stop_server()
23+
24+
# Pull with direct url
25+
@pytest.mark.asyncio
26+
async def test_model_pull_with_direct_url_should_be_success(self):
3127
run(
3228
"Delete model",
3329
[
@@ -36,10 +32,7 @@ def setup_and_teardown(self):
3632
"afrideva:zephyr-smol_llama-100m-sft-full-GGUF:zephyr-smol_llama-100m-sft-full.q2_k.gguf",
3733
],
3834
)
39-
stop_server()
40-
41-
@pytest.mark.asyncio
42-
async def test_model_pull_with_direct_url_should_be_success(self):
35+
4336
myobj = {
4437
"model": "https://huggingface.co/afrideva/zephyr-smol_llama-100m-sft-full-GGUF/blob/main/zephyr-smol_llama-100m-sft-full.q2_k.gguf"
4538
}
@@ -54,6 +47,15 @@ async def test_model_pull_with_direct_url_should_be_success(self):
5447
get_model_response.json()["model"]
5548
== "afrideva:zephyr-smol_llama-100m-sft-full-GGUF:zephyr-smol_llama-100m-sft-full.q2_k.gguf"
5649
)
50+
51+
run(
52+
"Delete model",
53+
[
54+
"models",
55+
"delete",
56+
"afrideva:zephyr-smol_llama-100m-sft-full-GGUF:zephyr-smol_llama-100m-sft-full.q2_k.gguf",
57+
],
58+
)
5759

5860
@pytest.mark.asyncio
5961
async def test_model_pull_with_direct_url_should_have_desired_name(self):
@@ -73,3 +75,58 @@ async def test_model_pull_with_direct_url_should_have_desired_name(self):
7375
get_model_response.json()["name"]
7476
== "smol_llama_100m"
7577
)
78+
79+
run(
80+
"Delete model",
81+
[
82+
"models",
83+
"delete",
84+
"afrideva:zephyr-smol_llama-100m-sft-full-GGUF:zephyr-smol_llama-100m-sft-full.q2_k.gguf",
85+
],
86+
)
87+
88+
async def test_models_start_stop_should_be_successful(self):
89+
print("Install engine")
90+
response = requests.post("http://localhost:3928/v1/engines/llama-cpp/install")
91+
assert response.status_code == 200
92+
await wait_for_websocket_download_success_event(timeout=None)
93+
# TODO(sang) need to fix for cuda download
94+
time.sleep(30)
95+
96+
print("Pull model")
97+
json_body = {"model": "tinyllama:gguf"}
98+
response = requests.post("http://localhost:3928/v1/models/pull", json=json_body)
99+
assert response.status_code == 200, f"Failed to pull model: tinyllama:gguf"
100+
await wait_for_websocket_download_success_event(timeout=None)
101+
102+
# get API
103+
print("Get model")
104+
response = requests.get("http://localhost:3928/v1/models/tinyllama:gguf")
105+
assert response.status_code == 200
106+
107+
# list API
108+
print("List model")
109+
response = requests.get("http://localhost:3928/v1/models")
110+
assert response.status_code == 200
111+
112+
print("Start model")
113+
json_body = {"model": "tinyllama:gguf"}
114+
response = requests.post(
115+
"http://localhost:3928/v1/models/start", json=json_body
116+
)
117+
assert response.status_code == 200, f"status_code: {response.status_code}"
118+
119+
print("Stop model")
120+
response = requests.post("http://localhost:3928/v1/models/stop", json=json_body)
121+
assert response.status_code == 200, f"status_code: {response.status_code}"
122+
123+
# update API
124+
print("Update model")
125+
body_json = {'model': 'tinyllama:gguf'}
126+
response = requests.patch("http://localhost:3928/v1/models/tinyllama:gguf", json = body_json)
127+
assert response.status_code == 200
128+
129+
# delete API
130+
print("Delete model")
131+
response = requests.delete("http://localhost:3928/v1/models/tinyllama:gguf")
132+
assert response.status_code == 200

engine/e2e-test/test_api_model_delete.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

engine/e2e-test/test_api_model_get.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)