Skip to content

Commit 5b477a4

Browse files
committed
Add a health check endpoint and document CI/CD test server process termination.
1 parent 7031fe9 commit 5b477a4

12 files changed

Lines changed: 227 additions & 19 deletions

AGENT.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ Finally, we deployed to Render and set up GitHub Actions.
7878
- **The Fix**: We encountered a `psycopg2` error on Render.
7979
- **Prompt Example**: *"Render is failing with 'ModuleNotFoundError: No module named psycopg2'. I am using asyncpg. Update the database connection logic to handle Render's postgres:// URL and convert it to the async-compatible postgresql+asyncpg:// format."*
8080

81+
### Phase 7: CI/CD Optimization (The "Hang" Fix)
82+
We noticed the CI/CD pipeline was hanging even after tests passed.
83+
- **The Challenge**: Background processes (like our test server) can keep a CI runner alive if not cleaned up properly.
84+
- **The Solution**: We implemented **Process Group** termination in our test fixtures to ensure every background process is killed once the tests are done.
85+
- **Prompt Example**: *"The CI/CD pipeline is hanging indefinitely after tests pass. Update the server fixture in conftest.py to use process groups and os.killpg to ensure the background uvicorn process is fully terminated."*
86+
8187
---
8288

8389
## 🎓 Learning for Students: Tips for Success
219 Bytes
Binary file not shown.

server/app/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ class Config:
137137

138138
fastapi_app = FastAPI()
139139

140+
@fastapi_app.get("/health")
141+
async def health_check():
142+
return {"status": "ok"}
143+
140144
@fastapi_app.on_event("startup")
141145
async def startup():
142146
async with engine.begin() as conn:

