Created
July 21, 2020 01:11
-
-
Save darenliang/2caaf2816908d3d95f9e112db1e02929 to your computer and use it in GitHub Desktop.
Basic Nikel API Benchmark Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import string | |
from locust import between, task | |
# Use fast http client | |
from locust.contrib.fasthttp import FastHttpUser | |
class NikelTestLoad(FastHttpUser): | |
# wait between 2 and 5 seconds | |
wait_time = between(2, 5) | |
@task | |
def courses(self): | |
""" | |
Test courses using a random char name and limit combination | |
""" | |
self.client.get(f"/api/courses?name={random.choice(string.ascii_lowercase)}&limit={random.randint(1, 100)}") | |
@task | |
def textbooks(self): | |
""" | |
Test textbooks using a random char title and limit combination | |
""" | |
self.client.get(f"/api/textbooks?title={random.choice(string.ascii_lowercase)}&limit={random.randint(1, 100)}") | |
@task | |
def exams(self): | |
""" | |
Test exams using a random char id and limit combination | |
""" | |
self.client.get(f"/api/exams?id={random.choice(string.ascii_lowercase)}&limit={random.randint(1, 100)}") | |
@task | |
def evals(self): | |
""" | |
Test evals using a random char name and limit combination | |
""" | |
self.client.get(f"/api/evals?name={random.choice(string.ascii_lowercase)}&limit={random.randint(1, 100)}") | |
@task | |
def food(self): | |
""" | |
Test food using a random char name and limit combination | |
""" | |
self.client.get(f"/api/food?name={random.choice(string.ascii_lowercase)}&limit={random.randint(1, 100)}") | |
@task | |
def services(self): | |
""" | |
Test services using a random char name and limit combination | |
""" | |
self.client.get(f"/api/services?name={random.choice(string.ascii_lowercase)}&limit={random.randint(1, 100)}") | |
@task | |
def buildings(self): | |
""" | |
Test buildings using a random char name and limit combination | |
""" | |
self.client.get(f"/api/buildings?name={random.choice(string.ascii_lowercase)}&limit={random.randint(1, 100)}") | |
@task | |
def parking(self): | |
""" | |
Test parking using a random char name and limit combination | |
""" | |
self.client.get(f"/api/parking?name={random.choice(string.ascii_lowercase)}&limit={random.randint(1, 100)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment