蝗虫,上传测试

Locust, upload test

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

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

我目前的测试是:

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

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

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