#NEWLINE# def testRemoveGarbage( self ) : #NEWLINE# #INDENT# 'Make sure abandoned files get removed.' #NEWLINE# writer_spec = { #NEWLINE# #INDENT# self . WRITER_CLS . BUCKET_NAME_PARAM : 'unused' , #NEWLINE# self . WRITER_CLS . TMP_BUCKET_NAME_PARAM : 'test' , #NEWLINE# #UNINDENT# } #NEWLINE# mapreduce_state = self . create_mapreduce_state ( output_params = writer_spec ) #NEWLINE# shard_state = self . create_shard_state ( 1 ) #NEWLINE# ctx = context . Context ( mapreduce_state . mapreduce_spec , shard_state ) #NEWLINE# context . Context . _set ( ctx ) #NEWLINE# writer = self . WRITER_CLS . create ( mapreduce_state . mapreduce_spec , shard_state . shard_number , 0 ) #NEWLINE# writer . begin_slice ( None ) #NEWLINE# our_file = '/test/gae_mr_tmp/DummyMapReduceJobId-tmp-1-very-random' #NEWLINE# f = cloudstorage . open ( our_file , 'w' ) #NEWLINE# f . write ( 'foo?' ) #NEWLINE# f . close ( ) #NEWLINE# their_file = '/test/gae_mr_tmp/DummyMapReduceJobId-tmp-3-very-random' #NEWLINE# f = cloudstorage . open ( their_file , 'w' ) #NEWLINE# f . write ( 'bar?' ) #NEWLINE# f . close ( ) #NEWLINE# real_file = '/test/this_things_should_survive' #NEWLINE# f = cloudstorage . open ( real_file , 'w' ) #NEWLINE# f . write ( 'yes, foobar!' ) #NEWLINE# f . close ( ) #NEWLINE# names = [ l . filename for l in cloudstorage . listbucket ( '/test' ) ] #NEWLINE# self . assertTrue ( ( our_file in names ) ) #NEWLINE# self . assertTrue ( ( their_file in names ) ) #NEWLINE# self . assertTrue ( ( real_file in names ) ) #NEWLINE# writer = self . _serialize_and_deserialize ( writer ) #NEWLINE# names = [ l . filename for l in cloudstorage . listbucket ( '/test' ) ] #NEWLINE# self . assertFalse ( ( our_file in names ) ) #NEWLINE# self . assertTrue ( ( their_file in names ) ) #NEWLINE# self . assertTrue ( ( real_file in names ) ) #NEWLINE# writer . finalize ( ctx , shard_state ) #NEWLINE# self . assertFalse ( ( our_file in names ) ) #NEWLINE# self . assertTrue ( ( their_file in names ) ) #NEWLINE# self . assertTrue ( ( real_file in names ) )