#NEWLINE# def test_replicator_skips_rsync_temp_files( self ) : #NEWLINE# #INDENT# device_path = os . path . join ( self . devices , 'sda' ) #NEWLINE# rmtree ( arg , ignore_errors = 1 ) #NEWLINE# os . mkdir ( device_path ) #NEWLINE# df = self . df_mgr . get_diskfile ( 'sda' , '0' , 'a' , 'c' , 'o' , policy = POLICIES . legacy ) #NEWLINE# ts = next ( self . ts ) #NEWLINE# with df . create ( ) as w : #NEWLINE# #INDENT# w . write ( 'asdf' ) #NEWLINE# w . put ( { #NEWLINE# #INDENT# 'X-Timestamp' : ts . internal , #NEWLINE# #UNINDENT# } ) #NEWLINE# w . commit ( ts ) #NEWLINE# #UNINDENT# expected_replicate_requests = 4 #NEWLINE# process_arg_checker = [ ( 0 , '' , [ ] ) , ( 0 , '' , [ ] ) ] #NEWLINE# stub_body = pickle . dumps ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# with _mock_process ( process_arg_checker ) as rsync_log , mock . patch ( 'swift.obj.replicator.whataremyips' , side_effect = _ips ) , mocked_http_conn ( * ( [ 200 ] * expected_replicate_requests ) , body = stub_body ) as conn_log : #NEWLINE# #INDENT# self . replicator . replicate ( ) #NEWLINE# #UNINDENT# self . assertEqual ( ( [ 'REPLICATE' ] * expected_replicate_requests ) , [ r [ 'method' ] for r in conn_log . requests ] ) #NEWLINE# self . assertEqual ( 2 , len ( rsync_log ) ) #NEWLINE# expected = '--exclude=.*.[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]' #NEWLINE# for subprocess_info in rsync_log : #NEWLINE# #INDENT# rsync_args = subprocess_info [ 'rsync_args' ] #NEWLINE# for arg in rsync_args : #NEWLINE# #INDENT# if arg . startswith ( '--exclude' ) : #NEWLINE# #INDENT# self . assertEqual ( arg , expected ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . fail ( ( 'Did not find --exclude argument in %r' % rsync_args ) )