From cec8742771f5af58e79e12b449744b58b24a2498 Mon Sep 17 00:00:00 2001 From: Qingchuan Ma Date: Thu, 1 Sep 2022 12:17:54 -0700 Subject: [PATCH 1/5] Add skip for ApiKey and increase retry time for HttpApi --- integration/combination/test_api_with_authorizer_apikey.py | 4 ++-- integration/combination/test_api_with_authorizers.py | 4 ++-- integration/config/service_names.py | 1 + integration/conftest.py | 4 +++- integration/helpers/base_test.py | 4 ++-- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/integration/combination/test_api_with_authorizer_apikey.py b/integration/combination/test_api_with_authorizer_apikey.py index f7d58237b2..5f0190e2bd 100644 --- a/integration/combination/test_api_with_authorizer_apikey.py +++ b/integration/combination/test_api_with_authorizer_apikey.py @@ -6,10 +6,10 @@ from integration.helpers.resource import current_region_does_not_support -from integration.config.service_names import REST_API +from integration.config.service_names import REST_API, API_KEY -@skipIf(current_region_does_not_support([REST_API]), "RestApi is not supported in this testing region") +@skipIf(current_region_does_not_support([REST_API, API_KEY]), "RestApi/ApiKey is not supported in this testing region") class TestApiWithAuthorizerApiKey(BaseTest): def test_authorizer_apikey(self): self.create_and_verify_stack("combination/api_with_authorizer_apikey") diff --git a/integration/combination/test_api_with_authorizers.py b/integration/combination/test_api_with_authorizers.py index 3d0ce02dc1..c95a4573cb 100644 --- a/integration/combination/test_api_with_authorizers.py +++ b/integration/combination/test_api_with_authorizers.py @@ -4,10 +4,10 @@ from integration.helpers.deployer.utils.retry import retry from integration.helpers.exception import StatusCodeError from integration.helpers.resource import current_region_does_not_support -from integration.config.service_names import COGNITO +from integration.config.service_names import API_KEY, COGNITO -@skipIf(current_region_does_not_support([COGNITO]), "Cognito is not supported in this testing region") +@skipIf(current_region_does_not_support([COGNITO, API_KEY]), "Cognito is not supported in this testing region") class TestApiWithAuthorizers(BaseTest): def test_authorizers_min(self): self.create_and_verify_stack("combination/api_with_authorizers_min") diff --git a/integration/config/service_names.py b/integration/config/service_names.py index e3651aa47f..babbca0233 100644 --- a/integration/config/service_names.py +++ b/integration/config/service_names.py @@ -33,3 +33,4 @@ LAMBDA_ENV_VARS = "LambdaEnvVars" EVENT_INVOKE_CONFIG = "EventInvokeConfig" EPHEMERAL_STORAGE = "EphemeralStorage" +API_KEY = "ApiKey" \ No newline at end of file diff --git a/integration/conftest.py b/integration/conftest.py index fb6cca5ae6..98afb18033 100644 --- a/integration/conftest.py +++ b/integration/conftest.py @@ -216,7 +216,9 @@ def _stack_exists(stack_name): cloudformation = boto3.resource("cloudformation") stack = cloudformation.Stack(stack_name) try: - stack.stack_status + status = stack.stack_status + if status == "REVIEW_IN_PROGRESS": + return False except ClientError as ex: if "does not exist" in str(ex): return False diff --git a/integration/helpers/base_test.py b/integration/helpers/base_test.py index 2ba79e1ad2..8e734d6263 100644 --- a/integration/helpers/base_test.py +++ b/integration/helpers/base_test.py @@ -452,7 +452,7 @@ def verify_stack(self, end_state="CREATE_COMPLETE"): @retry( stop=stop_after_attempt(3), - wait=wait_exponential(multiplier=1, min=4, max=10) + wait_random(0, 1), + wait=wait_exponential(multiplier=1, min=20, max=30) + wait_random(0, 1), retry=retry_if_exception_type(StatusCodeError), after=after_log(LOG, logging.WARNING), reraise=True, @@ -481,7 +481,7 @@ def verify_get_request_response(self, url, expected_status_code, headers=None): @retry( stop=stop_after_attempt(3), - wait=wait_exponential(multiplier=1, min=4, max=10) + wait_random(0, 1), + wait=wait_exponential(multiplier=1, min=20, max=30) + wait_random(0, 1), retry=retry_if_exception_type(StatusCodeError), after=after_log(LOG, logging.WARNING), reraise=True, From d2fa65af4e3190dfd57c1f0f6cb53c5068498ce5 Mon Sep 17 00:00:00 2001 From: Qingchuan Ma Date: Thu, 1 Sep 2022 12:22:23 -0700 Subject: [PATCH 2/5] Black reformatting --- integration/config/service_names.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/config/service_names.py b/integration/config/service_names.py index babbca0233..f26da09308 100644 --- a/integration/config/service_names.py +++ b/integration/config/service_names.py @@ -33,4 +33,4 @@ LAMBDA_ENV_VARS = "LambdaEnvVars" EVENT_INVOKE_CONFIG = "EventInvokeConfig" EPHEMERAL_STORAGE = "EphemeralStorage" -API_KEY = "ApiKey" \ No newline at end of file +API_KEY = "ApiKey" From f88c3b152f91f5493f617401842f07db3e513fac Mon Sep 17 00:00:00 2001 From: Qingchuan Ma Date: Thu, 1 Sep 2022 12:25:44 -0700 Subject: [PATCH 3/5] Add additional skips --- integration/combination/test_api_with_authorizers.py | 4 ++-- integration/combination/test_api_with_gateway_responses.py | 4 ++-- integration/combination/test_api_with_usage_plan.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/integration/combination/test_api_with_authorizers.py b/integration/combination/test_api_with_authorizers.py index c95a4573cb..aa5285e2b2 100644 --- a/integration/combination/test_api_with_authorizers.py +++ b/integration/combination/test_api_with_authorizers.py @@ -4,10 +4,10 @@ from integration.helpers.deployer.utils.retry import retry from integration.helpers.exception import StatusCodeError from integration.helpers.resource import current_region_does_not_support -from integration.config.service_names import API_KEY, COGNITO +from integration.config.service_names import API_KEY, COGNITO, REST_API -@skipIf(current_region_does_not_support([COGNITO, API_KEY]), "Cognito is not supported in this testing region") +@skipIf(current_region_does_not_support([COGNITO, API_KEY, REST_API]), "Cognito is not supported in this testing region") class TestApiWithAuthorizers(BaseTest): def test_authorizers_min(self): self.create_and_verify_stack("combination/api_with_authorizers_min") diff --git a/integration/combination/test_api_with_gateway_responses.py b/integration/combination/test_api_with_gateway_responses.py index 39979e016d..f0fd0e1ff4 100644 --- a/integration/combination/test_api_with_gateway_responses.py +++ b/integration/combination/test_api_with_gateway_responses.py @@ -5,13 +5,13 @@ from integration.helpers.base_test import BaseTest from integration.helpers.resource import current_region_does_not_support -from integration.config.service_names import GATEWAY_RESPONSES +from integration.config.service_names import GATEWAY_RESPONSES, REST_API LOG = logging.getLogger(__name__) @skipIf( - current_region_does_not_support([GATEWAY_RESPONSES]), "GatewayResponses is not supported in this testing region" + current_region_does_not_support([GATEWAY_RESPONSES, REST_API]), "GatewayResponses is not supported in this testing region" ) class TestApiWithGatewayResponses(BaseTest): def test_gateway_responses(self): diff --git a/integration/combination/test_api_with_usage_plan.py b/integration/combination/test_api_with_usage_plan.py index b252338a98..50b699482c 100644 --- a/integration/combination/test_api_with_usage_plan.py +++ b/integration/combination/test_api_with_usage_plan.py @@ -2,10 +2,10 @@ from integration.helpers.base_test import BaseTest from integration.helpers.resource import current_region_does_not_support -from integration.config.service_names import USAGE_PLANS +from integration.config.service_names import USAGE_PLANS, REST_API -@skipIf(current_region_does_not_support([USAGE_PLANS]), "UsagePlans is not supported in this testing region") +@skipIf(current_region_does_not_support([USAGE_PLANS, REST_API]), "UsagePlans is not supported in this testing region") class TestApiWithUsagePlan(BaseTest): def test_api_with_usage_plans(self): self.create_and_verify_stack("combination/api_with_usage_plan") From 8c8e125c431d9e73c637d3be501cec1aada12281 Mon Sep 17 00:00:00 2001 From: Qingchuan Ma Date: Thu, 1 Sep 2022 12:26:07 -0700 Subject: [PATCH 4/5] Black reformatting --- integration/combination/test_api_with_authorizers.py | 4 +++- integration/combination/test_api_with_gateway_responses.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/integration/combination/test_api_with_authorizers.py b/integration/combination/test_api_with_authorizers.py index aa5285e2b2..a34ef62589 100644 --- a/integration/combination/test_api_with_authorizers.py +++ b/integration/combination/test_api_with_authorizers.py @@ -7,7 +7,9 @@ from integration.config.service_names import API_KEY, COGNITO, REST_API -@skipIf(current_region_does_not_support([COGNITO, API_KEY, REST_API]), "Cognito is not supported in this testing region") +@skipIf( + current_region_does_not_support([COGNITO, API_KEY, REST_API]), "Cognito is not supported in this testing region" +) class TestApiWithAuthorizers(BaseTest): def test_authorizers_min(self): self.create_and_verify_stack("combination/api_with_authorizers_min") diff --git a/integration/combination/test_api_with_gateway_responses.py b/integration/combination/test_api_with_gateway_responses.py index f0fd0e1ff4..2554cbb340 100644 --- a/integration/combination/test_api_with_gateway_responses.py +++ b/integration/combination/test_api_with_gateway_responses.py @@ -11,7 +11,8 @@ @skipIf( - current_region_does_not_support([GATEWAY_RESPONSES, REST_API]), "GatewayResponses is not supported in this testing region" + current_region_does_not_support([GATEWAY_RESPONSES, REST_API]), + "GatewayResponses is not supported in this testing region", ) class TestApiWithGatewayResponses(BaseTest): def test_gateway_responses(self): From 68087a5c0c9fa1c33054d1f35bf2dad0851a2d38 Mon Sep 17 00:00:00 2001 From: Qingchuan Ma Date: Thu, 1 Sep 2022 13:16:06 -0700 Subject: [PATCH 5/5] Increase retry --- integration/helpers/base_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/integration/helpers/base_test.py b/integration/helpers/base_test.py index 8e734d6263..b462639482 100644 --- a/integration/helpers/base_test.py +++ b/integration/helpers/base_test.py @@ -451,8 +451,8 @@ def verify_stack(self, end_state="CREATE_COMPLETE"): self.fail(error) @retry( - stop=stop_after_attempt(3), - wait=wait_exponential(multiplier=1, min=20, max=30) + wait_random(0, 1), + stop=stop_after_attempt(6), + wait=wait_exponential(multiplier=1, min=16, max=64) + wait_random(0, 1), retry=retry_if_exception_type(StatusCodeError), after=after_log(LOG, logging.WARNING), reraise=True, @@ -480,8 +480,8 @@ def verify_get_request_response(self, url, expected_status_code, headers=None): return response @retry( - stop=stop_after_attempt(3), - wait=wait_exponential(multiplier=1, min=20, max=30) + wait_random(0, 1), + stop=stop_after_attempt(6), + wait=wait_exponential(multiplier=1, min=16, max=64) + wait_random(0, 1), retry=retry_if_exception_type(StatusCodeError), after=after_log(LOG, logging.WARNING), reraise=True,