#NEWLINE# def testExtendsLeaseIfCompactionTakesTooLong( self ) : #NEWLINE# #INDENT# with aff4 . FACTORY . Create ( self . collection_urn , 'PackedVersionedCollection' , mode = 'w' , token = self . token ) as fd : #NEWLINE# #INDENT# elements = [ ] #NEWLINE# for i in range ( 10 ) : #NEWLINE# #INDENT# elements . append ( rdf_flows . GrrMessage ( request_id = i ) ) #NEWLINE# #UNINDENT# fd . AddAll ( elements ) #NEWLINE# #UNINDENT# with test_lib . ConfigOverrider ( { #NEWLINE# #INDENT# 'Worker.compaction_lease_time' : 42 , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# with test_lib . FakeTime ( 20 ) : #NEWLINE# #INDENT# fd = aff4 . FACTORY . OpenWithLock ( self . collection_urn , 'PackedVersionedCollection' , lease_time = 10 , token = self . token ) #NEWLINE# self . assertEqual ( fd . CheckLease ( ) , 10 ) #NEWLINE# #UNINDENT# with test_lib . FakeTime ( 29 ) : #NEWLINE# #INDENT# fd . Compact ( ) #NEWLINE# self . assertEqual ( fd . CheckLease ( ) , 42 )