private Page randomPage( int corruptionPercent, MutableInt totalNumberOfCorruptions ) { int numberOfCorruptions = 0; boolean internal = randomRule.nextBoolean(); if ( randomRule.nextInt( 100 ) < corruptionPercent ) { int maxCorruptions = internal ? possibleCorruptionsInInternal.size() : possibleCorruptionsInLeaf.size(); numberOfCorruptions = randomRule.intBetween( 1, maxCorruptions ); totalNumberOfCorruptions.add( numberOfCorruptions ); } return internal ? randomInternal( numberOfCorruptions ) : randomLeaf( numberOfCorruptions ); }
public long nextLong( long origin, long bound ) { return nextLong( (bound - origin) + 1L ) + origin; }
private long[] randomNodes( Ids[] ids ) { long[] nodeIds = new long[ids.length]; int cursor = 0; for ( Ids id : ids ) { if ( random.nextBoolean() ) { nodeIds[cursor++] = id.node.getId(); } } // If none was selected, then pick just one if ( cursor == 0 ) { nodeIds[cursor++] = random.among( ids ).node.getId(); } return Arrays.copyOf( nodeIds, cursor ); }
private NodeLabelUpdate randomUpdate( long[] expected ) { int nodeId = random.nextInt( expected.length ); long labels = expected[nodeId]; long[] before = getLabels( labels ); int changeCount = random.nextInt( 4 ) + 1; for ( int i = 0; i < changeCount; i++ ) { labels = flipRandom( labels, LABEL_COUNT, random.random() ); } expected[nodeId] = labels; return NodeLabelUpdate.labelChanges( nodeId, before, getLabels( labels ) ); }
int transactionSize = random.intBetween( 1, 30 ); try ( Transaction tx = db.beginTx() ) float operation = random.nextFloat(); if ( operation < 0.1 ) nodes.remove( random.nextInt( nodes.size() ) ).delete(); Node node = db.createNode( random.nextBoolean() ? array( label ) : new Label[0] ); for ( String key : keys ) if ( random.nextBoolean() ) node.setProperty( key, random.nextValueAsObject() ); random.among( nodes, node -> node.removeLabel( label ) ); random.among( nodes, node -> node.addLabel( label ) ); random.among( nodes, node -> node.setProperty( random.among( keys ), random.nextValueAsObject() ) ); random.among( nodes, node -> node.removeProperty( random.among( keys ) ) );
@Test void randomizedTest() final int count = 10000 + rnd.nextInt( 1000 ); final Value value = rnd.randomValues().nextValue(); final long ref = container.add( value ); final ObjectLongPair<Value> pair = pair( value, ref ); if ( rnd.nextBoolean() ) toRemove.shuffleThis(rnd.random() ); for ( final ObjectLongPair<Value> valueRefPair : toRemove )
if ( random.nextFloat() < 0.7 ) newKey = key( random.nextLong() ); VALUE newValue = value( random.nextLong() ); int position = expectedKeyCount == 0 ? 0 : random.nextInt( expectedKeyCount ); int position = random.nextInt( expectedKeyCount ); node.keyAt( cursor, readKey, position, LEAF ); node.valueAt( cursor, readValue, position );
ValueType type = random.among( types ); Value from = random.randomValues().nextValueOfType( type ); Value to = random.randomValues().nextValueOfType( type ); if ( Values.COMPARATOR.compare( from, to ) > 0 ) to = tmp; boolean fromInclusive = random.nextBoolean(); boolean toInclusive = random.nextBoolean();
DatabaseLayout databaseLayout = directory.databaseLayout( "dir" + random.nextAlphaNumericString( 8, 8 ) ); IdGroupDistribution groupDistribution = new IdGroupDistribution( NODE_COUNT, NUMBER_OF_ID_GROUPS, random.random(), groups ); long nodeRandomSeed = random.nextLong(); long relationshipRandomSeed = random.nextLong(); JobScheduler jobScheduler = new ThreadPoolJobScheduler(); final BatchImporter inserter = new ParallelBatchImporter( databaseLayout, try ( PrintStream out = new PrintStream( failureFile ) ) out.println( "Seed used in this failing run: " + random.seed() ); out.println( inputIdGenerator ); inputIdGenerator.reset();
@Test public void shouldScanAllInUseRelationshipsOfCertainType() { // given RelationshipStore relationshipStore = neoStores.getRelationshipStore(); int count = 100; relationshipStore.setHighId( count ); Set<Long> expected = new HashSet<>(); int theType = 1; for ( long id = 0; id < count; id++ ) { boolean inUse = random.nextBoolean(); int type = random.nextInt( 3 ); createRelationshipRecord( id, type, relationshipStore, inUse ); if ( inUse && type == theType ) { expected.add( id ); } } // when assertSeesRelationships( expected, theType ); }
@Test void shouldFillRandomGaps() { // given int numberOfRanges = random.intBetween( 50, 100 ); int[] ranges = new int[numberOfRanges]; for ( int rangeId = 0; rangeId < numberOfRanges; rangeId++ ) { ranges[rangeId] = random.nextInt( 1 << RANGE_SIZE ); } GapFreeAllEntriesLabelScanReader reader = newGapFreeAllEntriesLabelScanReader( ranges ); // when Iterator<NodeLabelRange> iterator = reader.iterator(); // then assertRanges( iterator, ranges ); }
private Label[] randomLabels() { List<Label> labels = new ArrayList<>( LABELS.length ); for ( Label label : LABELS ) { if ( random.nextBoolean() ) { labels.add( label ); } } return labels.toArray( new Label[labels.size()] ); }
private long[] modificationData( int min, int max ) { int count = random.intBetween( min, max ); long[] data = new long[count * 2]; for ( int i = 0, c = 0; i < count; i++ ) { data[c++] = random.intBetween( 0, keyRange ); // key data[c++] = random.intBetween( 0, keyRange ); // value } return data; }
protected void scrambleFile( File file ) throws IOException { scrambleFile( this.random.random(), file ); }
for ( int i = 0; i < numberOfNodes; i++ ) int count = random.nextInt( 1, denseNodeThreshold * 2 ); cache.setCount( i, count, random.nextInt( numberOfTypes ), random.among( directions ) ); for ( int i = 0; i < numberOfTypes; i++ ) int count = random.nextInt( 1, 100 ); types.add( new RelationshipTypeCount( i, count ) ); numberOfRelationships += count;
private void remove( int count, ValuesMap actualMap, MutableLongObjectMap<Value> expectedMap ) { for ( int i = 0; i < count / 2; i++ ) { final long key = rnd.nextLong( count ); final Value value = rnd.randomValues().nextValue(); actualMap.put( key, value ); expectedMap.put( key, value ); } }
private void assertHighestStringArray() { for ( int i = 0; i < 1000; i++ ) { assertHighest( random.randomValues().nextTextArray() ); } }
Generator<R> generator = generatorSupplier.get(); int recordSize = format.getRecordSize( new IntStoreHeader( DATA_SIZE ) ); BatchingIdSequence idSequence = new BatchingIdSequence( random.nextBoolean() ? idSureToBeOnTheNextPage( PAGE_SIZE, recordSize ) : 10 ); ", seed:" + random.seed() + ", iteration:" + i ); throw t;
@Test void shouldHandleStringPredicates() { for ( int i = 0; i < ITERATIONS; i++ ) { String value = random.nextString(); String other; if ( random.nextBoolean() ) { other = value; } else { other = random.nextString(); } assertConsistent( value, other, TextValue::startsWith ); assertConsistent( value, other, TextValue::endsWith ); assertConsistent( value, other, TextValue::contains ); } }