Search in sources :

Example 41 with AssertableLogProvider

use of org.neo4j.logging.AssertableLogProvider in project neo4j-documentation by neo4j.

the class NeoServerShutdownLoggingDocIT method setupServer.

@Before
public void setupServer() throws IOException {
    logProvider = new AssertableLogProvider();
    server = ServerHelper.createNonPersistentServer(logProvider);
    ServerHelper.cleanTheDatabase(server);
}
Also used : AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Before(org.junit.Before)

Example 42 with AssertableLogProvider

use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.

the class StoreUpgraderTest method upgradeShouldGiveProgressMonitorProgressMessages.

@ParameterizedTest
@MethodSource("versions")
void upgradeShouldGiveProgressMonitorProgressMessages(RecordFormats formats) throws Exception {
    init(formats);
    // Given
    StoreVersionCheck check = getVersionCheck(pageCache);
    // When
    AssertableLogProvider logProvider = new AssertableLogProvider();
    newUpgrader(check, pageCache, allowMigrateConfig, new VisibleMigrationProgressMonitor(logProvider.getLog("test"))).migrateIfNeeded(databaseLayout, false);
    // Then
    assertThat(logProvider).containsMessages("Store files", "Indexes", "Successfully finished");
}
Also used : StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 43 with AssertableLogProvider

use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.

the class StoreUpgraderTest method failToMoveTransactionLogsIfTheyAlreadyExist.

@ParameterizedTest
@MethodSource("versions")
void failToMoveTransactionLogsIfTheyAlreadyExist(RecordFormats formats) throws IOException {
    init(formats);
    Path txRoot = testDirectory.directory("customTxRoot");
    AssertableLogProvider logProvider = new AssertableLogProvider();
    StoreVersionCheck check = getVersionCheck(pageCache);
    Config config = Config.newBuilder().fromConfig(allowMigrateConfig).set(neo4j_home, testDirectory.homePath()).set(GraphDatabaseSettings.transaction_logs_root_path, txRoot.toAbsolutePath()).set(default_database, databaseLayout.getDatabaseName()).build();
    DatabaseLayout migrationLayout = DatabaseLayout.of(config);
    Path databaseTransactionLogsHome = txRoot.resolve(migrationLayout.getDatabaseName());
    fileSystem.mkdir(databaseTransactionLogsHome);
    createDummyTxLogFiles(databaseTransactionLogsHome);
    assertThrows(StoreUpgrader.TransactionLogsRelocationException.class, () -> newUpgrader(check, pageCache, config, new VisibleMigrationProgressMonitor(logProvider.getLog("test"))).migrateIfNeeded(migrationLayout, false));
}
Also used : Path(java.nio.file.Path) StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) Config(org.neo4j.configuration.Config) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 44 with AssertableLogProvider

use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.

the class StoreUpgraderTest method upgradeFailsIfMigrationIsNotAllowed.

@ParameterizedTest
@MethodSource("versions")
void upgradeFailsIfMigrationIsNotAllowed(RecordFormats formats) throws IOException {
    init(formats);
    StoreVersionCheck check = getVersionCheck(pageCache);
    AssertableLogProvider logProvider = new AssertableLogProvider();
    assertThrows(UpgradeNotAllowedException.class, () -> newUpgrader(check, pageCache, Config.defaults(), new VisibleMigrationProgressMonitor(logProvider.getLog("test"))).migrateIfNeeded(databaseLayout, false));
}
Also used : StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 45 with AssertableLogProvider

use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.

the class StoreUpgraderTest method upgradeMoveTransactionLogs.

@ParameterizedTest
@MethodSource("versions")
void upgradeMoveTransactionLogs(RecordFormats formats) throws IOException {
    init(formats);
    Path txRoot = testDirectory.directory("customTxRoot");
    AssertableLogProvider logProvider = new AssertableLogProvider();
    StoreVersionCheck check = getVersionCheck(pageCache);
    Config config = Config.newBuilder().fromConfig(allowMigrateConfig).set(neo4j_home, testDirectory.homePath()).set(GraphDatabaseSettings.transaction_logs_root_path, txRoot.toAbsolutePath()).set(default_database, databaseLayout.getDatabaseName()).build();
    DatabaseLayout migrationLayout = DatabaseLayout.of(config);
    newUpgrader(check, pageCache, config, new VisibleMigrationProgressMonitor(logProvider.getLog("test"))).migrateIfNeeded(migrationLayout, false);
    assertThat(logProvider).containsMessages("Starting transaction logs migration.", "Transaction logs migration completed.");
    assertThat(getLogFiles(migrationLayout.databaseDirectory())).isEmpty();
    Path databaseTransactionLogsHome = txRoot.resolve(migrationLayout.getDatabaseName());
    assertTrue(fileSystem.fileExists(databaseTransactionLogsHome));
    Set<String> logFileNames = getLogFileNames(databaseTransactionLogsHome);
    assertThat(logFileNames).isNotEmpty();
    assertThat(logFileNames).containsAll(getLogFileNames(prepareDatabaseDirectory));
}
Also used : Path(java.nio.file.Path) StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) Config(org.neo4j.configuration.Config) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)202 Test (org.junit.jupiter.api.Test)98 Test (org.junit.Test)63 Path (java.nio.file.Path)29 Log (org.neo4j.logging.Log)24 FakeClock (org.neo4j.time.FakeClock)20 SslPolicyConfig (org.neo4j.configuration.ssl.SslPolicyConfig)14 IOException (java.io.IOException)13 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 DynamicTest (org.junit.jupiter.api.DynamicTest)12 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)12 SocketAddress (org.neo4j.configuration.helpers.SocketAddress)11 NullLog (org.neo4j.logging.NullLog)11 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)10 BeforeEach (org.junit.jupiter.api.BeforeEach)9 ExecutingQuery (org.neo4j.kernel.api.query.ExecutingQuery)9 QueryLogger (org.neo4j.kernel.impl.query.QueryLoggerKernelExtension.QueryLogger)9 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)8 ServerSocket (java.net.ServerSocket)8 Before (org.junit.Before)8