Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P8425
locust_kask.py
Active
Public
Actions
Authored by
akosiaris
on Apr 22 2019, 6:55 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
SRE
Prod-Kubernetes
Referenced Files
F28731967: raw.txt
Apr 22 2019, 6:55 PM
2019-04-22 18:55:22 (UTC+0)
Subscribers
None
from
locust
import
HttpLocust
,
TaskSet
,
task
import
string
import
random
STRINGLENGTH
=
32
BASE_URL
=
'/sessions/v1/'
class
UserBehavior
(
TaskSet
):
min_wait
=
1000
max_wait
=
5000
def
on_start
(
self
):
letters
=
string
.
ascii_lowercase
self
.
key
=
''
.
join
(
random
.
choice
(
letters
)
for
i
in
range
(
STRINGLENGTH
))
self
.
key
=
BASE_URL
+
self
.
key
self
.
data
=
''
.
join
(
random
.
choice
(
letters
)
for
i
in
range
(
STRINGLENGTH
))
@task
(
5
)
def
set
(
self
):
self
.
client
.
post
(
self
.
key
,
data
=
self
.
data
,
headers
=
{
'Content-Type'
:
'application/octet-stream'
},
name
=
'post'
,
)
@task
(
94
)
def
get
(
self
):
with
self
.
client
.
get
(
self
.
key
,
name
=
'get'
,
catch_response
=
True
)
as
response
:
if
response
.
status_code
==
404
:
response
.
success
()
@task
(
1
)
def
delete
(
self
):
self
.
client
.
delete
(
self
.
key
,
name
=
'delete'
)
class
HealthCheckBehavior
(
TaskSet
):
min_wait
=
10000
max_wait
=
10000
@task
def
healthz
(
self
):
self
.
client
.
get
(
'/healthz'
)
@task
def
metrics
(
self
):
self
.
client
.
get
(
'/metrics'
)
class
SessionUser
(
HttpLocust
):
weight
=
50
task_set
=
UserBehavior
class
HealthCheckUser
(
HttpLocust
):
weight
=
1
task_set
=
HealthCheckBehavior
Event Timeline
akosiaris
created this paste.
Apr 22 2019, 6:55 PM
2019-04-22 18:55:22 (UTC+0)
akosiaris
mentioned this in
T220401: Introduce kask session storage service to kubernetes
.
Apr 22 2019, 7:10 PM
2019-04-22 19:10:11 (UTC+0)
•
mobrovac
mentioned this in
T223953: Deploy the RESTBase front-end service (RESTRouter) to Kubernetes
.
May 29 2019, 9:57 AM
2019-05-29 09:57:47 (UTC+0)
•
mobrovac
mentioned this in
T226538: Conduct basic load-test experiments for RESTRouter in k8s
.
Jun 25 2019, 5:29 PM
2019-06-25 17:29:14 (UTC+0)
Log In to Comment