Skip to content

Commit

Permalink
feat: Store load test run
Browse files Browse the repository at this point in the history
Allows the monitor to wait until the run starts and share the run id with the load test script.
  • Loading branch information
bmtcril committed Mar 26, 2024
1 parent b21592a commit aa1339e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from random import choice
from textwrap import dedent
from time import sleep
from typing import Any
from typing import Any, List

import requests
from django.conf import settings
Expand Down Expand Up @@ -56,9 +56,10 @@ class LoadTest:
sent_event_count = 0
ch_runs_table = "load_test_runs"

def __init__(self, num_users: int, username_prefix: str):
def __init__(self, num_users: int, username_prefix: str, tags: List[str]):
self.num_users = num_users
self.username_prefix = username_prefix
self.tags = tags
self.run_id = str(uuid.uuid4())[:6]

self.course_shortname = str(uuid.uuid4())[:6]
Expand Down Expand Up @@ -116,6 +117,7 @@ def create_course(self) -> None:

def record_start(self) -> None:
self.record_to_clickhouse("start", {
"tags": self.tags,
"course_id": str(self.course.id),
"num_users": self.num_users,
"username_prefix": self.username_prefix,
Expand Down Expand Up @@ -261,6 +263,11 @@ def add_arguments(self, parser: Any) -> None:
default=0.75,
help="Fractional number of seconds to sleep between sending events.",
)
parser.add_argument(
"--tags",
nargs="*",
help="Tags to help define the run (ex: --tags celery 3workers k8s).",
)

def handle(self, *args, **options):
"""
Expand All @@ -270,7 +277,7 @@ def handle(self, *args, **options):
raise CommandError("This command must be run in the Open edX LMS or CMS.")

start = datetime.now()
lt = LoadTest(options["num_users"], options["username_prefix"])
lt = LoadTest(options["num_users"], options["username_prefix"], options["tags"])

try:
lt.trigger_events(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def _call_vector_graphql(self):
"""
Make the actual GraphQL call to the Vector API.
"""
# FIXME: Pull this from settings
# These values are hard coded in tutor local, K8s changes TBD
url = "http://vector:8686/graphql"
query = """
{
Expand Down

0 comments on commit aa1339e

Please sign in to comment.