use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class SpatialConfigExtractorTest method shouldLogFailureToExtractIndexConfigFromGenericBecauseOfIndexInFailedState.
@Test
void shouldLogFailureToExtractIndexConfigFromGenericBecauseOfIndexInFailedState() throws IOException {
// given
unzip(getClass(), ZIP_FAILED_SPATIAL_35_DIR, directory.homePath());
AssertableLogProvider logProvider = new AssertableLogProvider();
Log myLog = logProvider.getLog(getClass());
// and
Path spatialDirectory = directory.homePath().resolve(FAILED_SPATIAL_35_DIR);
assertTrue(fs.fileExists(spatialDirectory));
assertTrue(fs.isDirectory(spatialDirectory));
// when
List<SpatialFile> spatialFiles = IndexMigration.getSpatialFiles(fs, spatialDirectory);
SpatialConfigExtractor.indexConfigFromSpatialFile(pageCache, spatialFiles, NULL, myLog, DEFAULT_DATABASE_NAME);
// then
String reason = "Index is in FAILED state.";
assertContainsLogEntry(logProvider, spatialFiles.get(0).getIndexFile(), reason);
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class ServerSettingsMigratorTest method testWhitelistSettingsRename.
@Test
void testWhitelistSettingsRename() throws IOException {
Path confFile = testDirectory.createFile("test.conf");
Files.write(confFile, List.of("dbms.security.http_auth_whitelist=a,b"));
Config config = Config.newBuilder().fromFile(confFile).build();
var logProvider = new AssertableLogProvider();
config.setLogger(logProvider.getLog(Config.class));
assertThat(logProvider).forClass(Config.class).forLevel(WARN).containsMessageWithArguments("Use of deprecated setting %s. It is replaced by %s", "dbms.security.http_auth_whitelist", http_auth_allowlist.name());
assertEquals(List.of("a", "b"), config.get(http_auth_allowlist));
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class HttpTransactionManagerTest method newTransactionManager.
private static HttpTransactionManager newTransactionManager(DatabaseManagementService managementService, MemoryPool memoryPool) {
JobScheduler jobScheduler = mock(JobScheduler.class);
AssertableLogProvider logProvider = new AssertableLogProvider(true);
var defaultDatabase = "neo4j";
when(managementService.database(any(String.class))).thenAnswer(invocation -> {
Object[] args = invocation.getArguments();
String db = (String) args[0];
if (db.equals(defaultDatabase) || db.equals("system")) {
return graphWithName(db);
} else {
throw new DatabaseNotFoundException("Not found db named " + db);
}
});
return new HttpTransactionManager(managementService, memoryPool, jobScheduler, Clocks.systemClock(), Duration.ofMinutes(1), logProvider);
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class ErrorReporterTest method onlyDatabaseErrorsAreLogged.
@Test
void onlyDatabaseErrorsAreLogged() {
AssertableLogProvider userLog = new AssertableLogProvider();
AssertableLogProvider internalLog = new AssertableLogProvider();
ErrorReporter reporter = newErrorReporter(userLog, internalLog);
for (Status.Classification classification : Status.Classification.values()) {
if (classification != Status.Classification.DatabaseError) {
Status.Code code = newStatusCode(classification);
Neo4jError error = Neo4jError.from(() -> code, "Database error");
reporter.report(error);
assertThat(userLog).doesNotHaveAnyLogs();
assertThat(internalLog).doesNotHaveAnyLogs();
}
}
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class GraphDatabaseSettingsTest method testDefaultAddressMigration.
@Test
void testDefaultAddressMigration() {
String oldDefaultListen = "dbms.connectors.default_listen_address";
String oldDefaultAdvertised = "dbms.connectors.default_advertised_address";
var config = Config.newBuilder().setRaw(Map.of(oldDefaultListen, "foo", oldDefaultAdvertised, "bar")).build();
var logProvider = new AssertableLogProvider();
config.setLogger(logProvider.getLog(Config.class));
assertThrows(IllegalArgumentException.class, () -> config.getSetting(oldDefaultListen));
assertThrows(IllegalArgumentException.class, () -> config.getSetting(oldDefaultAdvertised));
assertEquals(new SocketAddress("foo"), config.get(default_listen_address));
assertEquals(new SocketAddress("bar"), config.get(default_advertised_address));
var messageMatcher = assertThat(logProvider).forClass(Config.class).forLevel(WARN);
messageMatcher.containsMessageWithArguments("Use of deprecated setting %s. It is replaced by %s", oldDefaultListen, default_listen_address.name()).containsMessageWithArguments("Use of deprecated setting %s. It is replaced by %s", oldDefaultAdvertised, default_advertised_address.name());
}
Aggregations