use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class RecoveryLogIT method transactionsRecoveryLogContainsTimeSpent.
@Test
void transactionsRecoveryLogContainsTimeSpent() throws IOException {
// Create database with forced recovery
Path tmpLogDir = testDirectory.directory("logs");
managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).build();
GraphDatabaseAPI db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
StorageEngineFactory storageEngineFactory = db.getDependencyResolver().resolveDependency(StorageEngineFactory.class);
try (Transaction tx = db.beginTx()) {
Node node1 = tx.createNode();
Node node2 = tx.createNode();
node1.createRelationshipTo(node2, RelationshipType.withName("likes"));
tx.commit();
}
Path[] txLogs = LogFilesBuilder.logFilesBasedOnlyBuilder(databaseLayout.getTransactionLogsDirectory(), fileSystem).withCommandReaderFactory(storageEngineFactory.commandReaderFactory()).build().logFiles();
for (Path file : txLogs) {
fileSystem.copyToDirectory(file, tmpLogDir);
}
managementService.shutdown();
for (Path txLog : fileSystem.listFiles(databaseLayout.getTransactionLogsDirectory())) {
fileSystem.deleteFile(txLog);
}
for (Path file : LogFilesBuilder.logFilesBasedOnlyBuilder(tmpLogDir, fileSystem).withCommandReaderFactory(storageEngineFactory.commandReaderFactory()).build().logFiles()) {
fileSystem.moveToDirectory(file, databaseLayout.getTransactionLogsDirectory());
}
AssertableLogProvider provider = new AssertableLogProvider();
managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).setInternalLogProvider(provider).build();
managementService.database(DEFAULT_DATABASE_NAME);
assertThat(provider).containsMessages("Recovery completed", "time spent");
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class IndexPopulationIT method setUp.
@BeforeEach
void setUp() {
logProvider = new AssertableLogProvider(true);
managementService = new TestDatabaseManagementServiceBuilder(directory.homePath()).setInternalLogProvider(logProvider).build();
database = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
executorService = Executors.newCachedThreadPool();
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class IndexPopulationIT method shutdownDatabaseDuringIndexPopulations.
@Test
void shutdownDatabaseDuringIndexPopulations() {
AssertableLogProvider assertableLogProvider = new AssertableLogProvider(true);
Path storeDir = directory.directory("shutdownDbTest");
Label testLabel = Label.label("testLabel");
String propertyName = "testProperty";
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(storeDir).setInternalLogProvider(assertableLogProvider).build();
GraphDatabaseService shutDownDb = managementService.database(DEFAULT_DATABASE_NAME);
prePopulateDatabase(shutDownDb, testLabel, propertyName);
try (Transaction transaction = shutDownDb.beginTx()) {
transaction.schema().indexFor(testLabel).on(propertyName).create();
transaction.commit();
}
managementService.shutdown();
assertThat(assertableLogProvider).forClass(IndexPopulationJob.class).forLevel(ERROR).doesNotHaveAnyLogs();
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class GenericConfigExtractorTest method shouldLogFailureToExtractIndexConfigFromGenericBecauseOfMissingFile.
@Test
void shouldLogFailureToExtractIndexConfigFromGenericBecauseOfMissingFile() throws IOException {
// given
AssertableLogProvider logProvider = new AssertableLogProvider();
Log myLog = logProvider.getLog(getClass());
Path genericFile = directory.file("genericFile");
assertFalse(fs.fileExists(genericFile));
// when
GenericConfigExtractor.indexConfigFromGenericFile(fs, pageCache, genericFile, NULL, myLog, DEFAULT_DATABASE_NAME);
// then
String reason = "Index file does not exists.";
assertContainsLogEntry(logProvider, genericFile, reason);
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class VisibleMigrationProgressMonitorTest method shouldIncludeDurationInCompletionMessage.
@Test
void shouldIncludeDurationInCompletionMessage() {
// given
AssertableLogProvider logProvider = new AssertableLogProvider();
Log log = logProvider.getLog(getClass());
FakeClock clock = new FakeClock();
VisibleMigrationProgressMonitor monitor = new VisibleMigrationProgressMonitor(log, clock);
// when
monitor.started(1);
clock.forward(1500, TimeUnit.MILLISECONDS);
monitor.completed();
// then
assertThat(logProvider).containsMessages("took 1s 500ms");
}
Aggregations