use of org.neo4j.kernel.impl.storemigration.StoreVersionCheck in project neo4j by neo4j.
the class StoreUpgraderTest method shouldLeaveAllFilesUntouchedIfWrongVersionNumberFound.
@Test
public void shouldLeaveAllFilesUntouchedIfWrongVersionNumberFound() throws IOException {
Set<String> applicableVersions = versionSet(StandardV2_0.STORE_VERSION, StandardV2_1.STORE_VERSION, StandardV2_2.STORE_VERSION);
assumeTrue("Applicable only to specified version set.", applicableVersions.contains(version));
File comparisonDirectory = new File("target/" + StoreUpgraderTest.class.getSimpleName() + "shouldLeaveAllFilesUntouchedIfWrongVersionNumberFound-comparison");
changeVersionNumber(fileSystem, new File(dbDirectory, "neostore.nodestore.db"), "v0.9.5");
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.UnexpectedUpgradingStoreVersionException e) {
// expected
}
verifyFilesHaveSameContent(fileSystem, comparisonDirectory, dbDirectory);
}
use of org.neo4j.kernel.impl.storemigration.StoreVersionCheck in project neo4j by neo4j.
the class StoreUpgraderTest method assertCorrectStoreVersion.
private static void assertCorrectStoreVersion(String expectedStoreVersion, StoreVersionCheck check, File storeDir) {
File neoStoreFile = new File(storeDir, MetaDataStore.DEFAULT_NAME);
StoreVersionCheck.Result result = check.hasVersion(neoStoreFile, expectedStoreVersion);
assertTrue("Unexpected store version", result.outcome.isSuccessful());
}
use of org.neo4j.kernel.impl.storemigration.StoreVersionCheck in project neo4j by neo4j.
the class StoreUpgraderTest method shouldHaltUpgradeIfUpgradeConfigurationVetoesTheProcess.
@Test
public void shouldHaltUpgradeIfUpgradeConfigurationVetoesTheProcess() throws IOException {
PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
Config deniedMigrationConfig = Config.embeddedDefaults(MapUtil.stringMap(GraphDatabaseSettings.allow_store_upgrade.name(), "false"));
UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fileSystem, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fileSystem), getRecordFormats());
try {
newUpgrader(upgradableDatabase, deniedMigrationConfig, pageCache).migrateIfNeeded(dbDirectory);
fail("Should throw exception");
} catch (UpgradeNotAllowedByConfigurationException e) {
// expected
}
}
use of org.neo4j.kernel.impl.storemigration.StoreVersionCheck in project neo4j by neo4j.
the class VersionCommand method execute.
@Override
public void execute(String[] args) throws IncorrectUsage, CommandFailed {
final Path storeDir = arguments.parseMandatoryPath("store", args);
Validators.CONTAINS_EXISTING_DATABASE.validate(storeDir.toFile());
try (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
PageCache pageCache = StandalonePageCacheFactory.createPageCache(fileSystem)) {
final String storeVersion = new StoreVersionCheck(pageCache).getVersion(storeDir.resolve(MetaDataStore.DEFAULT_NAME).toFile()).orElseThrow(() -> new CommandFailed(String.format("Could not find version metadata in store '%s'", storeDir)));
final String fmt = "%-25s%s";
out.accept(String.format(fmt, "Store format version:", storeVersion));
RecordFormats format = RecordFormatSelector.selectForVersion(storeVersion);
out.accept(String.format(fmt, "Introduced in version:", format.introductionVersion()));
findSuccessor(format).map(next -> String.format(fmt, "Superseded in version:", next.introductionVersion())).ifPresent(out);
out.accept(String.format(fmt, "Current version:", Version.getNeo4jVersion()));
} catch (IOException e) {
throw new CommandFailed(e.getMessage(), e);
}
}
use of org.neo4j.kernel.impl.storemigration.StoreVersionCheck in project neo4j by neo4j.
the class StoreMigratorTest method shouldNotDoActualStoreMigrationBetween3_0_5_and_next.
@Test
public void shouldNotDoActualStoreMigrationBetween3_0_5_and_next() throws Exception {
// GIVEN a store in vE.H.0 format
File storeDir = directory.directory();
new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDir).setConfig(GraphDatabaseSettings.record_format, HighLimitV3_0_0.NAME).newGraphDatabase().shutdown();
Config config = Config.embeddedDefaults(stringMap(pagecache_memory.name(), "8m"));
try (FileSystemAbstraction fs = new DefaultFileSystemAbstraction();
PageCache pageCache = new ConfiguringPageCacheFactory(fs, config, NULL, PageCursorTracerSupplier.NULL, NullLog.getInstance()).getOrCreatePageCache()) {
// For test code sanity
String fromStoreVersion = StoreVersion.HIGH_LIMIT_V3_0_0.versionString();
Result hasVersionResult = new StoreVersionCheck(pageCache).hasVersion(new File(storeDir, NEO_STORE.fileName(STORE)), fromStoreVersion);
assertTrue(hasVersionResult.actualVersion, hasVersionResult.outcome.isSuccessful());
// WHEN
StoreMigrator migrator = new StoreMigrator(fs, pageCache, config, NullLogService.getInstance(), NO_INDEX_PROVIDER);
MigrationProgressMonitor.Section monitor = mock(MigrationProgressMonitor.Section.class);
File migrationDir = new File(storeDir, "migration");
fs.mkdirs(migrationDir);
migrator.migrate(storeDir, migrationDir, monitor, fromStoreVersion, StoreVersion.HIGH_LIMIT_V3_0_6.versionString());
// THEN
verifyNoMoreInteractions(monitor);
}
}
Aggregations