Skip to content

Commit 5892219

Browse files
authored
fix:skip tests if eventrule to eventbus feature aren't available in specific regions (#3673)
1 parent 03a37fe commit 5892219

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

integration/combination/test_connectors.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ def tearDown(self):
8080
("combination/connector_event_rule_to_sqs_write",),
8181
("combination/connector_event_rule_to_sns_write",),
8282
("combination/connector_event_rule_to_sfn_write",),
83-
("combination/connector_event_rule_to_eb_default_write",),
84-
("combination/connector_event_rule_to_eb_custom_write",),
8583
("combination/connector_event_rule_to_lambda_write",),
8684
("combination/connector_event_rule_to_lambda_write_multiple",),
8785
("combination/connector_sqs_to_function",),
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from unittest import SkipTest
2+
from unittest.case import skipIf
3+
4+
from parameterized import parameterized
5+
from tenacity import retry, retry_if_exception, stop_after_attempt
6+
7+
from integration.config.service_names import EVENT_RULE_WITH_EVENT_BUS
8+
from integration.conftest import clean_bucket
9+
from integration.helpers.base_test import BaseTest
10+
from integration.helpers.resource import current_region_does_not_support
11+
12+
retry_once = retry(
13+
stop=stop_after_attempt(2),
14+
# unittest raises SkipTest for skipping tests
15+
retry=retry_if_exception(lambda e: not isinstance(e, SkipTest)),
16+
)
17+
18+
19+
@skipIf(
20+
current_region_does_not_support([EVENT_RULE_WITH_EVENT_BUS]),
21+
"EVENT_RULE_WITH_EVENT_BUS is not supported in this testing region",
22+
)
23+
class TestConnectorsWithEventRuleToEB(BaseTest):
24+
def tearDown(self):
25+
# Some tests will create items in S3 Bucket, which result in stack DELETE_FAILED state
26+
# manually empty the bucket to allow stacks to be deleted successfully.
27+
bucket_name = self.get_physical_id_by_type("AWS::S3::Bucket")
28+
if bucket_name:
29+
clean_bucket(bucket_name, self.client_provider.s3_client)
30+
super().tearDown()
31+
32+
@parameterized.expand(
33+
[
34+
("combination/connector_event_rule_to_eb_default_write",),
35+
("combination/connector_event_rule_to_eb_custom_write",),
36+
]
37+
)
38+
@retry_once
39+
def test_connector_event_rule_eb_by_invoking_a_function(self, template_file_path):
40+
self.skip_using_service_detector(template_file_path)
41+
self.create_and_verify_stack(template_file_path)
42+
43+
lambda_function_name = self.get_physical_id_by_logical_id("TriggerFunction")
44+
lambda_client = self.client_provider.lambda_client
45+
46+
request_params = {
47+
"FunctionName": lambda_function_name,
48+
"InvocationType": "RequestResponse",
49+
"Payload": "{}",
50+
}
51+
response = lambda_client.invoke(**request_params)
52+
self.assertEqual(response.get("StatusCode"), 200)
53+
self.assertEqual(response.get("FunctionError"), None)

integration/config/service_names.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@
3636
APP_SYNC = "AppSync"
3737
SNS_FILTER_POLICY_SCOPE = "SnsFilterPolicyScope"
3838
LOGS = "Logs"
39+
EVENT_RULE_WITH_EVENT_BUS = "EventRuleWithEventBus"

0 commit comments

Comments
 (0)