Skip to content

Commit 711a914

Browse files
authored
Move delete to teardown (#245)
* Empty bucket in tear down * Empty bucket in tear down Co-authored-by: Gavin Zhang <[email protected]>
1 parent deccf63 commit 711a914

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

integration/combination/test_connectors.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66

77

88
class TestConnectors(BaseTest):
9+
def tearDown(self):
10+
# Some tests will create items in S3 Bucket, which result in stack DELETE_FAILED state
11+
# manually empty the bucket to allow stacks to be deleted successfully.
12+
bucket_name = self.get_physical_id_by_type("AWS::S3::Bucket")
13+
if bucket_name:
14+
clean_bucket(bucket_name, self.client_provider.s3_client)
15+
super().tearDown()
16+
917
@parameterized.expand(
1018
[
1119
("combination/connector_function_to_function",),
@@ -50,12 +58,6 @@ def test_connector_by_invoking_a_function(self, template_file_path):
5058
self.assertEqual(response.get("StatusCode"), 200)
5159
self.assertEqual(response.get("FunctionError"), None)
5260

53-
# Some tests will create items in S3 Bucket, which result in stack DELETE_FAILED state
54-
# manually empty the bucket to allow stacks to be deleted successfully.
55-
bucket_name = self.get_physical_id_by_type("AWS::S3::Bucket")
56-
if bucket_name:
57-
clean_bucket(bucket_name, s3_client)
58-
5961
@parameterized.expand(
6062
[
6163
("combination/connector_sfn_to_table_read",),
@@ -84,12 +86,6 @@ def test_connector_by_sync_execute_an_state_machine(self, template_file_path):
8486
# Without permission, it will be "FAILED"
8587
self.assertEqual(response.get("status"), "SUCCEEDED")
8688

87-
# Some tests will create items in S3 Bucket, which result in stack DELETE_FAILED state
88-
# manually empty the bucket to allow stacks to be deleted successfully.
89-
bucket_name = self.get_physical_id_by_type("AWS::S3::Bucket")
90-
if bucket_name:
91-
clean_bucket(bucket_name, s3_client)
92-
9389
@parameterized.expand(
9490
[
9591
("combination/connector_sfn_to_sfn_sync",),
@@ -146,8 +142,3 @@ def test_connector_by_execute_a_s3_bucket(self, template_file_path):
146142
response = lambda_client.invoke(**request_params)
147143
self.assertEqual(response.get("StatusCode"), 200)
148144
self.assertEqual(response.get("FunctionError"), None)
149-
150-
# Some tests will create items in S3 Bucket, which result in stack DELETE_FAILED state
151-
# manually empty the bucket to allow stacks to be deleted successfully.
152-
bucket_name = self.get_physical_id_by_type("AWS::S3::Bucket")
153-
clean_bucket(bucket_name, s3_client)

0 commit comments

Comments
 (0)