locust

作者: hehehehe | 来源:发表于2023-04-06 14:01 被阅读0次
from locust import HttpUser, task, between


# 相当于模拟一个用户
class WebUser(HttpUser):
    # 服务器的地址
    host = 'http://192.168.160.19:30032'

    # 下一个任务执行之前等待的时间,用于模式用户的思考时间
    wait_time = between(3, 5)  # 这里使用随机 3,5 秒钟

    @task(1)
    def addresses(self):
        # 获取用户地址
        data = [
            {
                "source": "GD",
                "name": "(津华苑) 海连 大厦",
                "kind": "美食;蛋糕甜品店",
                "address": "鹏鸣B2区",
                "province": "北京市",
                "city": "北京市",
                "district": "海淀区",
                "id": 23
            }
        ]
        self.client.post('/poi/poi_normal', json=data)

    def on_start(self):
        # 测试之前执行的操作
        print('用户登录')

    def on_stop(self):
        # 测试结束执行的操作
        print('用户退出')

locust -f normal_test.py

相关文章

网友评论

      本文标题:locust

      本文链接:https://www.haomeiwen.com/subject/ofruddtx.html