Skip to content

Commit

Permalink
Metadata endpoint load tests (#737)
Browse files Browse the repository at this point in the history
* Initial commit

* WIP: No longer getting missing required header error

- now getting a different error about multiple values being returned
- still cannot find metadata file once written

* Fixed indentation

* header map with lowercase keys

* Added test for header casing conversion to lowercase

* Updated all calls to get headers to use lowercase name

* Reverted all changes related to new PR 739

* Added flag to make sure the metadata endpoint is called only after the order endpoint has been called

* Changed to generate submission_id per user and reduce the task weight for metadata endpoint calls

* Moved orders_api_called flag instantiation

---------

Co-authored-by: tjohnson7021 <[email protected]>
Co-authored-by: jorge Lopez <[email protected]>
Co-authored-by: halprin <[email protected]>
Co-authored-by: Jorge Lopez <[email protected]>
  • Loading branch information
5 people authored Dec 27, 2023
1 parent c94f2d0 commit 58c4692
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions operations/locustfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time
import uuid
import logging
import threading
import urllib.parse
Expand All @@ -11,6 +12,7 @@
AUTH_ENDPOINT = "/v1/auth/token"
DEMOGRAPHICS_ENDPOINT = "/v1/etor/demographics"
ORDERS_ENDPOINT = "/v1/etor/orders"
METADATA_ENDPOINT = "/v1/etor/metadata"

demographics_request_body = None
order_request_body = None
Expand All @@ -28,6 +30,9 @@ class SampleUser(FastHttpUser):
def on_start(self):
self.authenticate()

self.submission_id = str(uuid.uuid4())
self.orders_api_called = False

# Start the token refreshing thread
threading.Thread(
target=self.authenticate_periodically, args=(), daemon=True
Expand Down Expand Up @@ -58,11 +63,24 @@ def post_v1_etor_demographics(self):

@task(5)
def post_v1_etor_orders(self):
self.client.post(
response = self.client.post(
ORDERS_ENDPOINT,
headers={
"Authorization": self.access_token,
"RecordId": self.submission_id,
},
data=order_request_body,
headers={"Authorization": self.access_token},
)
if response.status_code == 200:
self.orders_api_called = True

@task(2)
def get_v1_etor_metadata(self):
if self.orders_api_called:
self.client.get(
f"{METADATA_ENDPOINT}/{self.submission_id}",
headers={"Authorization": self.access_token},
)


@events.test_start.add_listener
Expand Down

0 comments on commit 58c4692

Please sign in to comment.