Load test with Locust.io

This commit is contained in:
Yghor Kerscher 2017-10-26 21:53:55 +02:00
parent 4320af064c
commit 173fc4cec2
2 changed files with 108 additions and 0 deletions

View File

@ -0,0 +1,91 @@
from locust import HttpLocust, task, TaskSet
from random import randrange
class HoogleQueries(TaskSet):
@task
def hoogle_queries(self):
# TODO: Get actual common queries from server logs
_hoogle_queries = [
"Ord",
"Eq",
"Num",
"pack",
"Text -> String",
"fmap",
"a -> a",
"traverse",
"bracket",
"^.",
">>>",
"<$>",
"bimap",
"inject"
]
for q in _hoogle_queries:
self.client.get("/lts/hoogle?q=" + q, name="/lts/hoogle?q=[:query]")
@task
def stop(self):
self.interrupt()
class PackageBrowser(TaskSet):
@task(50)
def list_packages(self):
self.client.get("/lts")
@task(10)
def browse_package(self):
# TODO: Get packages to test from up-to-date listing on Stackage, move out of here
_packages = [
"accelerate",
"adjunctions",
"aeson",
"binary",
"both",
"extensible-effects",
"hamlet",
"hdocs",
"microlens",
"range",
"sort",
"text",
"universe"
]
self.client.get("/lts/package/" + _packages[randrange(len(_packages))], name="/lts/package/:package")
@task(2)
def stop(self):
self.interrupt()
class TopLevelPages(TaskSet):
@task(30)
def docs(self):
self.client.get("/docs")
@task(20)
def install(self):
self.client.get("/install")
@task(5)
def nightly(self):
self.client.get("/nightly")
@task(2)
def snapshots(self):
self.client.get("/snapshots")
@task(2)
def stop(self):
self.interrupt()
class UserBehaviour(TaskSet):
tasks = {
HoogleQueries : 2,
PackageBrowser : 2,
TopLevelPages : 1
}
class WebsiteUser(HttpLocust):
task_set = UserBehaviour
min_wait = 1000
max_wait = 9000

View File

@ -0,0 +1,17 @@
certifi==2017.4.17
chardet==3.0.4
click==6.7
Flask==0.12.2
gevent==1.2.2
greenlet==0.4.12
idna==2.5
itsdangerous==0.24
Jinja2==2.9.6
-e git://github.com/locustio/locust.git@072d7752552ff32898253fcd5734c3b64995c17e#egg=locustio
MarkupSafe==1.0
msgpack-python==0.4.8
pyzmq==15.2.0
requests==2.18.1
six==1.10.0
urllib3==1.21.1
Werkzeug==0.12.2