locust 上传文件性能测试
locust 上传文件性能测试:
代码示例:
from locust import HttpUser, TaskSet, task, os
import json
class MyTask(TaskSet):
@task
def FileTest(self):
self.file_data = {"file": open("D:/test.txt", "rb")}
with self.client.post("/pinter/file/api/upload2", files=self.file_data, name="上传文件接口") as response:
print(response.text)
class WebsiteUser(HttpUser):
tasks = [MyTask]
host = "http://lcocalhost:8080"
min_wait = 5000
max_wait = 9000
if __name__ == "__main__":
os.system("locust -f FileTest.py --host=http://localhost:8088")