|
1 | 1 | # GPU Hot — tests |
2 | 2 |
|
3 | | -This folder holds **unit tests** (Python + browser-style JS), **load-test / mock-cluster** tooling, and Docker definitions for both. |
4 | | - |
5 | | ---- |
6 | | - |
7 | | -## Unit tests |
8 | | - |
9 | | -Backend logic is covered with **pytest** (`tests/unit/`). Frontend **static JS** (charts, UI, WebSocket helpers, `app.js`) is covered with **Vitest** + **jsdom** (`tests/frontend/`). |
10 | | - |
11 | | -| File | Role | |
12 | | -|------|------| |
13 | | -| `pytest.ini` | Pytest config (`testpaths = unit`, asyncio mode) | |
14 | | -| `package.json` | Vitest + jsdom; scripts: `npm test`, `npm run test:watch` | |
15 | | -| `vitest.config.js` | Vitest root = this directory; `frontend/setup.js` loads `static/js` under vm | |
16 | | -| `Dockerfile.unittest` | Image: Python deps + Node, runs pytest then Vitest | |
17 | | -| `docker-compose.unittest.yml` | Build/run the unittest image (context: repo root) | |
18 | | - |
19 | | -From the **repository root**, the usual entry point is: |
| 3 | +All tests are run from the **repository root** with: |
20 | 4 |
|
21 | 5 | ```bash |
22 | 6 | ./run_tests.sh |
23 | 7 | ``` |
24 | 8 |
|
25 | | -That builds and runs `docker compose -f tests/docker-compose.unittest.yml` (same as a manual `docker compose … build` / `run`). |
26 | | - |
27 | | -### Unit tests without Docker |
28 | | - |
29 | | -Requires Python with `pytest`, `pytest-asyncio`, `httpx` (see `requirements.txt` + extras used in `Dockerfile.unittest`), and Node 18+. |
30 | | - |
31 | | -```bash |
32 | | -# Backend |
33 | | -python -m pytest -c tests/pytest.ini |
| 9 | +This builds and runs the unit-test Docker image (`docker compose -f tests/docker-compose.unittest.yml`), which executes **pytest** (backend) and **Vitest** (frontend) inside the container. |
34 | 10 |
|
35 | | -# Frontend (from repo root) |
36 | | -npm install --prefix tests |
37 | | -npm test --prefix tests |
38 | | -``` |
| 11 | +--- |
39 | 12 |
|
40 | | -To show **Vitest** `console.*` output from app code (hidden by default), run: |
| 13 | +## What's tested |
41 | 14 |
|
42 | | -```bash |
43 | | -VITEST_SILENT=0 npm test --prefix tests |
44 | | -``` |
| 15 | +- **Backend** (pytest): Python logic in `tests/unit/` |
| 16 | +- **Frontend** (Vitest + jsdom): Static JS (charts, UI, WebSocket helpers) in `tests/frontend/` |
45 | 17 |
|
46 | 18 | --- |
47 | 19 |
|
48 | 20 | ## Load testing (mock cluster) |
49 | 21 |
|
50 | | -Simple load testing for multi-node GPU monitoring with realistic async patterns. |
51 | | - |
52 | | -### Quick start |
| 22 | +A mock GPU cluster for manual load testing. Edit `docker-compose.test.yml` to choose a preset (LIGHT / MEDIUM / HEAVY), then: |
53 | 23 |
|
54 | 24 | ```bash |
55 | 25 | cd tests |
56 | | -docker compose -f docker-compose.test.yml up |
57 | | -``` |
58 | | - |
59 | | -Open http://localhost:1312 to see the dashboard. |
60 | | - |
61 | | -### Architecture |
62 | | - |
63 | | -- **FastAPI + AsyncIO**: async Python for mock nodes |
64 | | -- **Native WebSockets**: direct WebSocket protocol |
65 | | -- **Concurrent mock nodes**: multiple nodes in parallel |
66 | | -- **Realistic GPU patterns**: training-style utilization, warmup, validation |
67 | | - |
68 | | -### Load test presets |
69 | | - |
70 | | -Edit `docker-compose.test.yml` and uncomment the preset you want. |
71 | | - |
72 | | -**LIGHT (3 nodes, 14 GPUs)** — development / quick runs: |
73 | | - |
74 | | -```yaml |
75 | | -- NODES=2,4,8 |
76 | | -- NODE_URLS=http://mock-cluster:13120,http://mock-cluster:13121,http://mock-cluster:13122 |
77 | | -``` |
78 | | -
|
79 | | -**MEDIUM (8 nodes, 64 GPUs)** — default-style medium cluster: |
80 | | -
|
81 | | -```yaml |
82 | | -- NODES=8,8,8,8,8,8,8,8 |
83 | | -- NODE_URLS=http://mock-cluster:13120,...,http://mock-cluster:13127 |
84 | | -``` |
85 | | -
|
86 | | -**HEAVY (20 nodes, 160 GPUs)** — stress / large cluster: |
87 | | -
|
88 | | -```yaml |
89 | | -- NODES=8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 |
90 | | -- NODE_URLS=http://mock-cluster:13120,...,http://mock-cluster:13139 |
91 | | -``` |
92 | | -
|
93 | | -### What’s simulated |
94 | | -
|
95 | | -- Realistic GPU patterns (epochs, warmup, validation) |
96 | | -- Idle + busy GPUs (~40% utilization typical of many clusters) |
97 | | -- Stable memory, clock P-states, data-loading dips, temperature correlation |
98 | | -
|
99 | | -### Load-test files |
100 | | -
|
101 | | -| File | Role | |
102 | | -|------|------| |
103 | | -| `test_cluster.py` | Mock GPU node (FastAPI + AsyncIO) | |
104 | | -| `docker-compose.test.yml` | Stack + presets | |
105 | | -| `Dockerfile.test` | Image for mock nodes | |
106 | | - |
107 | | -### Rebuild after changes |
108 | | - |
109 | | -```bash |
110 | | -docker compose -f docker-compose.test.yml down |
111 | 26 | docker compose -f docker-compose.test.yml up --build |
112 | 27 | ``` |
113 | 28 |
|
114 | | -(Run these from the `tests/` directory, or pass `-f tests/docker-compose.test.yml` from the repo root.) |
| 29 | +Open http://localhost:1312 to see the dashboard with simulated GPU nodes. |
0 commit comments