Skip to content

Commit 16da6e7

Browse files
authored
fix: add retry for statemachine integ test (#3630)
1 parent 7a0558f commit 16da6e7

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

integration/helpers/base_test.py

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

570+
@retry(
571+
stop=stop_after_attempt(5),
572+
wait=wait_exponential(multiplier=1, min=16, max=64) + wait_random(0, 1),
573+
retry=retry_if_exception_type(StatusCodeError),
574+
after=after_log(LOG, logging.WARNING),
575+
reraise=True,
576+
)
570577
def verify_post_request(self, url: str, body_obj, expected_status_code: int, headers=None):
571578
"""Return response to POST request and verify matches expected status code."""
572579
response = self.do_post_request_with_logging(url, body_obj, headers)

integration/single/test_basic_api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import logging
3+
import time
34
from unittest.case import skipIf
45

56
from tenacity import after_log, retry_if_exception_type, stop_after_attempt, wait_exponential, wait_random
@@ -129,8 +130,14 @@ def test_state_machine_with_api_single_quotes_input(self):
129130
api_endpoint = stack_output.get("ApiEndpoint")
130131

131132
input_json = {"f'oo": {"hello": "'wor'l'd'''"}}
133+
134+
# This will be the wait time before triggering the APIGW request
135+
time.sleep(10)
136+
132137
response = self.verify_post_request(api_endpoint, input_json, 200)
133138

139+
LOG.log(msg=f"retry times {self.verify_get_request_response.retry.statistics}", level=logging.WARNING)
140+
134141
execution_arn = response.json()["executionArn"]
135142
execution = self.client_provider.sfn_client.describe_execution(executionArn=execution_arn)
136143
execution_input = json.loads(execution["input"])

0 commit comments

Comments
 (0)