Search in sources :

Example 11 with StoreVersionCheck

use of org.neo4j.kernel.impl.storemigration.StoreVersionCheck in project neo4j by neo4j.

the class StoreMigratorFrom20IT method setUp.

@Before
public void setUp() {
    fs = fileSystemRule.get();
    pageCache = pageCacheRule.getPageCache(fs);
    File storeDirectory = storeDir.directory();
    schemaIndexProvider = new LuceneSchemaIndexProvider(fs, DirectoryFactory.PERSISTENT, storeDirectory, NullLogProvider.getInstance(), Config.empty(), OperationalMode.single);
    labelScanStoreProvider = NeoStoreDataSourceRule.nativeLabelScanStoreProvider(storeDirectory, fs, pageCache);
    upgradableDatabase = new UpgradableDatabase(fs, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fs), recordFormat);
}
Also used : LuceneSchemaIndexProvider(org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider) StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) File(java.io.File) Before(org.junit.Before)

Example 12 with StoreVersionCheck

use of org.neo4j.kernel.impl.storemigration.StoreVersionCheck in project neo4j by neo4j.

the class StoreUpgraderTest method shouldRefuseToUpgradeIfAnyOfTheStoresWereNotShutDownCleanly.

@Test
public void shouldRefuseToUpgradeIfAnyOfTheStoresWereNotShutDownCleanly() throws IOException {
    File comparisonDirectory = new File("target/" + StoreUpgraderTest.class.getSimpleName() + "shouldRefuseToUpgradeIfAnyOfTheStoresWereNotShutDownCleanly-comparison");
    makeDbNotCleanlyShutdown(false);
    fileSystem.deleteRecursively(comparisonDirectory);
    fileSystem.copyRecursively(dbDirectory, comparisonDirectory);
    PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
    UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fileSystem, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fileSystem), getRecordFormats());
    try {
        newUpgrader(upgradableDatabase, pageCache).migrateIfNeeded(dbDirectory);
        fail("Should throw exception");
    } catch (StoreUpgrader.UnableToUpgradeException e) {
    // expected
    }
    verifyFilesHaveSameContent(fileSystem, comparisonDirectory, dbDirectory);
}
Also used : UnableToUpgradeException(org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnableToUpgradeException) StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) StoreUpgrader(org.neo4j.kernel.impl.storemigration.StoreUpgrader) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) MigrationTestUtils.truncateFile(org.neo4j.kernel.impl.storemigration.MigrationTestUtils.truncateFile) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 13 with StoreVersionCheck

use of org.neo4j.kernel.impl.storemigration.StoreVersionCheck in project neo4j by neo4j.

the class StoreUpgraderTest method upgraderShouldCleanupLegacyLeftoverAndMigrationDirs.

@Test
public void upgraderShouldCleanupLegacyLeftoverAndMigrationDirs() throws Exception {
    // Given
    fileSystem.deleteFile(new File(dbDirectory, StoreLogService.INTERNAL_LOG_NAME));
    fileSystem.mkdir(new File(dbDirectory, StoreUpgrader.MIGRATION_DIRECTORY));
    fileSystem.mkdir(new File(dbDirectory, StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY));
    fileSystem.mkdir(new File(dbDirectory, StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY + "_1"));
    fileSystem.mkdir(new File(dbDirectory, StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY + "_2"));
    fileSystem.mkdir(new File(dbDirectory, StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY + "_42"));
    PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
    // When
    UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fileSystem, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fileSystem), getRecordFormats());
    StoreUpgrader storeUpgrader = newUpgrader(upgradableDatabase, pageCache);
    storeUpgrader.migrateIfNeeded(dbDirectory);
    // Then
    assertThat(migrationHelperDirs(), is(emptyCollectionOf(File.class)));
}
Also used : StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) StoreUpgrader(org.neo4j.kernel.impl.storemigration.StoreUpgrader) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) MigrationTestUtils.truncateFile(org.neo4j.kernel.impl.storemigration.MigrationTestUtils.truncateFile) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 14 with StoreVersionCheck

use of org.neo4j.kernel.impl.storemigration.StoreVersionCheck in project neo4j by neo4j.

the class StoreUpgraderTest method shouldContinueMovingFilesIfUpgradeCancelledWhileMoving.

