use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class RecordStorageMigratorIT method shouldBeAbleToMigrateWithoutErrors.
@ParameterizedTest
@MethodSource("versions")
void shouldBeAbleToMigrateWithoutErrors(String version, LogPosition expectedLogPosition, Function<TransactionId, Boolean> txIdComparator) throws Exception {
// GIVEN a legacy database
Path prepare = testDirectory.directory("prepare");
var fs = testDirectory.getFileSystem();
MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, databaseLayout.databaseDirectory(), prepare);
AssertableLogProvider logProvider = new AssertableLogProvider(true);
LogService logService = new SimpleLogService(logProvider, logProvider);
RecordStoreVersionCheck check = getVersionCheck(pageCache, databaseLayout);
String versionToMigrateFrom = getVersionToMigrateFrom(check);
RecordStorageMigrator migrator = new RecordStorageMigrator(fs, pageCache, CONFIG, logService, jobScheduler, PageCacheTracer.NULL, batchImporterFactory, INSTANCE);
// WHEN migrating
migrator.migrate(databaseLayout, migrationLayout, progressMonitor.startSection("section"), versionToMigrateFrom, getVersionToMigrateTo(check), EMPTY);
migrator.moveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, getVersionToMigrateTo(check));
// THEN starting the new store should be successful
assertThat(testDirectory.getFileSystem().fileExists(databaseLayout.relationshipGroupDegreesStore())).isTrue();
GBPTreeRelationshipGroupDegreesStore.DegreesRebuilder noRebuildAssertion = new GBPTreeRelationshipGroupDegreesStore.DegreesRebuilder() {
@Override
public void rebuild(RelationshipGroupDegreesStore.Updater updater, CursorContext cursorContext, MemoryTracker memoryTracker) {
throw new IllegalStateException("Rebuild should not be required");
}
@Override
public long lastCommittedTxId() {
try {
return new RecordStorageEngineFactory().readOnlyTransactionIdStore(fs, databaseLayout, pageCache, NULL).getLastCommittedTransactionId();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
};
try (GBPTreeRelationshipGroupDegreesStore groupDegreesStore = new GBPTreeRelationshipGroupDegreesStore(pageCache, databaseLayout.relationshipGroupDegreesStore(), testDirectory.getFileSystem(), immediate(), noRebuildAssertion, writable(), PageCacheTracer.NULL, GBPTreeGenericCountsStore.NO_MONITOR, databaseLayout.getDatabaseName(), counts_store_max_cached_entries.defaultValue())) {
// The rebuild would happen here in start and will throw exception (above) if invoked
groupDegreesStore.start(NULL, INSTANCE);
// The store keeps track of committed transactions.
// It is essential that it starts with the transaction
// that is the last committed one at the upgrade time.
assertEquals(TX_ID, groupDegreesStore.txId());
}
StoreFactory storeFactory = new StoreFactory(databaseLayout, CONFIG, new ScanOnOpenOverwritingIdGeneratorFactory(fs, databaseLayout.getDatabaseName()), pageCache, fs, logService.getInternalLogProvider(), PageCacheTracer.NULL, writable());
storeFactory.openAllNeoStores().close();
assertThat(logProvider).forLevel(ERROR).doesNotHaveAnyLogs();
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class BoltThrottleMaxDurationIT method getTestGraphDatabaseFactory.
protected TestDatabaseManagementServiceBuilder getTestGraphDatabaseFactory() {
TestDatabaseManagementServiceBuilder factory = new TestDatabaseManagementServiceBuilder();
logProvider = new AssertableLogProvider();
factory.setInternalLogProvider(logProvider);
return factory;
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class CommonAbstractStoreTest method shouldIncludeFileNameInStoreVersionPrintout.
@Test
public void shouldIncludeFileNameInStoreVersionPrintout() {
// given
TheStore store = newStore();
AssertableLogProvider logProvider = new AssertableLogProvider();
// when
store.logVersions(logProvider.getLog(TheStore.class)::info);
// then
LogAssertions.assertThat(logProvider).containsMessages(format("%s[%s] %s", TheStore.TYPE_DESCRIPTOR, storeFile.getFileName(), TheStore.STORE_VERSION));
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class TestReadOnlyNeo4j method databaseNotStartInReadOnlyModeWithMissingIndex.
@Test
void databaseNotStartInReadOnlyModeWithMissingIndex() throws IOException {
createIndex();
deleteIndexFolder();
AssertableLogProvider logProvider = new AssertableLogProvider();
managementService = dbmsReadOnly(logProvider);
final var db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
var namedDatabaseId = db.databaseId();
assertFalse(db.isAvailable(1L), "Did not expect db to start");
assertThat(logProvider).assertExceptionForLogMessage("[" + namedDatabaseId.logPrefix() + "] Exception occurred while starting the database. Trying to stop already started components.").hasMessageContaining("Some indexes need to be rebuilt. This is not allowed in read only mode. Please start db in " + "writable mode to rebuild indexes. Indexes needing rebuild: ");
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class TransactionRangeDiagnosticsTest method shouldLogCorrectTransactionLogDiagnosticsForNoTransactionLogs.
@Test
void shouldLogCorrectTransactionLogDiagnosticsForNoTransactionLogs() throws IOException {
// GIVEN
Database database = databaseWithLogFilesContainingLowestTxId(noLogs());
AssertableLogProvider logProvider = new AssertableLogProvider();
Log logger = logProvider.getLog(getClass());
// WHEN
new TransactionRangeDiagnostics(database).dump(logger::info);
// THEN
assertThat(logProvider).containsMessages("Transaction log files stored on file store:").containsMessages(" - no transactions found").containsMessages(" - no checkpoints found");
}
Aggregations