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

Commit 7c3788d

Browse files
LeVinhGithubHarry Le
andauthored
task: expand e2e Hardware
Co-authored-by: Harry Le <harry@menlo.ai>
1 parent e541d12 commit 7c3788d

File tree

3 files changed

+253
-1
lines changed

3 files changed

+253
-1
lines changed
Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
import pytest
2+
import requests
3+
from utils.test_runner import start_server, stop_server
4+
import jsonschema
5+
from utils.logger import log_response
6+
from utils.assertion import assert_equal
7+
8+
9+
class TestApiGetHardware:
10+
11+
@pytest.fixture(autouse=True)
12+
def setup_and_teardown(self):
13+
# Setup
14+
success = start_server()
15+
if not success:
16+
raise Exception("Failed to start server")
17+
18+
yield
19+
20+
# Teardown
21+
stop_server()
22+
23+
def test_api_get_hardware_successfully(self):
24+
hardware_url = f"http://localhost:3928/v1/hardware"
25+
hardware_response = requests.get(hardware_url)
26+
json_data_hardware = hardware_response.json()
27+
log_response(json_data_hardware, "test_api_get_hardware_successfully")
28+
assert_equal(hardware_response.status_code,200)
29+
30+
schema = {
31+
"type": "object",
32+
"properties": {
33+
"cpu": {
34+
"type": "object",
35+
"properties": {
36+
"arch": {
37+
"type": "string",
38+
"example": "amd64",
39+
"description": "The architecture of the CPU."
40+
},
41+
"cores": {
42+
"type": "integer",
43+
"example": 8,
44+
"description": "The number of CPU cores available."
45+
},
46+
"instructions": {
47+
"type": "array",
48+
"items": {
49+
"type": "string"
50+
},
51+
"example": [
52+
"fpu",
53+
"mmx",
54+
"sse",
55+
"sse2",
56+
"sse3",
57+
"ssse3",
58+
"sse4_1",
59+
"sse4_2",
60+
"pclmulqdq",
61+
"avx",
62+
"avx2",
63+
"aes",
64+
"f16c"
65+
],
66+
"description": "A list of supported CPU instruction sets."
67+
},
68+
"model": {
69+
"type": "string",
70+
"example": "AMD Ryzen Threadripper PRO 5955WX 16-Cores",
71+
"description": "The model name of the CPU."
72+
}
73+
},
74+
"required": [
75+
"arch",
76+
"cores",
77+
"instructions",
78+
"model"
79+
]
80+
},
81+
"gpus": {
82+
"type": "array",
83+
"items": {
84+
"type": "object",
85+
"properties": {
86+
"activated": {
87+
"type": "boolean",
88+
"example": True,
89+
"description": "Indicates if the GPU is currently activated."
90+
},
91+
"additional_information": {
92+
"type": "object",
93+
"properties": {
94+
"compute_cap": {
95+
"type": "string",
96+
"example": "8.6",
97+
"description": "The compute capability of the GPU."
98+
},
99+
"driver_version": {
100+
"type": "string",
101+
"example": "535.183",
102+
"description": "The version of the installed driver."
103+
}
104+
},
105+
"required": [
106+
"compute_cap",
107+
"driver_version"
108+
]
109+
},
110+
"free_vram": {
111+
"type": "integer",
112+
"example": 23983,
113+
"description": "The amount of free VRAM in MB."
114+
},
115+
"id": {
116+
"type": "string",
117+
"example": "0",
118+
"description": "Unique identifier for the GPU."
119+
},
120+
"name": {
121+
"type": "string",
122+
"example": "NVIDIA GeForce RTX 3090",
123+
"description": "The name of the GPU model."
124+
},
125+
"total_vram": {
126+
"type": "integer",
127+
"example": 24576,
128+
"description": "The total VRAM available in MB."
129+
},
130+
"uuid": {
131+
"type": "string",
132+
"example": "GPU-5206045b-2a1c-1e7d-6c60-d7c367d02376",
133+
"description": "The universally unique identifier for the GPU."
134+
},
135+
"version": {
136+
"type": "string",
137+
"example": "12.2",
138+
"description": "The version of the GPU."
139+
}
140+
},
141+
"required": [
142+
"activated",
143+
"additional_information",
144+
"free_vram",
145+
"id",
146+
"name",
147+
"total_vram",
148+
"uuid",
149+
"version"
150+
]
151+
}
152+
},
153+
"os": {
154+
"type": "object",
155+
"properties": {
156+
"name": {
157+
"type": "string",
158+
"example": "Ubuntu 24.04.1 LTS",
159+
"description": "The name of the operating system."
160+
},
161+
"version": {
162+
"type": "string",
163+
"example": "24.04.1 LTS (Noble Numbat)",
164+
"description": "The version of the operating system."
165+
}
166+
},
167+
"required": [
168+
"name",
169+
"version"
170+
]
171+
},
172+
"power": {
173+
"type": "object",
174+
"properties": {
175+
"battery_life": {
176+
"type": "integer",
177+
"example": 0,
178+
"description": "The percentage of battery life remaining."
179+
},
180+
"charging_status": {
181+
"type": "string",
182+
"example": "",
183+
"description": "The charging status of the device."
184+
},
185+
"is_power_saving": {
186+
"type": "boolean",
187+
"example": False,
188+
"description": "Indicates if the power-saving mode is enabled."
189+
}
190+
},
191+
"required": [
192+
"battery_life",
193+
"charging_status",
194+
"is_power_saving"
195+
]
196+
},
197+
"ram": {
198+
"type": "object",
199+
"properties": {
200+
"available": {
201+
"type": "integer",
202+
"example": 11100,
203+
"description": "The amount of available RAM in MB."
204+
},
205+
"total": {
206+
"type": "integer",
207+
"example": 15991,
208+
"description": "The total RAM in MB."
209+
},
210+
"type": {
211+
"type": "string",
212+
"example": "",
213+
"description": "The type of RAM."
214+
}
215+
},
216+
"required": [
217+
"available",
218+
"total",
219+
"type"
220+
]
221+
},
222+
"storage": {
223+
"type": "object",
224+
"properties": {
225+
"available": {
226+
"type": "integer",
227+
"example": 0,
228+
"description": "The amount of available storage in MB."
229+
},
230+
"total": {
231+
"type": "integer",
232+
"example": 0,
233+
"description": "The total storage in MB."
234+
},
235+
"type": {
236+
"type": "string",
237+
"example": "",
238+
"description": "The type of storage."
239+
}
240+
},
241+
"required": [
242+
"available",
243+
"total",
244+
"type"
245+
]
246+
}
247+
}
248+
}
249+
250+
# Validate response schema
251+
jsonschema.validate(instance=json_data_hardware, schema=schema)

engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from api.thread.test_api_delete_thread import TestApiDeleteThread
3737
from api.thread.test_api_get_thread import TestApiGetThread
3838
from api.thread.test_api_get_list_thread import TestApiGetListThread
39+
from api.hardware.test_api_get_hardware import TestApiGetHardware
3940
from api.assistants.test_api_create_assistant import TestApiCreateAssistant
4041
from api.assistants.test_api_get_list_assistant import TestApiGetListAssistant
4142
from api.assistants.test_api_get_assistant import TestApiGetAssistant

engine/e2e-test/runner/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
from api.thread.test_api_delete_thread import TestApiDeleteThread
3737
from api.thread.test_api_get_thread import TestApiGetThread
3838
from api.thread.test_api_get_list_thread import TestApiGetListThread
39+
from api.hardware.test_api_get_hardware import TestApiGetHardware
3940
from api.assistants.test_api_create_assistant import TestApiCreateAssistant
4041
from api.assistants.test_api_get_list_assistant import TestApiGetListAssistant
4142
from api.assistants.test_api_get_assistant import TestApiGetAssistant
4243
from api.assistants.test_api_delete_assistant import TestApiDeleteAssistant
4344

44-
4545
###
4646
from cli.engines.test_cli_engine_get import TestCliEngineGet
4747
from cli.engines.test_cli_engine_install import TestCliEngineInstall

0 commit comments

Comments
 (0)