Skip to content

Commit

Permalink
Fix Deletion and Question Data
Browse files Browse the repository at this point in the history
  • Loading branch information
shiva-menta committed Jan 24, 2024
1 parent 38a3ba6 commit d537a6e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions backend/clubs/management/commands/stress_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class Command(BaseCommand):
"""

def setUp(self):
self.num_clubs = 500
self.num_users = 2000
self.subset_size = 5
self.num_questions_per_club = 5
self.total_submissions = 3
self.num_clubs = 5
self.num_users = 10
self.subset_size = 1
self.num_questions_per_club = 2
self.total_submissions = 1
self.prefix = "test_club_"

self.uri = "/users/question_response/"
Expand Down Expand Up @@ -81,7 +81,7 @@ def submit_application(self, user, club_id):
"questionIds": self.club_question_ids[club_id],
}
for question_id in self.club_question_ids[club_id]:
data[question_id] = {"test": "This is a test answer."}
data[question_id] = {"text": "This is a test answer."}

request = self.factory.post(self.uri, data, format="json")
request.user = user
Expand All @@ -91,9 +91,7 @@ def submit_application(self, user, club_id):
return end_time - start_time

def tearDown(self):
test_clubs = Club.objects.filter(code__startswith=self.prefix)
for club in test_clubs:
club.delete()
Club.objects.filter(code__startswith=self.prefix).delete()
for user in self.users:
user.delete()

Expand Down Expand Up @@ -126,6 +124,7 @@ async def handleAsync(self, *args, **kwargs):
)
tasks.append(task)
all_tasks = await asyncio.gather(*tasks, return_exceptions=True)
print(all_tasks)
end_time = time.time()

print(f"Throughput was: {sum(all_tasks) / len(all_tasks)} seconds per txn.")
Expand All @@ -135,8 +134,8 @@ def handle(self, *args, **kwargs):
self.setUp()
try:
asyncio.run(self.handleAsync(args, kwargs))
self.tearDown()
# self.tearDown()
except Exception as e:
print(e)
logging.exception("Something happened!")
self.tearDown()
# self.tearDown()

0 comments on commit d537a6e

Please sign in to comment.