Added load testing test case

merge-requests/949/head
Eliot Berriot 2019-10-21 11:01:50 +02:00
rodzic 6b5cb9759a
commit d1fcea5632
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6B501DFD73514E14
1 zmienionych plików z 38 dodań i 0 usunięć

Wyświetl plik

@ -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