Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P8863
locust script for wikifeeds profiling
Active
Public
Actions
Authored by
MSantos
on Aug 5 2019, 8:05 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
Wikifeeds
Referenced Files
F29967356: raw.txt
Aug 5 2019, 8:05 PM
2019-08-05 20:05:24 (UTC+0)
Subscribers
None
from
locust
import
HttpLocust
,
TaskSet
,
task
import
random
def
random_year
():
return
random
.
randrange
(
2016
,
2019
)
def
random_month
():
month
=
random
.
randrange
(
1
,
13
)
if
month
<
10
:
return
"0
%d
"
%
(
month
)
else
:
return
"
%d
"
%
(
month
)
def
random_day
():
day
=
random
.
randrange
(
1
,
29
)
if
day
<
10
:
return
"0
%d
"
%
(
day
)
else
:
return
"
%d
"
%
(
day
)
class
UserBehavior
(
TaskSet
):
def
on_start
(
self
):
""" on_start is called when a Locust start before any task is scheduled """
def
on_stop
(
self
):
""" on_stop is called when the TaskSet is stopping """
@task
(
1
)
def
announcements
(
self
):
self
.
client
.
get
(
"/en.wikipedia.org/v1/feed/announcements"
)
@task
(
0
)
def
availability
(
self
):
self
.
client
.
get
(
"/en.wikipedia.org/v1/feed/availability"
)
@task
(
1
)
def
news
(
self
):
self
.
client
.
get
(
"/en.wikipedia.org/v1/page/news"
)
@task
(
23
)
def
random
(
self
):
self
.
client
.
get
(
"/en.wikipedia.org/v1/page/random/title"
)
@task
(
8
)
def
onthisday
(
self
):
self
.
client
.
get
(
"/en.wikipedia.org/v1/feed/onthisday/selected/
%s
/
%s
"
%
(
random_month
(),
random_day
()))
@task
(
3
)
def
featured
(
self
):
self
.
client
.
get
(
"/en.wikipedia.org/v1/page/featured/
%d
/
%s
/
%s
"
%
(
random_year
(),
random_month
(),
random_day
()))
@task
(
3
)
def
image_featured
(
self
):
self
.
client
.
get
(
"/en.wikipedia.org/v1/media/image/featured/
%d
/
%s
/
%s
"
%
(
random_year
(),
random_month
(),
random_day
()))
@task
(
3
)
def
most_read
(
self
):
self
.
client
.
get
(
"/en.wikipedia.org/v1/page/most-read/
%d
/
%s
/
%s
"
%
(
random_year
(),
random_month
(),
random_day
()))
class
WebsiteUser
(
HttpLocust
):
task_set
=
UserBehavior
min_wait
=
10000
max_wait
=
60000
Event Timeline
MSantos
created this paste.
Aug 5 2019, 8:05 PM
2019-08-05 20:05:24 (UTC+0)
MSantos
mentioned this in
T229287: Profile wikifeeds memory usage for Helm chart
.
Aug 5 2019, 8:25 PM
2019-08-05 20:25:04 (UTC+0)
Log In to Comment