Skip to content

Commit

Permalink
Story 676/load tests (#822)
Browse files Browse the repository at this point in the history
* WIP Adding consolidated endpoint

* Update the consolidated metadata API to return whether the data is stale or not

* Adding unit tests

* Renaming endpoint

* Remove TODO, we have decided to retrieve all of the metadata when getting by sender

* Removed 💩 emoji stale status for consolidated metadata endpoint

* Update unit test for orchestrating the collection of our consolidated metadata

* added readMetadata for sender throough metadata_directory

* Adding test for FilePartnerMetadataStorage

* Fixing merge issue

* Updated load tests

* Fixing Load test having old file names

* Fixing typo and issue with Result Test

---------

Co-authored-by: halprin <[email protected]>
  • Loading branch information
jcrichlake and halprin authored Jan 30, 2024
1 parent 4797532 commit 9720bee
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ConsolidatedSummaryTest extends Specification {
jsonBody.get((jsonBody.keySet().toArray())[0]).status != null
}

def "consolidated endpoint failes when called while not authenticated"() {
def "consolidated endpoint fails when called while not authenticated"() {
when:
def consolidatedResponse = ConsolidatedSummaryClient.get("test", false)
def parsedJsonBody = JsonParsing.parseContent(consolidatedResponse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ class EtorDomainRegistrationTest extends Specification {
1 * mockResponseHelper.constructOkResponse(expectedResultMap) >> new DomainResponse(expectedStatusCode)
}


def "Consolidated metadata endpoint fails with a 500"() {
given:
def expectedStatusCode = 500
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ class PostgresDaoTest extends Specification {
TestApplicationContext.register(SqlDriverManager, mockDriver)
TestApplicationContext.injectRegisteredImplementations()


when:
def actual = PostgresDao.getInstance().fetchMetadataForSender("sender")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class FilePartnerMetadataStorageTest extends Specification {
def sender = "same_sender"
PartnerMetadata metadata2 = new PartnerMetadata("abcdefghi", null, sender, null, null, null, null, null)
PartnerMetadata metadata1 = new PartnerMetadata("123456789", null, sender, null, null, null, null, null)

TestApplicationContext.register(Formatter, Jackson.getInstance())
TestApplicationContext.injectRegisteredImplementations()

Expand Down
16 changes: 13 additions & 3 deletions operations/locustfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
DEMOGRAPHICS_ENDPOINT = "/v1/etor/demographics"
ORDERS_ENDPOINT = "/v1/etor/orders"
METADATA_ENDPOINT = "/v1/etor/metadata"
CONSOLIDATED_ENDPOINT = "/v1/etor/metadata/summary"

demographics_request_body = None
order_request_body = None
Expand All @@ -32,6 +33,7 @@ def on_start(self):

self.submission_id = str(uuid.uuid4())
self.orders_api_called = False
self.sender = "flexion.simulated-hospital"

# Start the token refreshing thread
threading.Thread(
Expand Down Expand Up @@ -74,14 +76,22 @@ def post_v1_etor_orders(self):
if response.status_code == 200:
self.orders_api_called = True

@task(2)
@task(1)
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},
)

# @task(1)
# def get_v1_metadata_consolidated(self):
# if self.orders_api_called:
# self.client.get(
# f"{CONSOLIDATED_ENDPOINT}/{self.sender}",
# headers={"Authorization": self.access_token},
# )


@events.test_start.add_listener
def test_start(environment):
Expand Down Expand Up @@ -124,11 +134,11 @@ def get_auth_request_body():

def get_demographics_request_body():
# read the sample request body for the demographics endpoint
with open("examples/fhir/newborn_patient.json", "r") as f:
with open("examples/Other/003_Patient_NBS.fhir", "r") as f:
return f.read()


def get_orders_request_body():
# read the sample request body for the orders endpoint
with open("examples/fhir/lab_order.json", "r") as f:
with open("examples/Other/002_Order.fhir", "r") as f:
return f.read()

0 comments on commit 9720bee

Please sign in to comment.