Skip to content
Snippets Groups Projects
Commit 2bc450ed authored by Martin Juhás's avatar Martin Juhás
Browse files

Merge branch 'update-perf-tests' into 'main'

Update performance tests

Closes #191

See merge request inject/backend!194
parents e194c260 76923dfc
No related branches found
No related tags found
No related merge requests found
...@@ -29,8 +29,11 @@ class Fragments: ...@@ -29,8 +29,11 @@ class Fragments:
@staticmethod @staticmethod
def email() -> ResponseField: def email() -> ResponseField:
return ResponseField( return ResponseField(
["id", "content", "fileName", "timestamp"], ["id", "timestamp"],
{"sender": Fragments.email_participant()}, {
"sender": Fragments.email_participant(),
"content": Fragments.content(),
},
) )
@staticmethod @staticmethod
...@@ -40,8 +43,10 @@ class Fragments: ...@@ -40,8 +43,10 @@ class Fragments:
@staticmethod @staticmethod
def action_log() -> ResponseField: def action_log() -> ResponseField:
return ResponseField( return ResponseField(
["id", "actionType", "content", "sender", "timestamp"], ["id", "timestamp", "type"],
{"tool": Fragments.tool(), "team": Fragments.team()}, {
"team": Fragments.team(),
},
) )
@staticmethod @staticmethod
...@@ -106,14 +111,14 @@ class Fragments: ...@@ -106,14 +111,14 @@ class Fragments:
return ResponseField( return ResponseField(
[ [
"exerciseDuration", "exerciseDuration",
"enableEmail",
"emailBetweenTeams", "emailBetweenTeams",
"teamFileUpload",
"teamVisibleMilestones",
"showExerciseTime", "showExerciseTime",
"enableRoles", "enableRoles",
"teamCount",
"customEmailSuffix", "customEmailSuffix",
], ],
{}, {},
) )
@staticmethod
def content() -> ResponseField:
return ResponseField(["id", "raw"], {})
...@@ -47,7 +47,11 @@ class CreateThreadAction(APIAction): ...@@ -47,7 +47,11 @@ class CreateThreadAction(APIAction):
self.query = GraphQLQuery( self.query = GraphQLQuery(
"mutation", "mutation",
self.query_name, self.query_name,
[("participantAddresses", "[String]!"), ("subject", "String!")], [
("participantAddresses", "[String]!"),
("subject", "String!"),
id_argument("exercise"),
],
ResponseField([], {"thread": Fragments.email_thread()}), ResponseField([], {"thread": Fragments.email_thread()}),
) )
......
No preview for this file type
...@@ -154,7 +154,9 @@ class InjectTeam(GraphQLUser): ...@@ -154,7 +154,9 @@ class InjectTeam(GraphQLUser):
"participant_addresses": [ "participant_addresses": [
other_address, other_address,
self.team.team_address, self.team.team_address,
] ],
"subject": f"{self.team.team_id} {self.team.team_address} {other_address}",
"exercise_id": self.team.exercise_id,
}, },
{}, {},
) )
......
...@@ -2,17 +2,22 @@ import argparse ...@@ -2,17 +2,22 @@ import argparse
import os import os
from dataclasses import dataclass from dataclasses import dataclass
from typing import List, Dict, Any from typing import List, Dict, Any
import django
import gevent import gevent
from gevent import monkey from gevent import monkey
from locust.html import get_html_report from locust.html import get_html_report
from common_lib.utils import get_definition_id # from common_lib.utils import get_definition_id
# without this, a warning gets thrown # without this, a warning gets thrown
monkey.patch_all() monkey.patch_all()
import requests import requests
import logging import logging
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ttxbackend.settings")
django.setup()
from graphene_django.utils import camelize from graphene_django.utils import camelize
from locust import events from locust import events
from locust.env import Environment from locust.env import Environment
...@@ -94,12 +99,18 @@ def upload_definition(definition_path: str) -> int: ...@@ -94,12 +99,18 @@ def upload_definition(definition_path: str) -> int:
files=files, files=files,
data=values, data=values,
) )
return get_definition_id(response.status_code, response.content) id = response.json()["detail"].split(":")[1]
return int(id)
def get_teams(team_dicts: List[dict]) -> List[TeamData]: def get_teams(exercise_id: int, team_dicts: List[dict]) -> List[TeamData]:
return [ return [
TeamData(int(team["id"]), str(team["emailAddress"]["address"]), []) TeamData(
exercise_id,
int(team["id"]),
str(team["emailAddress"]["address"]),
[],
)
for team in team_dicts for team in team_dicts
] ]
...@@ -113,10 +124,8 @@ def get_exercise_config(exercise_id: int) -> Dict[str, Any]: ...@@ -113,10 +124,8 @@ def get_exercise_config(exercise_id: int) -> Dict[str, Any]:
def create_exercise(definition_id: int, team_count: int) -> PreparedExercise: def create_exercise(definition_id: int, team_count: int) -> PreparedExercise:
action = CreateExerciseAction( action = CreateExerciseAction(
{ {
"create_exercise_input": { "definition_id": definition_id,
"definition_id": definition_id, "team_count": team_count,
"team_count": team_count,
}
}, },
{}, {},
) )
...@@ -126,7 +135,10 @@ def create_exercise(definition_id: int, team_count: int) -> PreparedExercise: ...@@ -126,7 +135,10 @@ def create_exercise(definition_id: int, team_count: int) -> PreparedExercise:
return PreparedExercise( return PreparedExercise(
definition_id, definition_id,
exercise_id, exercise_id,
get_teams(action.result["exercise"]["teams"]), get_teams(
int(action.result["exercise"]["id"]),
action.result["exercise"]["teams"],
),
email_addresses=[], email_addresses=[],
config=exercise_config, config=exercise_config,
) )
...@@ -289,9 +301,14 @@ if __name__ == "__main__": ...@@ -289,9 +301,14 @@ if __name__ == "__main__":
parser = init_argument_parser() parser = init_argument_parser()
parsed_arguments = parse_arguments(parser) parsed_arguments = parse_arguments(parser)
VERSION = "v1"
URL_PREFIX = f"inject/api/{VERSION}/"
BASE_URL = parsed_arguments.host BASE_URL = parsed_arguments.host
DEFINITION_UPLOAD_URL = f"{BASE_URL}/exercise_definition/upload-definition" DEFINITION_UPLOAD_URL = (
GRAPHQL_URL = f"{BASE_URL}/graphql/" f"{BASE_URL}/{URL_PREFIX}exercise_definition/upload-definition"
)
GRAPHQL_URL = f"{BASE_URL}/{URL_PREFIX}graphql/"
run_load_test( run_load_test(
parsed_arguments, parsed_arguments,
......
...@@ -10,6 +10,7 @@ class ToolData: ...@@ -10,6 +10,7 @@ class ToolData:
@dataclass @dataclass
class TeamData: class TeamData:
exercise_id: int
team_id: int team_id: int
team_address: str team_address: str
tools: List[ToolData] tools: List[ToolData]
...@@ -37,3 +37,4 @@ change: rename api prefix from `ttxbackend` to `inject` #183 ...@@ -37,3 +37,4 @@ change: rename api prefix from `ttxbackend` to `inject` #183
feat: add `validate_email_address` query for validation purposes #188 feat: add `validate_email_address` query for validation purposes #188
docs: update INSTALATION.md and move poetry description back into README.md docs: update INSTALATION.md and move poetry description back into README.md
feat: implement formatted welcome email and modify email sender, add DOMAIN env var #185 feat: implement formatted welcome email and modify email sender, add DOMAIN env var #185
fix: update performance testing tools to the newest API
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment