#NEWLINE# def test_operation_retry( self ) : #NEWLINE# #INDENT# self . configure ( retries = 5 , retry_interval = 5 ) #NEWLINE# deployment_id = str ( uuid . uuid4 ( ) ) #NEWLINE# deploy ( resource ( 'dsl/test-operation-retry-blueprint.yaml' ) , deployment_id = deployment_id ) #NEWLINE# invocations = self . get_plugin_data ( plugin_name = 'testmockoperations' , deployment_id = deployment_id ) [ 'retry_invocations' ] #NEWLINE# self . assertEqual ( 4 , invocations ) #NEWLINE# with open ( self . test_logs_file , 'r' ) as f : #NEWLINE# #INDENT# events_and_logs = f . read ( ) #NEWLINE# self . assertIn ( 'Task rescheduled' , assertion ) #NEWLINE# self . assertIn ( 'Retrying operation' , events_and_logs ) #NEWLINE# #UNINDENT# def assertion( ) : #NEWLINE# #INDENT# events = [ e for e in self . events if ( e . get ( 'event_type' , '' ) . startswith ( 'task_' ) or ( e . get ( 'event_type' , '' ) == 'sending_task' ) ) ] #NEWLINE# self . assertGreater ( len ( events ) , 0 ) #NEWLINE# seen_current_retries = set ( ) #NEWLINE# for event in events : #NEWLINE# #INDENT# current_retries = event [ 'context' ] [ 'task_current_retries' ] #NEWLINE# seen_current_retries . add ( current_retries ) #NEWLINE# total_retries = event [ 'context' ] [ 'task_total_retries' ] #NEWLINE# self . assertEqual ( total_retries , 5 ) #NEWLINE# #UNINDENT# self . assertSetEqual ( seen_current_retries , { 0 , 1 , 2 , 3 } ) #NEWLINE# #UNINDENT# self . do_assertions ( assertion )