@Override public void handleTestExecutionException( ExtensionContext context, Throwable t ) { if ( t instanceof TestAbortedException ) { return; } final long seed = getStoredValue( context ).seed(); // The reason we throw a new exception wrapping the actual exception here, instead of simply enhancing the message is: // - AssertionFailedError has its own 'message' field, in addition to Throwable's 'detailedMessage' field // - Even if 'message' field is updated the test doesn't seem to print the updated message on assertion failure throw new AssertionFailedError( format( "%s [ random seed used: %dL ]", t.getMessage(), seed ), t ); } }
@Test @RandomRule.Seed( 15 ) void randomSeedSetupTest() { assertEquals( 15, nestedRandom.seed() ); }
Generator generator = generators[slot] = new Generator( MAX_BATCH_SIZE, random.seed() + slot, slot * worstCaseEntriesPerThread ); for ( int j = 0; j < BATCHES_PER_THREAD; j++ )
RandomValues randomValues = RandomValues.create( new Random( random.seed() + THREADS ) ); while ( insertersDone.getCount() > 0 )
private DataFactory generateData( Header.Factory factory, MutableLong start, long count, long nodeCount, String headerString, String fileName, Groups groups ) throws IOException { File file = directory.file( fileName ); Header header = factory.create( charSeeker( wrap( headerString ), COMMAS, false ), COMMAS, IdType.INTEGER, groups ); Distribution<String> distribution = new Distribution<>( new String[] {"Token"} ); Deserialization<String> deserialization = new StringDeserialization( COMMAS ); try ( PrintWriter out = new PrintWriter( new BufferedWriter( new FileWriter( file ) ) ); RandomEntityDataGenerator generator = new RandomEntityDataGenerator( nodeCount, count, toIntExact( count ), random.seed(), start.longValue(), header, distribution, distribution, 0, 0 ); InputChunk chunk = generator.newChunk(); InputEntity entity = new InputEntity() ) { out.println( headerString ); while ( generator.next( chunk ) ) { while ( chunk.next( entity ) ) { out.println( convert( entity, deserialization, header ) ); } } } start.add( count ); return DataFactories.data( InputEntityDecorators.NO_DECORATOR, Charsets.UTF_8, file ); } }
", seed:" + random.seed() + ", iteration:" + i ); throw t;
@Test public void shouldApplyLargeAmountOfInterleavedRandomUpdates() throws Exception { // given populator.create(); random.reset(); Random updaterRandom = new Random( random.seed() ); Iterator<IndexEntryUpdate<IndexDescriptor>> updates = valueCreatorUtil.randomUpdateGenerator( random ); // when int count = interleaveLargeAmountOfUpdates( updaterRandom, updates ); // then populator.close( true ); random.reset(); verifyUpdates( valueCreatorUtil.randomUpdateGenerator( random ), count ); }
try ( PrintStream out = new PrintStream( failureFile ) ) out.println( "Seed used in this failing run: " + random.seed() ); out.println( inputIdGenerator ); inputIdGenerator.reset();
@Test public void shouldReportProgressOfNodeImport() throws Exception { // given CapturingMonitor progress = new CapturingMonitor(); HumanUnderstandableExecutionMonitor monitor = new HumanUnderstandableExecutionMonitor( progress, NO_EXTERNAL_MONITOR ); IdType idType = INTEGER; Input input = new DataGeneratorInput( NODE_COUNT, RELATIONSHIP_COUNT, idType, Collector.EMPTY, random.seed(), 0, bareboneNodeHeader( idType, new Extractors( ';' ) ), bareboneRelationshipHeader( idType, new Extractors( ';' ) ), 1, 1, 0, 0 ); // when try ( JobScheduler jobScheduler = new ThreadPoolJobScheduler() ) { new ParallelBatchImporter( storage.directory().databaseLayout(), storage.fileSystem(), storage.pageCache(), DEFAULT, NullLogService.getInstance(), monitor, EMPTY, defaults(), LATEST_RECORD_FORMATS, NO_MONITOR, jobScheduler ).doImport( input ); // then progress.assertAllProgressReachedEnd(); } }
@Override public void handleTestExecutionException( ExtensionContext context, Throwable t ) { if ( t instanceof TestAbortedException ) { return; } final long seed = getStoredValue( context ).seed(); // The reason we throw a new exception wrapping the actual exception here, instead of simply enhancing the message is: // - AssertionFailedError has its own 'message' field, in addition to Throwable's 'detailedMessage' field // - Even if 'message' field is updated the test doesn't seem to print the updated message on assertion failure throw new AssertionFailedError( format( "%s [ random seed used: %dL ]", t.getMessage(), seed ), t ); } }