关于怎么下载安装locust,网上已经有很多啦
我就大致说一下我的坑吧
我是一个神奇的人,基本上安装什么东西,没有坑,我也会弄出坑
from locust import HttpLocust, TaskSet, task
class UserBehavior(TaskSet):
def on_start(self):
""" on_start is called when a Locust start before any task is scheduled """
self.login()
def login(self):
self.client.post("/login", {"username":"ellen_key", "password":"education"})#post方法需要放入请求头之类的内容
@task(2)
def index(self):
self.client.get("/")# get方法只需要加入地址就可以
@task(1)#分权重
def profile(self):
self.client.get("/profile")
class WebsiteUser(HttpLocust):
task_set = UserBehavior
min_wait = 5000 #默认值,一般情况自带有
max_wait = 9000
是这样子的,你在你的电脑装入xshell等一些可以连接服务器的软件,想把服务器虚拟机作为locust的测试A端,那么你需要在服务器上安装locust等
安装完启动web网页时,注意是否有开防火墙
开启防火墙,打不开本机的浏览器
防火墙的相关操作如下:
service iptables status
# 停止防火墙
service iptables stop
# 启动防火墙
service iptables start
# 重启防火墙
service iptables restart
# 永久关闭防火墙
chkconfig iptables off
# 永久关闭后重启
chkconfig iptables on