mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-03 17:39:17 +02:00
Added load testing test case
This commit is contained in:
parent
6b5cb9759a
commit
d1fcea5632
1 changed files with 38 additions and 0 deletions
38
api/tests/loadtesting/library.py
Normal file
38
api/tests/loadtesting/library.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
import os
|
||||
import urllib.parse
|
||||
|
||||
from locust import HttpLocust, TaskSet, task
|
||||
|
||||
JWT_TOKEN = os.environ.get("JWT_TOKEN")
|
||||
|
||||
DATA = {"playable": True}
|
||||
HEADERS = {}
|
||||
if JWT_TOKEN:
|
||||
print("Starting authenticated session")
|
||||
HEADERS["authorization"] = "JWT {}".format(JWT_TOKEN)
|
||||
|
||||
|
||||
class WebsiteTasks(TaskSet):
|
||||
@task
|
||||
def albums(self):
|
||||
self.client.get(
|
||||
"/api/v1/albums?" + urllib.parse.urlencode(DATA), headers=HEADERS
|
||||
)
|
||||
|
||||
@task
|
||||
def artists(self):
|
||||
self.client.get(
|
||||
"/api/v1/artists?" + urllib.parse.urlencode(DATA), headers=HEADERS
|
||||
)
|
||||
|
||||
@task
|
||||
def tracks(self):
|
||||
self.client.get(
|
||||
"/api/v1/tracks?" + urllib.parse.urlencode(DATA), headers=HEADERS
|
||||
)
|
||||
|
||||
|
||||
class WebsiteUser(HttpLocust):
|
||||
task_set = WebsiteTasks
|
||||
min_wait = 1000
|
||||
max_wait = 3000
|
Loading…
Add table
Add a link
Reference in a new issue