11from  time  import  sleep 
2+ from  unittest  import  SkipTest 
23from  parameterized  import  parameterized 
4+ from  tenacity  import  retry , stop_after_attempt , retry_if_exception 
35from  integration .conftest  import  clean_bucket 
46from  integration .helpers .base_test  import  S3_BUCKET_PREFIX , BaseTest 
57from  integration .helpers .resource  import  generate_suffix 
68
9+ retry_once  =  retry (
10+     stop = stop_after_attempt (2 ),
11+     # unittest raises SkipTest for skipping tests 
12+     retry = retry_if_exception (lambda  e : not  isinstance (e , SkipTest )),
13+ )
14+ 
715
816class  TestConnectors (BaseTest ):
917    def  tearDown (self ):
@@ -41,6 +49,7 @@ def tearDown(self):
4149            ("combination/connector_table_to_function_read" ,), 
4250        ] 
4351    ) 
52+     @retry_once  
4453    def  test_connector_by_invoking_a_function (self , template_file_path ):
4554        self .skip_using_service_detector (template_file_path )
4655        self .create_and_verify_stack (template_file_path )
@@ -72,6 +81,7 @@ def test_connector_by_invoking_a_function(self, template_file_path):
7281            ("combination/connector_sfn_to_eb_custom_write" ,), 
7382        ] 
7483    ) 
84+     @retry_once  
7585    def  test_connector_by_sync_execute_an_state_machine (self , template_file_path ):
7686        self .skip_using_service_detector (template_file_path )
7787        self .create_and_verify_stack (template_file_path )
@@ -91,6 +101,7 @@ def test_connector_by_sync_execute_an_state_machine(self, template_file_path):
91101            ("combination/connector_sfn_to_sfn_sync" ,), 
92102        ] 
93103    ) 
104+     @retry_once  
94105    def  test_connector_by_async_execute_an_state_machine (self , template_file_path ):
95106        self .skip_using_service_detector (template_file_path )
96107        self .create_and_verify_stack (template_file_path )
@@ -123,6 +134,7 @@ def test_connector_by_async_execute_an_state_machine(self, template_file_path):
123134            ("combination/connector_bucket_to_function_write" ,), 
124135        ] 
125136    ) 
137+     @retry_once  
126138    def  test_connector_by_execute_a_s3_bucket (self , template_file_path ):
127139        self .skip_using_service_detector (template_file_path )
128140        bucket_name  =  S3_BUCKET_PREFIX  +  "connector"  +  generate_suffix ()
0 commit comments