@Test
public void shouldContinueMovingFilesIfUpgradeCancelledWhileMoving() throws Exception {
    PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
    UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fileSystem, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fileSystem), getRecordFormats());
    String versionToMigrateTo = upgradableDatabase.currentVersion();
    String versionToMigrateFrom = upgradableDatabase.checkUpgradeable(dbDirectory).storeVersion();
    // GIVEN
    {
        StoreUpgrader upgrader = newUpgrader(upgradableDatabase, allowMigrateConfig, pageCache);
        String failureMessage = "Just failing";
        upgrader.addParticipant(participantThatWillFailWhenMoving(failureMessage));
        // WHEN
        try {
            upgrader.migrateIfNeeded(dbDirectory);
            fail("should have thrown");
        } catch (UnableToUpgradeException e) {
            // THEN
            assertTrue(e.getCause() instanceof IOException);
            assertEquals(failureMessage, e.getCause().getMessage());
        }
    }
    // AND WHEN
    {
        StoreUpgrader upgrader = newUpgrader(upgradableDatabase, pageCache);
        StoreMigrationParticipant observingParticipant = Mockito.mock(StoreMigrationParticipant.class);
        upgrader.addParticipant(observingParticipant);
        upgrader.migrateIfNeeded(dbDirectory);
        // THEN
        verify(observingParticipant, Mockito.times(0)).migrate(any(File.class), any(File.class), any(MigrationProgressMonitor.Section.class), eq(versionToMigrateFrom), eq(versionToMigrateTo));
        verify(observingParticipant, Mockito.times(1)).moveMigratedFiles(any(File.class), any(File.class), eq(versionToMigrateFrom), eq(versionToMigrateTo));
        verify(observingParticipant, Mockito.times(1)).cleanup(any(File.class));
    }
}
Also used : StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UnableToUpgradeException(org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnableToUpgradeException) SilentMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor) MigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.MigrationProgressMonitor) StoreMigrationParticipant(org.neo4j.kernel.impl.storemigration.StoreMigrationParticipant) AbstractStoreMigrationParticipant(org.neo4j.kernel.impl.storemigration.participant.AbstractStoreMigrationParticipant) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) Matchers.containsString(org.hamcrest.Matchers.containsString) StoreUpgrader(org.neo4j.kernel.impl.storemigration.StoreUpgrader) IOException(java.io.IOException) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 15 with StoreVersionCheck

use of org.neo4j.kernel.impl.storemigration.StoreVersionCheck in project neo4j by neo4j.

the class StoreUpgradeOnStartupTest method setup.

@Before
public void setup() throws IOException {
    fileSystem = fileSystemRule.get();
    PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
    workingDirectory = testDir.directory("working_" + version);
    check = new StoreVersionCheck(pageCache);
    File prepareDirectory = testDir.directory("prepare_" + version);
    prepareSampleLegacyDatabase(version, fileSystem, workingDirectory, prepareDirectory);
    assertEquals(!StandardV2_3.STORE_VERSION.equals(version), allLegacyStoreFilesHaveVersion(fileSystem, workingDirectory, version));
}
Also used : StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) MigrationTestUtils.truncateFile(org.neo4j.kernel.impl.storemigration.MigrationTestUtils.truncateFile) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) Before(org.junit.Before)

Aggregations

StoreVersionCheck (org.neo4j.kernel.impl.storemigration.StoreVersionCheck)22 PageCache (org.neo4j.io.pagecache.PageCache)19 LegacyStoreVersionCheck (org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck)19 File (java.io.File)17 Test (org.junit.Test)17 UpgradableDatabase (org.neo4j.kernel.impl.storemigration.UpgradableDatabase)17 MigrationTestUtils.truncateFile (org.neo4j.kernel.impl.storemigration.MigrationTestUtils.truncateFile)9 SilentMigrationProgressMonitor (org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor)9 NullLogService (org.neo4j.kernel.impl.logging.NullLogService)7 StoreUpgrader (org.neo4j.kernel.impl.storemigration.StoreUpgrader)7 LogService (org.neo4j.kernel.impl.logging.LogService)6 StoreMigrator (org.neo4j.kernel.impl.storemigration.participant.StoreMigrator)4 IOException (java.io.IOException)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)3 UnableToUpgradeException (org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnableToUpgradeException)3 Before (org.junit.Before)2 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)2 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)2 Config (org.neo4j.kernel.configuration.Config)2