Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Plural
platform
chartmuseum
Commits
8075c86d
Commit
8075c86d
authored
7 years ago
by
Christian Jauvin
Committed by
David Genest
7 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Add locust.io load testing script
parent
52183fca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
loadtesting/locustfile.py
+44
-0
loadtesting/locustfile.py
with
44 additions
and
0 deletions
+44
-0
loadtesting/locustfile.py
0 → 100644
+
44
-
0
View file @
8075c86d
from
locust
import
HttpLocust
,
TaskSet
import
tarfile
import
io
patch_version
=
1
def
index
(
l
):
l
.
client
.
get
(
"/index.yaml"
)
def
metrics
(
l
):
l
.
client
.
get
(
"/metrics"
)
def
not_found
(
l
):
l
.
client
.
get
(
"/toto"
)
def
post_new_chart
(
l
):
global
patch_version
# Create dummy 'chartmuseum-loadtest' chart package for which we only increment the patch version
chart_name
=
'chartmuseum-loadtest'
chart_version
=
'0.0.%d'
%
patch_version
patch_version
+=
1
chart_fn
=
'%s-%s.tgz'
%
(
chart_name
,
chart_version
)
tgz_buf
=
io
.
BytesIO
()
t
=
tarfile
.
open
(
mode
=
"w:gz"
,
fileobj
=
tgz_buf
)
chart_content
=
b
'name: %s
\n
version: %s
\n
'
%
(
chart_name
.
encode
(
'utf8'
),
chart_version
.
encode
(
'utf8'
))
tarinfo
=
tarfile
.
TarInfo
(
'%s/Chart.yaml'
%
chart_name
)
tarinfo
.
size
=
len
(
chart_content
)
t
.
addfile
(
tarinfo
=
tarinfo
,
fileobj
=
io
.
BytesIO
(
chart_content
))
t
.
close
()
tgz_buf
.
seek
(
0
)
l
.
client
.
post
(
'/api/charts'
,
files
=
{
'chartfile'
:
(
chart_fn
,
tgz_buf
)})
class
UserBehavior
(
TaskSet
):
tasks
=
{
index
:
15
,
metrics
:
1
,
post_new_chart
:
1
}
class
WebsiteUser
(
HttpLocust
):
task_set
=
UserBehavior
min_wait
=
1000
max_wait
=
3000
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment