【发布时间】:2019-07-15 14:58:33
【问题描述】:
操作系统: Windows 7 **蝗虫版本:**0.11.0
我正在探索 locust 工具,看看我是否可以在我的项目中使用这个工具。
我创建了以下文件以进行动手操作,但显然脚本没有运行。
但我不确定原因。
有人可以帮帮我吗?
蝗虫.py
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
输出:-
工具一直运行如下。
【问题讨论】:
-
你必须去
localhost:8089运行它 -
对我来说似乎是在运行。现在访问 web ui 并运行你的脚本
-
@DanielA.White 在命令行中指定主机时收到以下错误。 C DRive>locust -f IP ADDRESS:8089 Locustio.py [2019-07-15 23:11:51,436] DESKTOP-ER32D9B/ERROR/locust.main:找不到任何 locustfile!确保文件以 '.py' 结尾,并查看 --help 以获取可用选项。注意:.py 文件正确存在。
-
@CoreyGoldberg 我也无法通过网络访问。错误无法访问此站点 127.0.0.1 拒绝连接。
标签: locust