use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class TransactionRangeDiagnosticsTest method shouldLogCorrectTransactionLogDiagnosticsForTransactionsAndCheckpointLogs.
@Test
void shouldLogCorrectTransactionLogDiagnosticsForTransactionsAndCheckpointLogs() throws Exception {
// GIVEN
long txLogLowVersion = 2;
long txLogHighVersion = 10;
long checkpointLogLowVersion = 0;
long checkpointLogHighVersion = 3;
StoreId storeId = new StoreId(12345);
LogPosition checkpointLogPosition = new LogPosition(checkpointLogHighVersion, 34);
Database database = databaseWithLogFilesContainingLowestTxId(logs(transactionLogsWithTransaction(txLogLowVersion, txLogHighVersion, 42), checkpointLogsWithLastCheckpoint(checkpointLogLowVersion, checkpointLogHighVersion, new CheckpointInfo(new LogEntryDetachedCheckpoint(KernelVersion.LATEST, checkpointLogPosition, 1234, storeId, "testing"), checkpointLogPosition))));
AssertableLogProvider logProvider = new AssertableLogProvider();
Log logger = logProvider.getLog(getClass());
// WHEN
new TransactionRangeDiagnostics(database).dump(logger::info);
// THEN
assertThat(logProvider).containsMessages("existing transaction log versions " + txLogLowVersion + "-" + txLogHighVersion).containsMessages("existing checkpoint log versions " + checkpointLogLowVersion + "-" + checkpointLogHighVersion);
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class KernelDiagnosticsTest method shouldPrintDiskUsage.
@Test
void shouldPrintDiskUsage() throws IOException {
DatabaseLayout layout = DatabaseLayout.ofFlat(testDirectory.homePath());
StorageEngineFactory storageEngineFactory = mock(StorageEngineFactory.class);
when(storageEngineFactory.listStorageFiles(any(), any())).thenReturn(Collections.emptyList());
AssertableLogProvider logProvider = new AssertableLogProvider();
StoreFilesDiagnostics storeFiles = new StoreFilesDiagnostics(storageEngineFactory, fs, layout);
storeFiles.dump(logProvider.getLog(getClass())::debug);
assertThat(logProvider).containsMessages("Disk space on partition");
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class RecoveryIT method failToStartDatabaseWithTransactionLogsInLegacyLocation.
@Test
void failToStartDatabaseWithTransactionLogsInLegacyLocation() throws Exception {
GraphDatabaseAPI database = createDatabase();
generateSomeData(database);
managementService.shutdown();
LogFiles logFiles = buildLogFiles();
Path[] txLogFiles = fileSystem.listFiles(logFiles.logFilesDirectory(), path -> path.getFileName().toString().startsWith(DEFAULT_NAME));
txLogFiles = ArrayUtil.concat(txLogFiles, logFiles.getCheckpointFile().getDetachedCheckpointFiles());
Path databasesDirectory = databaseLayout.getNeo4jLayout().databasesDirectory();
DatabaseLayout legacyLayout = Neo4jLayout.ofFlat(databasesDirectory).databaseLayout(databaseLayout.getDatabaseName());
LegacyTransactionLogsLocator logsLocator = new LegacyTransactionLogsLocator(Config.defaults(), legacyLayout);
Path transactionLogsDirectory = logsLocator.getTransactionLogsDirectory();
assertNotNull(txLogFiles);
assertTrue(txLogFiles.length > 0);
for (Path logFile : txLogFiles) {
fileSystem.moveToDirectory(logFile, transactionLogsDirectory);
}
AssertableLogProvider logProvider = new AssertableLogProvider();
builder.setInternalLogProvider(logProvider);
GraphDatabaseAPI restartedDb = createDatabase();
try {
DatabaseStateService dbStateService = restartedDb.getDependencyResolver().resolveDependency(DatabaseStateService.class);
var failure = dbStateService.causeOfFailure(restartedDb.databaseId());
assertTrue(failure.isPresent());
assertThat(failure.get()).hasRootCauseMessage("Transaction logs are missing and recovery is not possible.");
assertThat(logProvider.serialize()).contains(txLogFiles[0].getFileName().toString());
} finally {
managementService.shutdown();
}
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class FileWatchIT method setUp.
@BeforeEach
void setUp() {
logProvider = new AssertableLogProvider();
managementService = new TestDatabaseManagementServiceBuilder(databaseLayout).setInternalLogProvider(logProvider).build();
database = managementService.database(DEFAULT_DATABASE_NAME);
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class LogPruneStrategyFactoryTest method setUp.
@BeforeEach
void setUp() {
fsa = new DefaultFileSystemAbstraction();
clock = Clocks.nanoClock();
logProvider = new AssertableLogProvider();
}
Aggregations