Skip to content

Commit da50d8e

Browse files
committed
load tests for the APIs
1 parent 3a87176 commit da50d8e

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tests/load_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# load_test.py
2+
from locust import HttpUser, task, between
3+
import random
4+
5+
class StudentApiUser(HttpUser):
6+
wait_time = between(1, 2)
7+
8+
@task(2)
9+
def get_students(self):
10+
self.client.get("/students")
11+
12+
@task(1)
13+
def create_student(self):
14+
student_id = random.randint(1000, 9999)
15+
payload = {
16+
"name": f"Test User {student_id}",
17+
"domain": "Engineering",
18+
"gpa": round(random.uniform(6.0, 10.0), 2),
19+
"email": f"testuser{student_id}@example.com"
20+
}
21+
self.client.post("/students", json=payload)
22+

0 commit comments

Comments
 (0)