Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToResumeMigrationOnRebuildingCounts() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToResumeMigrationOnRebuildingCounts()
        {
            // GIVEN a legacy database
            DatabaseLayout databaseLayout = _directory.databaseLayout();
            File           prepare        = _directory.directory("prepare");

            MigrationTestUtils.prepareSampleLegacyDatabase(Version, _fs, databaseLayout.DatabaseDirectory(), prepare);
            // and a state of the migration saying that it has done the actual migration
            LogService         logService         = NullLogService.Instance;
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fs);
            LogTailScanner     tailScanner        = GetTailScanner(databaseLayout.DatabaseDirectory());
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache, tailScanner);

            string versionToMigrateFrom = upgradableDatabase.CheckUpgradable(databaseLayout).storeVersion();
            SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
            StoreMigrator  migrator        = new StoreMigrator(_fs, pageCache, _config, logService, _jobScheduler);
            DatabaseLayout migrationLayout = _directory.databaseLayout(StoreUpgrader.MIGRATION_DIRECTORY);

            migrator.Migrate(databaseLayout, migrationLayout, progressMonitor.StartSection("section"), versionToMigrateFrom, upgradableDatabase.CurrentVersion());

            // WHEN simulating resuming the migration
            progressMonitor = new SilentMigrationProgressMonitor();
            CountsMigrator countsMigrator = new CountsMigrator(_fs, pageCache, _config);

            countsMigrator.Migrate(databaseLayout, migrationLayout, progressMonitor.StartSection("section"), versionToMigrateFrom, upgradableDatabase.CurrentVersion());
            migrator.MoveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, upgradableDatabase.CurrentVersion());
            countsMigrator.MoveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, upgradableDatabase.CurrentVersion());

            // THEN starting the new store should be successful
            StoreFactory storeFactory = new StoreFactory(databaseLayout, _config, new DefaultIdGeneratorFactory(_fs), pageCache, _fs, logService.InternalLogProvider, EmptyVersionContextSupplier.EMPTY);

            storeFactory.OpenAllNeoStores().close();
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMovingFiles() throws java.io.IOException, org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMovingFiles()
        {
            MigrationTestUtils.prepareSampleLegacyDatabase(Version, _fs, _workingDatabaseLayout.databaseDirectory(), _prepareDirectory);
            PageCache                      pageCache            = _pageCacheRule.getPageCache(_fs);
            StoreVersionCheck              check                = new StoreVersionCheck(pageCache);
            UpgradableDatabase             upgradableDatabase   = GetUpgradableDatabase(check);
            SilentMigrationProgressMonitor progressMonitor      = new SilentMigrationProgressMonitor();
            LogService                     logService           = NullLogService.Instance;
            StoreMigrator                  failingStoreMigrator = new StoreMigratorAnonymousInnerClass2(this, _fs, pageCache, _config, logService, _jobScheduler);

            try
            {
                NewUpgrader(upgradableDatabase, pageCache, progressMonitor, CreateIndexMigrator(), failingStoreMigrator).migrateIfNeeded(_workingDatabaseLayout);
                fail("Should throw exception");
            }
            catch (Exception e)
            {
                assertEquals("This upgrade is failing", e.Message);
            }

            assertTrue(checkNeoStoreHasDefaultFormatVersion(check, _workingDatabaseLayout));

            progressMonitor = new SilentMigrationProgressMonitor();
            StoreMigrator migrator = new StoreMigrator(_fs, pageCache, _config, logService, _jobScheduler);

            NewUpgrader(upgradableDatabase, pageCache, progressMonitor, CreateIndexMigrator(), migrator).migrateIfNeeded(_workingDatabaseLayout);

            assertTrue(checkNeoStoreHasDefaultFormatVersion(check, _workingDatabaseLayout));

            pageCache.Close();

            // Since consistency checker is in read only mode we need to start/stop db to generate label scan store.
            StartStopDatabase(_workingDatabaseLayout.databaseDirectory());
            assertConsistentStore(_workingDatabaseLayout);
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToMigrateWithoutErrors() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToMigrateWithoutErrors()
        {
            // GIVEN a legacy database
            DatabaseLayout databaseLayout = _directory.databaseLayout();
            File           prepare        = _directory.directory("prepare");

            MigrationTestUtils.prepareSampleLegacyDatabase(Version, _fs, databaseLayout.DatabaseDirectory(), prepare);

            AssertableLogProvider logProvider = new AssertableLogProvider(true);
            LogService            logService  = new SimpleLogService(logProvider, logProvider);
            PageCache             pageCache   = _pageCacheRule.getPageCache(_fs);

            LogTailScanner     tailScanner        = GetTailScanner(databaseLayout.DatabaseDirectory());
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache, tailScanner);

            string versionToMigrateFrom = upgradableDatabase.CheckUpgradable(databaseLayout).storeVersion();
            SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
            StoreMigrator  migrator        = new StoreMigrator(_fs, pageCache, _config, logService, _jobScheduler);
            CountsMigrator countsMigrator  = new CountsMigrator(_fs, pageCache, _config);
            DatabaseLayout migrationLayout = _directory.databaseLayout(StoreUpgrader.MIGRATION_DIRECTORY);

            // WHEN migrating
            migrator.Migrate(databaseLayout, migrationLayout, progressMonitor.StartSection("section"), versionToMigrateFrom, upgradableDatabase.CurrentVersion());
            countsMigrator.Migrate(databaseLayout, migrationLayout, progressMonitor.StartSection("section"), versionToMigrateFrom, upgradableDatabase.CurrentVersion());
            migrator.MoveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, upgradableDatabase.CurrentVersion());
            countsMigrator.MoveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, upgradableDatabase.CurrentVersion());

            // THEN starting the new store should be successful
            StoreFactory storeFactory = new StoreFactory(databaseLayout, _config, new DefaultIdGeneratorFactory(_fs), pageCache, _fs, logService.InternalLogProvider, EmptyVersionContextSupplier.EMPTY);

            storeFactory.OpenAllNeoStores().close();
            logProvider.RawMessageMatcher().assertNotContains("ERROR");
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void haShouldFailToStartWithOldStore()
        public virtual void HaShouldFailToStartWithOldStore()
        {
            try
            {
                File storeDirectory    = TestDirectory.directory("haShouldFailToStartWithOldStore");
                File databaseDirectory = TestDirectory.databaseDir(storeDirectory);
                MigrationTestUtils.find23FormatStoreDirectory(databaseDirectory);

                (new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(databaseDirectory).setConfig(ClusterSettings.server_id, "1").setConfig(ClusterSettings.initial_hosts, "localhost:9999").newGraphDatabase();

                fail("Should exit abnormally");
            }
            catch (Exception e)
            {
                Exception rootCause = Exceptions.rootCause(e);
                assertThat(rootCause, instanceOf(typeof(UpgradeNotAllowedByConfigurationException)));
            }
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldComputeTheLastTxInfoCorrectly() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldComputeTheLastTxInfoCorrectly()
        {
            // given
            DatabaseLayout databaseLayout = _directory.databaseLayout();
            File           prepare        = _directory.directory("prepare");

            MigrationTestUtils.prepareSampleLegacyDatabase(Version, _fs, databaseLayout.DatabaseDirectory(), prepare);
            // and a state of the migration saying that it has done the actual migration
            LogService         logService         = NullLogService.Instance;
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fs);
            LogTailScanner     tailScanner        = GetTailScanner(databaseLayout.DatabaseDirectory());
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache, tailScanner);

            string versionToMigrateFrom = upgradableDatabase.CheckUpgradable(databaseLayout).storeVersion();
            SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
            StoreMigrator  migrator        = new StoreMigrator(_fs, pageCache, _config, logService, _jobScheduler);
            DatabaseLayout migrationLayout = _directory.databaseLayout(StoreUpgrader.MIGRATION_DIRECTORY);

            // when
            migrator.Migrate(databaseLayout, migrationLayout, progressMonitor.StartSection("section"), versionToMigrateFrom, upgradableDatabase.CurrentVersion());

            // then
            assertTrue(TxIdComparator.apply(migrator.ReadLastTxInformation(migrationLayout)));
        }