import queue from locust import HttpUser,task,TaskSet class AccountTask(TaskSet): def on_start(self): self.i=0 try: self.data = self.user.user_data.get() except queue.Empty: print('no data exist') exit(0) def on_stop(self): pass @task def account_register(self): print(self.data,self.i) self.client.post('/account/account/api/operate',json=self.data) self.i+=1 class AccountUser(HttpUser): min_wait = 1 max_wait = 5 tasks = [AccountTask] host = "https://127.0.0.1" user_data = queue.Queue() for i in range(100): data = { "username": "test%d" % i, "password": "pwd%d" % i, "email": "test%d@xxx.com" % i, "phone": "135%08d" % i, } user_data.put_nowait(data)
locust性能脚本参数化,每个用户使用不同的数据
最新推荐文章于 2022-12-05 15:41:45 发布