#NEWLINE# def test_sync_remote_with_timings( self ) : #NEWLINE# #INDENT# ts_iter = make_timestamp_iter ( ) #NEWLINE# broker = self . _get_broker ( 'a' , 'c' , node_index = 0 ) #NEWLINE# put_timestamp = next ( ts_iter ) #NEWLINE# broker . initialize ( put_timestamp . internal , POLICIES . default . idx ) #NEWLINE# broker . update_metadata ( { #NEWLINE# #INDENT# 'x-container-meta-test' : ( 'foo' , put_timestamp . internal ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# remote_broker = self . _get_broker ( 'a' , 'c' , node_index = 1 ) #NEWLINE# remote_broker . initialize ( next ( ts_iter ) . internal , POLICIES . default . idx ) #NEWLINE# timestamp = next ( ts_iter ) #NEWLINE# for db in ( broker , remote_broker ) : #NEWLINE# #INDENT# db . put_object ( '/a/c/o' , timestamp . internal , 0 , 'content-type' , 'etag' , storage_policy_index = db . storage_policy_index ) #NEWLINE# #UNINDENT# daemon = replicator . ContainerReplicator ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# ( part , node ) = self . _get_broker_part_node ( remote_broker ) #NEWLINE# info = broker . get_replication_info ( ) #NEWLINE# with mock . patch . object ( db_replicator , 'DEBUG_TIMINGS_THRESHOLD' , ( - 1 ) ) : #NEWLINE# #INDENT# success = daemon . _repl_to_node ( node , broker , part , info ) #NEWLINE# #UNINDENT# self . assertTrue ( success ) #NEWLINE# self . assertEqual ( 1 , daemon . stats [ 'no_change' ] ) #NEWLINE# expected_timings = ( 'info' , 'update_metadata' , 'merge_timestamps' , 'get_sync' , 'merge_syncs' ) #NEWLINE# debug_lines = self . rpc . logger . logger . get_lines_for_level ( 'debug' ) #NEWLINE# self . assertEqual ( len ( expected_timings ) , len ( debug_lines ) , ( 'Expected %s debug lines but only got %s: %s' % ( len ( expected_timings ) , len ( db ) , debug_lines ) ) ) #NEWLINE# for metric in expected_timings : #NEWLINE# #INDENT# expected = ( 'replicator-rpc-sync time for %s:' % metric ) #NEWLINE# self . assertTrue ( any ( ( ( expected in line ) for line in debug_lines ) ) , ( 'debug timing %r was not in %r' % ( expected , debug_lines ) ) )