private SchemaState getSchemaState() { return embeddedDatabase.resolveDependency( SchemaState.class ); }
private ThreadToStatementContextBridge getTransactionStatementContextBridge() { return embeddedDatabase.resolveDependency( ThreadToStatementContextBridge.class ); }
private JobScheduler getJobScheduler() { return embeddedDatabase.resolveDependency( JobScheduler.class ); }
private IndexProviderMap getIndexProviderMap() { return embeddedDatabase.resolveDependency( IndexProviderMap.class ); }
private <T> T resolveComponent( Class<T> clazz ) { return db.resolveDependency( clazz ); }
private LabelScanStore getLabelScanStore() { return embeddedDatabase.resolveDependency( LabelScanStore.class ); }
private NeoStores getNeoStores() { RecordStorageEngine recordStorageEngine = embeddedDatabase.resolveDependency( RecordStorageEngine.class ); return recordStorageEngine.testAccessNeoStores(); }
private List<LockOperationRecord> traceQueryLocks( String query, LockOperationListener... listeners ) throws QueryExecutionKernelException { GraphDatabaseQueryService graph = databaseRule.resolveDependency( GraphDatabaseQueryService.class ); QueryExecutionEngine executionEngine = databaseRule.resolveDependency( QueryExecutionEngine.class ); try ( InternalTransaction tx = graph .beginTransaction( KernelTransaction.Type.implicit, LoginContext.AUTH_DISABLED ) ) { TransactionalContextWrapper context = new TransactionalContextWrapper( createTransactionContext( graph, tx, query ), listeners ); executionEngine.executeQuery( query, VirtualValues.emptyMap(), context ); return new ArrayList<>( context.recordingLocks.getLockOperationRecords() ); } }
@Override void lockAcquired( boolean exclusive, ResourceType resourceType, long... ids ) { if ( !executed ) { ThreadToStatementContextBridge bridge = databaseRule.resolveDependency( ThreadToStatementContextBridge.class ); KernelTransaction ktx = bridge.getKernelTransactionBoundToThisThread( true ); ktx.schemaRead().schemaStateFlush(); } executed = true; } }
@Test public void reportNotCleanLabelIndexWithCorrectData() 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 ); db.shutdownAndKeepStore(); copyFile( labelIndexFileCopy, databaseLayout.labelScanStore() ); ConsistencyCheckService.Result result = fullConsistencyCheck(); assertTrue( "Expected consistency check to fail", result.isSuccessful() ); assertThat( readReport( result ), hasItem( containsString("WARN : Label index was not properly shutdown and rebuild is required.") ) ); }
@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.") ) ); }