批量数据请求接口

以下是一个简单的demo模型,具体的注册接口替换过去就可以了

# 保存为 locustfile4.py
#  coding=utf-8
from locust import HttpLocust, TaskSet, task
import queue class test_taskset(TaskSet):  @task def register(self): try: tel = self.locust.telqueue.get() # 获取队列里的数据 print(tel) except queue.Empty: # 队列取空后,直接退出 print("no data exist") exit(0) print("当前注册手机号:%s" % tel) # body = { # "username": tel, # "psd": "123456", # } # self.client.post("/register", data=body) # POST方法发送请求 class test_run(HttpLocust): host = 'http://192.168.1.xxx:80' task_set = test_taskset # 生成测试手机号 teldatas = [str(13812120000+i) for i in range(100)] # 添加到队列 telqueue = queue.Queue() for i in teldatas: telqueue.put_nowait(i) if __name__ == "__main__": import os os.system("locust -f locustfile4.py")

转载于:https://www.cnblogs.com/yaohu/p/10305502.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值