protected void scrambleFile( File file ) throws IOException { scrambleFile( this.random.random(), file ); }
toRemove.shuffleThis(rnd.random() ); for ( final ObjectLongPair<Value> valueRefPair : toRemove )
private void scrambleFile( File file ) throws IOException { LabelScanStoreTest.scrambleFile( randomRule.random(), file ); }
private void scrambleFile( File file ) throws IOException { LabelScanStoreTest.scrambleFile( random.random(), file ); }
@Test public void shouldReadBackwardCorrectlyWithConcurrentInsert() throws Throwable { TestCoordinator testCoordinator = new TestCoordinator( random.random(), false, 1 ); shouldReadCorrectlyWithConcurrentUpdates( testCoordinator ); }
@Test public void shouldReadBackwardCorrectlyWithConcurrentRemove() throws Throwable { TestCoordinator testCoordinator = new TestCoordinator( random.random(), false, 0 ); shouldReadCorrectlyWithConcurrentUpdates( testCoordinator ); }
@Test public void shouldReadForwardCorrectlyWithConcurrentUpdates() throws Throwable { TestCoordinator testCoordinator = new TestCoordinator( random.random(), true, 0.5 ); shouldReadCorrectlyWithConcurrentUpdates( testCoordinator ); }
@Test public void shouldReadBackwardCorrectlyWithConcurrentUpdates() throws Throwable { TestCoordinator testCoordinator = new TestCoordinator( random.random(), false, 0.5 ); shouldReadCorrectlyWithConcurrentUpdates( testCoordinator ); }
@Test public void shouldReadForwardCorrectlyWithConcurrentInsert() throws Throwable { TestCoordinator testCoordinator = new TestCoordinator( random.random(), true, 1 ); shouldReadCorrectlyWithConcurrentUpdates( testCoordinator ); }
@Test public void shouldReadForwardCorrectlyWithConcurrentRemove() throws Throwable { TestCoordinator testCoordinator = new TestCoordinator( random.random(), true, 0 ); shouldReadCorrectlyWithConcurrentUpdates( testCoordinator ); }
private List<InputEntity> randomNodeData() { List<InputEntity> nodes = new ArrayList<>(); for ( int i = 0; i < 300; i++ ) { InputEntity node = new InputEntity(); node.id( UUID.randomUUID().toString(), Group.GLOBAL ); node.property( "name", "Node " + i ); node.property( "pointA", "\" { x : -4.2, y : " + i + ", crs: WGS-84 } \"" ); node.property( "pointB", "\" { x : -8, y : " + i + " } \"" ); node.property( "date", LocalDate.of( 2018, i % 12 + 1, i % 28 + 1 ) ); node.property( "time", OffsetTime.of( 1, i % 60, 0, 0, ZoneOffset.ofHours( 9 ) ) ); node.property( "dateTime", ZonedDateTime.of( 2011, 9, 11, 8, i % 60, 0, 0, ZoneId.of( "Europe/Stockholm" ) ) ); node.property( "dateTime2", LocalDateTime.of( 2011, 9, 11, 8, i % 60, 0, 0 ) ); // No zone specified node.property( "localTime", LocalTime.of( 1, i % 60, 0 ) ); node.property( "localDateTime", LocalDateTime.of( 2011, 9, 11, 8, i % 60 ) ); node.property( "duration", Period.of( 2, -3, i % 30 ) ); node.labels( randomLabels( random.random() ) ); nodes.add( node ); } return nodes; }
private void randomModifications( long[] expected, int count ) throws IOException { BitSet editedNodes = new BitSet(); try ( LabelScanWriter writer = store.newWriter() ) { for ( int i = 0; i < count; i++ ) { int nodeId = random.nextInt( NODE_COUNT ); if ( editedNodes.get( nodeId ) ) { i--; continue; } int changeSize = random.nextInt( 3 ) + 1; long labels = expected[nodeId]; long[] labelsBefore = getLabels( labels ); for ( int j = 0; j < changeSize; j++ ) { labels = flipRandom( labels, LABEL_COUNT, random.random() ); } long[] labelsAfter = getLabels( labels ); editedNodes.set( nodeId ); NodeLabelUpdate labelChanges = labelChanges( nodeId, labelsBefore, labelsAfter ); writer.write( labelChanges ); expected[nodeId] = labels; } } }
for ( int i = 0; i < count; i++ ) data.put( randomKey( random.random() ), randomValue( random.random() ) ); KEY first = randomKey( random.random() ); KEY second = randomKey( random.random() ); KEY from; KEY to; randomlyModifyIndex( index, data, random.random(), (double) round / totalNumberOfRounds );
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 ) ); }
@Test public void failedIndexShouldRepairAutomatically() throws Exception { // given try ( Transaction tx = db.beginTx() ) { db.schema().indexFor( PERSON ).on( "name" ).create(); tx.success(); } awaitIndexesOnline( 5, SECONDS ); createNamed( PERSON, "Johan" ); // when - we restart the database in a state where the index is not operational db.restartDatabase( new SabotageNativeIndex( random.random() ) ); // then - the database should still be operational createNamed( PERSON, "Lars" ); awaitIndexesOnline( 5, SECONDS ); indexStateShouldBe( equalTo( ONLINE ) ); assertFindsNamed( PERSON, "Lars" ); }
IdGroupDistribution groupDistribution = new IdGroupDistribution( NODE_COUNT, NUMBER_OF_ID_GROUPS, random.random(), groups ); long nodeRandomSeed = random.nextLong(); long relationshipRandomSeed = random.nextLong();
@Test public void shouldNotBeAbleToViolateConstraintWhenBackingIndexFailsToOpen() throws Exception { // given try ( Transaction tx = db.beginTx() ) { db.schema().constraintFor( PERSON ).assertPropertyIsUnique( "name" ).create(); tx.success(); } createNamed( PERSON, "Lars" ); // when - we restart the database in a state where the index is not operational db.restartDatabase( new SabotageNativeIndex( random.random() ) ); // then - we must not be able to violate the constraint createNamed( PERSON, "Johan" ); Throwable failure = null; try { createNamed( PERSON, "Lars" ); } catch ( Throwable e ) { // this must fail, otherwise we have violated the constraint failure = e; } assertNotNull( failure ); indexStateShouldBe( equalTo( ONLINE ) ); }
@Test public void shouldArchiveFailedIndex() throws Exception { // given db.withSetting( GraphDatabaseSettings.archive_failed_index, "true" ); try ( Transaction tx = db.beginTx() ) { Node node = db.createNode( PERSON ); node.setProperty( "name", "Fry" ); tx.success(); } try ( Transaction tx = db.beginTx() ) { Node node = db.createNode( PERSON ); node.setProperty( "name", Values.pointValue( CoordinateReferenceSystem.WGS84, 1, 2 ) ); tx.success(); } try ( Transaction tx = db.beginTx() ) { db.schema().constraintFor( PERSON ).assertPropertyIsUnique( "name" ).create(); tx.success(); } assertThat( archiveFile(), nullValue() ); // when db.restartDatabase( new SabotageNativeIndex( random.random() ) ); // then indexStateShouldBe( equalTo( ONLINE ) ); assertThat( archiveFile(), notNullValue() ); }
assertTrue( m.keySet().allSatisfy( map::containsKey ) ); final List<LongLongPair> toRemove = m.keyValuesView().select( p -> rnd.nextInt( 100 ) < 75 ).toList().shuffleThis( rnd.random() );