server/server_50865.log

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
INFO: Started server process [99735]
2+
INFO: Waiting for application startup.
3+
2026-01-04 04:45:13,669 INFO sqlalchemy.engine.Engine BEGIN (implicit)
4+
2026-01-04 04:45:13,670 INFO sqlalchemy.engine.Engine PRAGMA main.table_info("users")
5+
2026-01-04 04:45:13,670 INFO sqlalchemy.engine.Engine [raw sql] ()
6+
2026-01-04 04:45:13,670 INFO sqlalchemy.engine.Engine PRAGMA temp.table_info("users")
7+
2026-01-04 04:45:13,671 INFO sqlalchemy.engine.Engine [raw sql] ()
8+
2026-01-04 04:45:13,671 INFO sqlalchemy.engine.Engine PRAGMA main.table_info("sessions")
9+
2026-01-04 04:45:13,671 INFO sqlalchemy.engine.Engine [raw sql] ()
10+
2026-01-04 04:45:13,672 INFO sqlalchemy.engine.Engine PRAGMA temp.table_info("sessions")
11+
2026-01-04 04:45:13,672 INFO sqlalchemy.engine.Engine [raw sql] ()
12+
2026-01-04 04:45:13,673 INFO sqlalchemy.engine.Engine
13+
CREATE TABLE users (
14+
id VARCHAR NOT NULL,
15+
email VARCHAR,
16+
password VARCHAR,
17+
name VARCHAR,
18+
role VARCHAR,
19+
PRIMARY KEY (id)
20+
)
21+
22+
23+
2026-01-04 04:45:13,673 INFO sqlalchemy.engine.Engine [no key 0.00012s] ()
24+
2026-01-04 04:45:13,867 INFO sqlalchemy.engine.Engine CREATE INDEX ix_users_id ON users (id)
25+
2026-01-04 04:45:13,867 INFO sqlalchemy.engine.Engine [no key 0.00015s] ()
26+
2026-01-04 04:45:13,872 INFO sqlalchemy.engine.Engine CREATE UNIQUE INDEX ix_users_email ON users (email)
27+
2026-01-04 04:45:13,872 INFO sqlalchemy.engine.Engine [no key 0.00013s] ()
28+
2026-01-04 04:45:13,876 INFO sqlalchemy.engine.Engine
29+
CREATE TABLE sessions (
30+
id VARCHAR NOT NULL,
31+
candidate_name VARCHAR,
32+
candidate_email VARCHAR,
33+
date VARCHAR,
34+
duration INTEGER,
35+
score INTEGER,
36+
status VARCHAR,
37+
language VARCHAR,
38+
notes TEXT,
39+
start_time VARCHAR,
40+
code TEXT,
41+
output TEXT,
42+
question JSON,
43+
server_time VARCHAR,
44+
whiteboard JSON,
45+
PRIMARY KEY (id)
46+
)
47+
48+
49+
2026-01-04 04:45:13,876 INFO sqlalchemy.engine.Engine [no key 0.00010s] ()
50+
2026-01-04 04:45:13,881 INFO sqlalchemy.engine.Engine CREATE INDEX ix_sessions_id ON sessions (id)
51+
2026-01-04 04:45:13,881 INFO sqlalchemy.engine.Engine [no key 0.00011s] ()
52+
2026-01-04 04:45:13,885 INFO sqlalchemy.engine.Engine COMMIT
53+
2026-01-04 04:45:13,886 INFO sqlalchemy.engine.Engine BEGIN (implicit)
54+
2026-01-04 04:45:13,889 INFO sqlalchemy.engine.Engine SELECT users.id, users.email, users.password, users.name, users.role
55+
FROM users
56+
2026-01-04 04:45:13,889 INFO sqlalchemy.engine.Engine [generated in 0.00014s] ()
57+
Seeding mock users...
58+
2026-01-04 04:45:13,892 INFO sqlalchemy.engine.Engine INSERT INTO users (id, email, password, name, role) VALUES (?, ?, ?, ?, ?)
59+
2026-01-04 04:45:13,892 INFO sqlalchemy.engine.Engine [generated in 0.00017s] [('user-1', 'interviewer@example.com', 'password123', 'Alice Interviewer', 'interviewer'), ('user-2', 'tech.lead@example.com', 'securepass', 'Bob Lead', 'interviewer'), ('user-3', 'candidate@example.com', 'candidate123', 'Charlie Candidate', 'candidate'), ('user-4', 'junior@example.com', 'juniorpass', 'Dave Junior', 'candidate')]
60+
2026-01-04 04:45:13,892 INFO sqlalchemy.engine.Engine COMMIT
61+
INFO: Application startup complete.
62+
INFO: Uvicorn running on http://127.0.0.1:50865 (Press CTRL+C to quit)
63+
Seeding complete.
64+
INFO: 127.0.0.1:43692 - "GET /health HTTP/1.1" 404 Not Found
65+
INFO: 127.0.0.1:43706 - "GET /health HTTP/1.1" 404 Not Found
66+
INFO: 127.0.0.1:43708 - "GET /health HTTP/1.1" 404 Not Found
67+
INFO: 127.0.0.1:43720 - "GET /health HTTP/1.1" 404 Not Found
68+
INFO: 127.0.0.1:43736 - "GET /health HTTP/1.1" 404 Not Found
69+
INFO: 127.0.0.1:43744 - "GET /health HTTP/1.1" 404 Not Found
70+
INFO: 127.0.0.1:43758 - "GET /health HTTP/1.1" 404 Not Found
71+
INFO: 127.0.0.1:43770 - "GET /health HTTP/1.1" 404 Not Found
72+
INFO: 127.0.0.1:43774 - "GET /health HTTP/1.1" 404 Not Found
73+
INFO: 127.0.0.1:43782 - "GET /health HTTP/1.1" 404 Not Found
74+
INFO: 127.0.0.1:43798 - "GET /health HTTP/1.1" 404 Not Found
75+
INFO: 127.0.0.1:43814 - "GET /health HTTP/1.1" 404 Not Found
76+
INFO: 127.0.0.1:43830 - "GET /health HTTP/1.1" 404 Not Found
77+
INFO: 127.0.0.1:43844 - "GET /health HTTP/1.1" 404 Not Found
78+
INFO: 127.0.0.1:43858 - "GET /health HTTP/1.1" 404 Not Found
79+
INFO: 127.0.0.1:43866 - "GET /health HTTP/1.1" 404 Not Found
80+
INFO: 127.0.0.1:43868 - "GET /health HTTP/1.1" 404 Not Found
81+
INFO: 127.0.0.1:43870 - "GET /health HTTP/1.1" 404 Not Found
82+
INFO: 127.0.0.1:43876 - "GET /health HTTP/1.1" 404 Not Found
83+
INFO: 127.0.0.1:43884 - "GET /health HTTP/1.1" 404 Not Found
84+
INFO: 127.0.0.1:43888 - "GET /health HTTP/1.1" 404 Not Found
85+
INFO: 127.0.0.1:43900 - "GET /health HTTP/1.1" 404 Not Found
86+
INFO: 127.0.0.1:43902 - "GET /health HTTP/1.1" 404 Not Found
87+
INFO: 127.0.0.1:43916 - "GET /health HTTP/1.1" 404 Not Found
88+
INFO: 127.0.0.1:43932 - "GET /health HTTP/1.1" 404 Not Found
89+
INFO: 127.0.0.1:43948 - "GET /health HTTP/1.1" 404 Not Found
90+
INFO: 127.0.0.1:43952 - "GET /health HTTP/1.1" 404 Not Found
91+
INFO: 127.0.0.1:43954 - "GET /health HTTP/1.1" 404 Not Found
92+
INFO: 127.0.0.1:43970 - "GET /health HTTP/1.1" 404 Not Found
93+
INFO: 127.0.0.1:43976 - "GET /health HTTP/1.1" 404 Not Found
94+
INFO: 127.0.0.1:43986 - "GET /health HTTP/1.1" 404 Not Found
95+
INFO: 127.0.0.1:43996 - "GET /health HTTP/1.1" 404 Not Found
96+
INFO: 127.0.0.1:44008 - "GET /health HTTP/1.1" 404 Not Found
97+
INFO: 127.0.0.1:44024 - "GET /health HTTP/1.1" 404 Not Found
98+
INFO: 127.0.0.1:38190 - "GET /health HTTP/1.1" 404 Not Found
99+
INFO: 127.0.0.1:38200 - "GET /health HTTP/1.1" 404 Not Found
100+
INFO: 127.0.0.1:38214 - "GET /health HTTP/1.1" 404 Not Found
101+
INFO: 127.0.0.1:38220 - "GET /health HTTP/1.1" 404 Not Found
102+
INFO: 127.0.0.1:38226 - "GET /health HTTP/1.1" 404 Not Found
103+
INFO: 127.0.0.1:38234 - "GET /health HTTP/1.1" 404 Not Found
104+
INFO: 127.0.0.1:38248 - "GET /health HTTP/1.1" 404 Not Found
105+
INFO: 127.0.0.1:38258 - "GET /health HTTP/1.1" 404 Not Found
106+
INFO: 127.0.0.1:38260 - "GET /health HTTP/1.1" 404 Not Found
107+
INFO: 127.0.0.1:38272 - "GET /health HTTP/1.1" 404 Not Found
108+
INFO: 127.0.0.1:38278 - "GET /health HTTP/1.1" 404 Not Found
109+
INFO: 127.0.0.1:38284 - "GET /health HTTP/1.1" 404 Not Found
110+
INFO: 127.0.0.1:38288 - "GET /health HTTP/1.1" 404 Not Found
111+
INFO: 127.0.0.1:38298 - "GET /health HTTP/1.1" 404 Not Found
112+
INFO: 127.0.0.1:38312 - "GET /health HTTP/1.1" 404 Not Found
113+
INFO: 127.0.0.1:38314 - "GET /health HTTP/1.1" 404 Not Found
114+
INFO: 127.0.0.1:38316 - "GET /health HTTP/1.1" 404 Not Found
115+
INFO: 127.0.0.1:38318 - "GET /health HTTP/1.1" 404 Not Found
116+
INFO: 127.0.0.1:38322 - "GET /health HTTP/1.1" 404 Not Found
117+
INFO: 127.0.0.1:38330 - "GET /health HTTP/1.1" 404 Not Found
118+
INFO: 127.0.0.1:38342 - "GET /health HTTP/1.1" 404 Not Found
119+
INFO: 127.0.0.1:38354 - "GET /health HTTP/1.1" 404 Not Found
120+
INFO: 127.0.0.1:38360 - "GET /health HTTP/1.1" 404 Not Found
121+
INFO: 127.0.0.1:38364 - "GET /health HTTP/1.1" 404 Not Found
122+
INFO: 127.0.0.1:38372 - "GET /health HTTP/1.1" 404 Not Found
123+
INFO: 127.0.0.1:38388 - "GET /health HTTP/1.1" 404 Not Found
124+
INFO: 127.0.0.1:38394 - "GET /health HTTP/1.1" 404 Not Found
125+
INFO: 127.0.0.1:38406 - "GET /health HTTP/1.1" 404 Not Found
126+
INFO: 127.0.0.1:38412 - "GET /health HTTP/1.1" 404 Not Found
127+
INFO: 127.0.0.1:38428 - "GET /health HTTP/1.1" 404 Not Found
128+
INFO: 127.0.0.1:38444 - "GET /health HTTP/1.1" 404 Not Found
129+
INFO: 127.0.0.1:38460 - "GET /health HTTP/1.1" 404 Not Found
130+
INFO: 127.0.0.1:38470 - "GET /health HTTP/1.1" 404 Not Found
131+
INFO: 127.0.0.1:38482 - "GET /health HTTP/1.1" 404 Not Found
132+
INFO: 127.0.0.1:38496 - "GET /health HTTP/1.1" 404 Not Found
133+
INFO: 127.0.0.1:38502 - "GET /health HTTP/1.1" 404 Not Found
134+
INFO: 127.0.0.1:38518 - "GET /health HTTP/1.1" 404 Not Found
135+
INFO: 127.0.0.1:38534 - "GET /health HTTP/1.1" 404 Not Found
136+
INFO: 127.0.0.1:38544 - "GET /health HTTP/1.1" 404 Not Found
137+
INFO: 127.0.0.1:38558 - "GET /health HTTP/1.1" 404 Not Found
138+
INFO: 127.0.0.1:38564 - "GET /health HTTP/1.1" 404 Not Found
139+
INFO: 127.0.0.1:38574 - "GET /health HTTP/1.1" 404 Not Found
140+
INFO: 127.0.0.1:38580 - "GET /health HTTP/1.1" 404 Not Found
141+
INFO: 127.0.0.1:38586 - "GET /health HTTP/1.1" 404 Not Found
142+
INFO: 127.0.0.1:52188 - "GET /health HTTP/1.1" 404 Not Found
143+
INFO: 127.0.0.1:52200 - "GET /health HTTP/1.1" 404 Not Found
144+
INFO: 127.0.0.1:52204 - "GET /health HTTP/1.1" 404 Not Found
145+
INFO: 127.0.0.1:52214 - "GET /health HTTP/1.1" 404 Not Found
146+
INFO: 127.0.0.1:52218 - "GET /health HTTP/1.1" 404 Not Found
147+
INFO: 127.0.0.1:52222 - "GET /health HTTP/1.1" 404 Not Found
148+
INFO: 127.0.0.1:52230 - "GET /health HTTP/1.1" 404 Not Found
149+
INFO: 127.0.0.1:52240 - "GET /health HTTP/1.1" 404 Not Found
150+
INFO: 127.0.0.1:52256 - "GET /health HTTP/1.1" 404 Not Found
151+
INFO: 127.0.0.1:52266 - "GET /health HTTP/1.1" 404 Not Found
152+
INFO: 127.0.0.1:52280 - "GET /health HTTP/1.1" 404 Not Found
153+
INFO: 127.0.0.1:52288 - "GET /health HTTP/1.1" 404 Not Found
154+
INFO: 127.0.0.1:52300 - "GET /health HTTP/1.1" 404 Not Found
155+
INFO: 127.0.0.1:52306 - "GET /health HTTP/1.1" 404 Not Found
156+
INFO: 127.0.0.1:52318 - "GET /health HTTP/1.1" 404 Not Found
157+
INFO: 127.0.0.1:52334 - "GET /health HTTP/1.1" 404 Not Found
158+
INFO: 127.0.0.1:52342 - "GET /health HTTP/1.1" 404 Not Found

server/test_manual.db

32 KB
Binary file not shown.

server/test_sync_40911.db

32 KB
Binary file not shown.

server/test_sync_44087.db

32 KB
Binary file not shown.

server/test_sync_50501.db

32 KB
Binary file not shown.

server/test_sync_50865.db

32 KB
Binary file not shown.

server/test_sync_56345.db

32 KB
Binary file not shown.

0 commit comments

Comments
 (0)