Skip to content

Commit f63fc62

Browse files
authored
chore: Integration test improvements with ApiKey skips and retry time (#2487)
* Add skip for ApiKey and increase retry time for HttpApi * Black reformatting * Add additional skips * Black reformatting * Increase retry
1 parent 38d535c commit f63fc62

File tree

7 files changed

+19
-13
lines changed

7 files changed

+19
-13
lines changed

integration/combination/test_api_with_authorizer_apikey.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77

88
from integration.helpers.resource import current_region_does_not_support
9-
from integration.config.service_names import REST_API
9+
from integration.config.service_names import REST_API, API_KEY
1010

1111

12-
@skipIf(current_region_does_not_support([REST_API]), "RestApi is not supported in this testing region")
12+
@skipIf(current_region_does_not_support([REST_API, API_KEY]), "RestApi/ApiKey is not supported in this testing region")
1313
class TestApiWithAuthorizerApiKey(BaseTest):
1414
def test_authorizer_apikey(self):
1515
self.create_and_verify_stack("combination/api_with_authorizer_apikey")

integration/combination/test_api_with_authorizers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
from integration.helpers.deployer.utils.retry import retry
55
from integration.helpers.exception import StatusCodeError
66
from integration.helpers.resource import current_region_does_not_support
7-
from integration.config.service_names import COGNITO
7+
from integration.config.service_names import API_KEY, COGNITO, REST_API
88

99

10-
@skipIf(current_region_does_not_support([COGNITO]), "Cognito is not supported in this testing region")
10+
@skipIf(
11+
current_region_does_not_support([COGNITO, API_KEY, REST_API]), "Cognito is not supported in this testing region"
12+
)
1113
class TestApiWithAuthorizers(BaseTest):
1214
def test_authorizers_min(self):
1315
self.create_and_verify_stack("combination/api_with_authorizers_min")

integration/combination/test_api_with_gateway_responses.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55

66
from integration.helpers.base_test import BaseTest
77
from integration.helpers.resource import current_region_does_not_support
8-
from integration.config.service_names import GATEWAY_RESPONSES
8+
from integration.config.service_names import GATEWAY_RESPONSES, REST_API
99

1010
LOG = logging.getLogger(__name__)
1111

1212

1313
@skipIf(
14-
current_region_does_not_support([GATEWAY_RESPONSES]), "GatewayResponses is not supported in this testing region"
14+
current_region_does_not_support([GATEWAY_RESPONSES, REST_API]),
15+
"GatewayResponses is not supported in this testing region",
1516
)
1617
class TestApiWithGatewayResponses(BaseTest):
1718
def test_gateway_responses(self):

integration/combination/test_api_with_usage_plan.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
from integration.helpers.base_test import BaseTest
44
from integration.helpers.resource import current_region_does_not_support
5-
from integration.config.service_names import USAGE_PLANS
5+
from integration.config.service_names import USAGE_PLANS, REST_API
66

77

8-
@skipIf(current_region_does_not_support([USAGE_PLANS]), "UsagePlans is not supported in this testing region")
8+
@skipIf(current_region_does_not_support([USAGE_PLANS, REST_API]), "UsagePlans is not supported in this testing region")
99
class TestApiWithUsagePlan(BaseTest):
1010
def test_api_with_usage_plans(self):
1111
self.create_and_verify_stack("combination/api_with_usage_plan")

integration/config/service_names.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@
3333
LAMBDA_ENV_VARS = "LambdaEnvVars"
3434
EVENT_INVOKE_CONFIG = "EventInvokeConfig"
3535
EPHEMERAL_STORAGE = "EphemeralStorage"
36+
API_KEY = "ApiKey"

integration/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ def _stack_exists(stack_name):
216216
cloudformation = boto3.resource("cloudformation")
217217
stack = cloudformation.Stack(stack_name)
218218
try:
219-
stack.stack_status
219+
status = stack.stack_status
220+
if status == "REVIEW_IN_PROGRESS":
221+
return False
220222
except ClientError as ex:
221223
if "does not exist" in str(ex):
222224
return False

integration/helpers/base_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,8 @@ def verify_stack(self, end_state="CREATE_COMPLETE"):
451451
self.fail(error)
452452

453453
@retry(
454-
stop=stop_after_attempt(3),
455-
wait=wait_exponential(multiplier=1, min=4, max=10) + wait_random(0, 1),
454+
stop=stop_after_attempt(6),
455+
wait=wait_exponential(multiplier=1, min=16, max=64) + wait_random(0, 1),
456456
retry=retry_if_exception_type(StatusCodeError),
457457
after=after_log(LOG, logging.WARNING),
458458
reraise=True,
@@ -480,8 +480,8 @@ def verify_get_request_response(self, url, expected_status_code, headers=None):
480480
return response
481481

482482
@retry(
483-
stop=stop_after_attempt(3),
484-
wait=wait_exponential(multiplier=1, min=4, max=10) + wait_random(0, 1),
483+
stop=stop_after_attempt(6),
484+
wait=wait_exponential(multiplier=1, min=16, max=64) + wait_random(0, 1),
485485
retry=retry_if_exception_type(StatusCodeError),
486486
after=after_log(LOG, logging.WARNING),
487487
reraise=True,

0 commit comments

Comments
 (0)