【问题标题】:Locust, upload test蝗虫,上传测试
【发布时间】:2016-07-31 07:22:05
【问题描述】:

我是 locust 新手,正在尝试进行第一次测试,上传带有标题和路径的简单文件,但似乎无法使其工作

很高兴得到任何帮助,谢谢!

我目前的测试是:

class UserBehavior(TaskSet):
        @task
        def post_img(self):
                self.client.headers['1'] = "1"
                self.client.headers['1'] = "1"
                test_file = 'PATH/TO.FILE'
                self.client.post("address", files={'file': open(test_file, 'rb')})


class WebsiteUser(HttpLocust):
        host = 'IP'
        task_set = UserBehavior
        min_wait = 100
        max_wait = 300

【问题讨论】:

    标签: python upload locust


    【解决方案1】:

    设法编写了一个上传文件的测试:

    class HttpSession(TaskSet):
            @task
            def post_img(self):
            headers = {'1': '1', '2': '2'}
                    test_file = '/pathTo/file.jpg'
                    self.client.request('POST', 'url', files={'file': open(test_file, 'rb')}, headers=headers)
    
    
    class WebsiteUser(HttpLocust):
            host = 'http://IP'
            task_set = HttpSession
            min_wait = 100
            max_wait = 300
    

    【讨论】:

      猜你喜欢
      • 2022-01-14
      • 2019-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多