Skip to content

Commit c64c882

Browse files
authored
fix: change endpoint configuration for state machine integ test (#3614)
1 parent 2064306 commit c64c882

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

integration/helpers/base_test.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,9 @@ def verify_options_request(self, url, expected_status_code, headers=None):
567567
)
568568
return response
569569

570-
def verify_post_request(self, url: str, body_obj, expected_status_code: int):
570+
def verify_post_request(self, url: str, body_obj, expected_status_code: int, headers=None):
571571
"""Return response to POST request and verify matches expected status code."""
572-
response = self.do_post_request(url, body_obj)
572+
response = self.do_post_request_with_logging(url, body_obj, headers)
573573
if response.status_code != expected_status_code:
574574
raise StatusCodeError(
575575
f"Request to {url} failed with status: {response.status_code}, expected status: {expected_status_code}"
@@ -650,12 +650,17 @@ def do_options_request_with_logging(self, url, headers=None):
650650
)
651651
return response
652652

653-
def do_post_request(self, url: str, body_obj):
653+
def do_post_request_with_logging(self, url: str, body_obj, requestHeaders=None):
654654
"""Perform a POST request with dict body body_obj."""
655-
response = requests.post(url, json=body_obj)
655+
response = (
656+
requests.post(url, json=body_obj, headers=requestHeaders)
657+
if requestHeaders
658+
else requests.post(url, json=body_obj)
659+
)
660+
amazon_headers = RequestUtils(response).get_amazon_headers()
656661
if self.internal:
657662
REQUEST_LOGGER.info(
658663
"POST request made to " + url,
659-
extra={"test": self.testcase, "status": response.status_code},
664+
extra={"test": self.testcase, "status": response.status_code, "headers": amazon_headers},
660665
)
661666
return response

integration/resources/templates/single/state_machine_with_api.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Resources:
44
Type: AWS::Serverless::Api
55
Properties:
66
StageName: Prod
7+
EndpointConfiguration:
8+
Type: REGIONAL
79
HelloWorldFunction:
810
Type: AWS::Serverless::Function
911
Properties:

integration/single/test_basic_api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ def test_state_machine_with_api_single_quotes_input(self):
118118
"""
119119
Pass single quotes in input JSON to a StateMachine
120120
See https://github.com/aws/serverless-application-model/issues/1895
121+
122+
This test is known to sometimes be flaky, but we want to avoid marking it as non-blocking as this is a basic api test.
123+
Instead, we set the EndpointConfiguration to REGIONAL and added logging to the api request
124+
If this test continues to fail it should be marked as non-blocking
121125
"""
122126
self.create_and_verify_stack("single/state_machine_with_api")
123127

0 commit comments

Comments
 (0)