美文网首页工作生活
locust 使用记录

locust 使用记录

作者: Super7 | 来源:发表于2019-06-29 17:12 被阅读0次

    前置步骤

    • 安装完毕 ssl

    • 增加文件打开数

      ulimit -n 4096 
      

    开始

    以下是官方快速示例

    from locust import HttpLocust, TaskSet
    
    def login(l):
        l.client.post("/login", {"username":"ellen_key", "password":"education"})
    
    def logout(l):
        l.client.post("/logout", {"username":"ellen_key", "password":"education"})
    
    def index(l):
        l.client.get("/")
    
    def profile(l):
        l.client.get("/profile")
    
    class UserBehavior(TaskSet):
        tasks = {index: 2, profile: 1}
    
        def on_start(self):
            login(self)
    
        def on_stop(self):
            logout(self)
    
    class WebsiteUser(HttpLocust):
        task_set = UserBehavior
        min_wait = 5000
        max_wait = 9000
    

    相关文章

      网友评论

        本文标题:locust 使用记录

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