#NEWLINE# def test_sync_to_remote_with_misplaced( self ) : #NEWLINE# #INDENT# ts = ( Timestamp ( t ) . internal for t in itertools . count ( int ( time . time ( ) ) ) ) #NEWLINE# policy = random . choice ( list ( POLICIES ) ) #NEWLINE# broker = self . _get_broker ( 'a' , 'c' , node_index = 0 ) #NEWLINE# broker . initialize ( next ( ts ) , policy . idx ) #NEWLINE# remote_policy = random . choice ( [ p for p in POLICIES if ( p is not policy ) ] ) #NEWLINE# remote_broker = self . _get_broker ( 'a' , 'c' , node_index = 1 ) #NEWLINE# remote_broker . initialize ( next ( ts ) , remote_policy . idx ) #NEWLINE# remote_broker . put_object ( '/a/c/o' , next ( ts ) , 0 , 'content-type' , 'etag' , storage_policy_index = remote_broker . storage_policy_index ) #NEWLINE# self . assertEqual ( remote_broker . get_info ( ) [ 'object_count' ] , 1 ) #NEWLINE# self . assertEqual ( [ ] , remote_broker . get_misplaced_since ( ( - 1 ) , 1 ) ) #NEWLINE# ( part , node ) = self . _get_broker_part_node ( broker ) #NEWLINE# daemon = self . _run_once ( node ) #NEWLINE# self . assertEqual ( 1 , daemon . stats [ 'no_change' ] ) #NEWLINE# self . assertEqual ( 0 , broker . get_info ( ) [ 'object_count' ] ) #NEWLINE# info = remote_broker . get_info ( ) #NEWLINE# expectations = { #NEWLINE# #INDENT# 'object_count' : 0 , #NEWLINE# 'storage_policy_index' : policy . idx , #NEWLINE# #UNINDENT# } #NEWLINE# for ( key , value ) in expectations . items ( ) : #NEWLINE# #INDENT# self . assertEqual ( info [ key ] , value ) #NEWLINE# #UNINDENT# misplaced = remote_broker . get_misplaced_since ( ( - 1 ) , 100 ) #NEWLINE# self . assertEqual ( len ( misplaced ) , 1 ) #NEWLINE# self . assertEqual ( 1 , daemon . stats [ 'rsync' ] ) #NEWLINE# third_broker = self . _get_broker ( 'a' , 'c' , node_index = 2 ) #NEWLINE# info = third_broker . get_info ( ) #NEWLINE# for ( key , value ) in expectations . items ( ) : #NEWLINE# #INDENT# self . assertEqual ( info [ key ] , value )