private Node createNamedLabeledNode( Label label, String name ) { Node node = embeddedDatabase.createNode( label ); node.setProperty( NAME_PROPERTY, name ); return node; }
private Node createNewNode( Label[] labels ) { Node node = db.createNode( labels ); node.setProperty( PROPERTY_KEY, random.nextInt() ); return node; }
private void createNewNode( List<Pair<Long,Label[]>> existingNodes ) { Label[] labels = randomLabels(); Node node = db.createNode( labels ); existingNodes.add( Pair.of( node.getId(), labels ) ); }
private void testNodeCreationTransaction( Label label, int i ) { try ( Transaction transaction = database.beginTx() ) { Node node = database.createNode( label ); node.setProperty( "property" + i, i ); transaction.success(); } }
@Test public void takeLabelLockForQueryWithIndexUsages() throws Exception { String labelName = "Human"; Label human = Label.label( labelName ); String propertyKey = "name"; createIndex( human, propertyKey ); try ( Transaction transaction = databaseRule.beginTx() ) { Node node = databaseRule.createNode( human ); node.setProperty( propertyKey, RandomStringUtils.randomAscii( 10 ) ); transaction.success(); } String query = "MATCH (n:" + labelName + ") where n." + propertyKey + " = \"Fry\" RETURN n "; List<LockOperationRecord> lockOperationRecords = traceQueryLocks( query ); assertThat( "Observed list of lock operations is: " + lockOperationRecords, lockOperationRecords, hasSize( 1 ) ); LockOperationRecord operationRecord = lockOperationRecords.get( 0 ); assertTrue( operationRecord.acquisition ); assertFalse( operationRecord.exclusive ); assertEquals( ResourceTypes.LABEL, operationRecord.resourceType ); }
db.createNode( randomLabels() ).setProperty( "name", randomUUID().toString() ); try ( Transaction tx = db.beginTx() ) node = db.createNode( randomLabels() ); nodeHeads.set( guy, node ); tx.success();
Node node = databaseRule.createNode( robot ); node.setProperty( propertyKey, RandomStringUtils.randomAscii( 10 ) ); transaction.success();
@Test public void mustReportMissingNode() throws Exception { // given someData(); File labelIndexFileCopy = copyLabelIndexFile(); // when try ( Transaction tx = db.beginTx() ) { db.createNode( LABEL_ONE ); tx.success(); } // and replaceLabelIndexWithCopy( labelIndexFileCopy ); db.shutdownAndKeepStore(); // then ConsistencyCheckService.Result result = fullConsistencyCheck(); assertFalse( "Expected consistency check to fail", result.isSuccessful() ); }
@Test public void reportNotCleanLabelIndex() throws IOException, ConsistencyCheckIncompleteException { DatabaseLayout databaseLayout = db.databaseLayout(); someData(); db.resolveDependency( CheckPointer.class ).forceCheckPoint( new SimpleTriggerInfo( "forcedCheckpoint" ) ); File labelIndexFileCopy = databaseLayout.file( "label_index_copy" ); copyFile( databaseLayout.labelScanStore(), labelIndexFileCopy ); try ( Transaction tx = db.beginTx() ) { db.createNode( LABEL_ONE ); tx.success(); } db.shutdownAndKeepStore(); copyFile( labelIndexFileCopy, databaseLayout.labelScanStore() ); ConsistencyCheckService.Result result = fullConsistencyCheck(); assertFalse( "Expected consistency check to fail", result.isSuccessful() ); assertThat( readReport( result ), hasItem( containsString("WARN : Label index was not properly shutdown and rebuild is required.") ) ); }
private void prepareDb() { Label countryLabel = Label.label( COUNTRY_LABEL ); Label color = Label.label( COLOR_LABEL ); Label car = Label.label( CAR_LABEL ); try ( Transaction transaction = embeddedDatabase.beginTx() ) { country1 = createNamedLabeledNode( countryLabel, "Sweden" ); country2 = createNamedLabeledNode( countryLabel, "USA" ); color1 = createNamedLabeledNode( color, "red" ); color2 = createNamedLabeledNode( color, "green" ); car1 = createNamedLabeledNode( car, "Volvo" ); car2 = createNamedLabeledNode( car, "Ford" ); otherNodes = new Node[250]; for ( int i = 0; i < 250; i++ ) { otherNodes[i] = embeddedDatabase.createNode(); } transaction.success(); } }
Node node1 = db.createNode( LABEL ); node1.setProperty( "prop", true );