28 lines
761 B
Python
28 lines
761 B
Python
from locust import HttpUser, task, between
|
|
import random
|
|
|
|
class StudentUser(HttpUser):
|
|
wait_time = between(1, 10)
|
|
|
|
def on_start(self):
|
|
# Register a user and get a cookie
|
|
username = f"testuser_{random.randint(1, 100000)}"
|
|
self.client.post("/register", data={
|
|
"username": username,
|
|
"acknowledge": "on"
|
|
})
|
|
self.client.post("/access", data={"password": "locust"})
|
|
|
|
@task(5)
|
|
def view_index(self):
|
|
self.client.get("/")
|
|
|
|
@task(1)
|
|
def enter_password(self):
|
|
self.client.post("/access", data={"password": "locust_test"})
|
|
|
|
@task(3)
|
|
def view_slide(self):
|
|
# Simulate loading slide files
|
|
self.client.get("/slides/itsec2526/tut-01/index.html")
|