Skip to content

Commit

Permalink
CrashGenerationCleanerCrashTest more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen committed Aug 23, 2018
1 parent 4997569 commit 1be828a
Showing 1 changed file with 12 additions and 17 deletions.
Expand Up @@ -26,7 +26,7 @@
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicBoolean;


import org.neo4j.helpers.Exceptions; import org.neo4j.helpers.Exceptions;
import org.neo4j.io.pagecache.PageCursor; import org.neo4j.io.pagecache.PageCursor;
Expand All @@ -45,7 +45,7 @@ public class CrashGenerationCleanerCrashTest
public PageCacheAndDependenciesRule store = new PageCacheAndDependenciesRule(); public PageCacheAndDependenciesRule store = new PageCacheAndDependenciesRule();


@Test @Test
public void name() public void mustNotLeakTasksOnCrash()
{ {
// Given // Given
String exceptionMessage = "When there's no more room in hell, the dead will walk the earth"; String exceptionMessage = "When there's no more room in hell, the dead will walk the earth";
Expand Down Expand Up @@ -75,31 +75,26 @@ private CrashGenerationCleaner newCrashingCrashGenerationCleaner( String message
int pageSize = 8192; int pageSize = 8192;
PagedFile pagedFile = new StubPagedFile( pageSize ) PagedFile pagedFile = new StubPagedFile( pageSize )
{ {
AtomicInteger ioCount = new AtomicInteger(); AtomicBoolean first = new AtomicBoolean( true );


@Override @Override
public PageCursor io( long pageId, int pf_flags ) throws IOException public PageCursor io( long pageId, int pf_flags ) throws IOException
{ {
int count = ioCount.getAndIncrement(); try
System.out.println( "IOCount: " + count );
if ( count == 10 )
{ {
throw new IOException( message ); Thread.sleep( 1 );
}
catch ( InterruptedException e )
{
throw Exceptions.launderedException( e );
} }
else if ( first.getAndSet( false ) )
{ {
try throw new IOException( message );
{
Thread.sleep( 1 );
}
catch ( InterruptedException e )
{
throw Exceptions.launderedException( e );
}
} }
return super.io( pageId, pf_flags ); return super.io( pageId, pf_flags );
} }
}; };
return new CrashGenerationCleaner( pagedFile, new TreeNode<>( pageSize, new SimpleLongLayout() ), 0, MAX_BATCH_SIZE * 1000, 5, 7, NO_MONITOR ); return new CrashGenerationCleaner( pagedFile, new TreeNode<>( pageSize, new SimpleLongLayout() ), 0, MAX_BATCH_SIZE * 1_000_000_000, 5, 7, NO_MONITOR );
} }
} }

0 comments on commit 1be828a

Please sign in to comment.