我正在使用Locust (python) 在 Django Web 应用程序上加载测试。运行脚本时,我不断收到 403 错误。
这是代码:
from locust import HttpLocust, TaskSet
def index(l):
l.client.get("/")
def login(l):
l.client.post("/login/", {"username":"an@id.com", "password":"education")
def upload(l):
l.client.get("/upload-image/")
def home(l):
l.client.get("/home/")
def settings(l):
l.client.get("/settings/")
def logout(l):
l.client.get("/logout/")
class UserBehavior(TaskSet):
tasks = {index:1, upload:1, home:1, settings:1, logout:1}
def on_start(self):
login(self)
class WebsiteUser(HttpLocust):
task_set = UserBehavior
min_wait=5000
max_wait=9000