/** * The test case is basically loads of concurrent CREATE/DELETE NODE or sometimes just CREATE, keeping the created node in an array * for dedicated deleter threads to pick up and delete as fast as they can see them. This concurrently with large creation transactions. */ @Test public void shouldStressIt() throws Throwable { // given Race race = new Race().withMaxDuration( 5, TimeUnit.SECONDS ); AtomicReferenceArray<Node> nodeHeads = new AtomicReferenceArray<>( NUMBER_OF_CREATORS ); for ( int i = 0; i < NUMBER_OF_CREATORS; i++ ) { race.addContestant( creator( nodeHeads, i ) ); } race.addContestants( NUMBER_OF_DELETORS, deleter( nodeHeads ) ); // when race.go(); // then DatabaseLayout dbLayout = db.databaseLayout(); db.shutdownAndKeepStore(); assertTrue( new ConsistencyCheckService().runFullConsistencyCheck( dbLayout, defaults(), NONE, toOutputStream( System.out ), false, new ConsistencyFlags( true, true, true, false ) ).isSuccessful() ); }
@Test public void concurrentCreatingUniquenessConstraint() throws Throwable { // given Race race = new Race().withMaxDuration( 10, SECONDS ); Label label = label( 0 ); race.addContestants( 10, () -> { try ( Transaction tx = db.beginTx() ) { db.schema().constraintFor( label ).assertPropertyIsUnique( KEY ).create(); tx.success(); } catch ( TransientFailureException | ConstraintViolationException e ) { // It's OK } }, 300 ); // when race.go(); try ( Transaction tx = db.beginTx() ) { // then ConstraintDefinition constraint = single( db.schema().getConstraints( label ) ); assertNotNull( constraint ); IndexDefinition index = single( db.schema().getIndexes( label ) ); assertNotNull( index ); tx.success(); } }
Race race = new Race().withMaxDuration( 10, SECONDS ); race.addContestants( 3, () ->