locust -post请求
------------恢复内容开始------------
参考:https://www.cnblogs.com/imyalost/p/9758189.html
#coding=utf-8
import requests
from locust import HttpLocust,TaskSet,task
class Msg(TaskSet):
@task(1)
def get_blog(self):
header = { "Content-Type":"application/json"}
payload={
"data": "{\"phone\":\"7029876553\",:\"message's body\",\"action\":\"https://www.baidu.com\"}",
"appId": 1,
"sign": "d9347eb257a0",
"id": "500",
"packageName": "team.xxx.pay",
"body": "message's body",
"businessType": "pay",
"list": ["7029876123213553","702912312876554","7020981231236549"],
"title": "test11:06--message's title",
"operator": "1"
}
req = self.client.post("/push/push",data=payload ,headers=header, verify=False)
if req.status_code == 200:
print("success")
else:
print("fails")
class websitUser(HttpLocust):
task_set = Msg
min_wait = 1000 # 单位为毫秒
max_wait = 3000 # 单位为毫秒
if __name__ == "__main__":
import os
os.system("locust -f locust_api.py --host=http://dev.xxx.com")
------------恢复内容结束------------