@Test public void skipEmptyIndexStorageMigration() throws IOException { when( fs.listFiles( originalIndexStore ) ).thenReturn( null ); ExplicitIndexProvider indexProviders = getExplicitIndexProvider(); ExplicitIndexMigrator indexMigrator = new TestExplicitIndexMigrator( fs, indexProviders, logProvider, true ); indexMigrator.migrate( storeLayout, migrationLayout, progressMonitor, StandardV2_3.STORE_VERSION, StandardV3_0.STORE_VERSION ); verify( fs, never() ).deleteRecursively( originalIndexStore ); verify( fs, never() ).moveToDirectory( migratedIndexStore, storeLayout.databaseDirectory() ); }
@Test public void logErrorWithIndexNameOnIndexMigrationException() { Log log = mock( Log.class ); when( logProvider.getLog( TestExplicitIndexMigrator.class ) ).thenReturn( log ); ExplicitIndexProvider indexProviders = getExplicitIndexProvider(); try { ExplicitIndexMigrator indexMigrator = new TestExplicitIndexMigrator( fs, indexProviders, logProvider, false ); indexMigrator.migrate( storeLayout, migrationLayout, progressMonitor, StandardV2_3.STORE_VERSION, StandardV3_0.STORE_VERSION ); fail( "Index migration should fail" ); } catch ( IOException e ) { // ignored } verify( log ).error( eq( "Migration of explicit indexes failed. Index: testIndex can't be migrated." ), any( Throwable.class ) ); }
@Test public void cleanupMigrationDirectory() throws IOException { when( fs.fileExists( migratedIndexStore ) ).thenReturn( true ); ExplicitIndexProvider indexProviders = getExplicitIndexProvider(); ExplicitIndexMigrator indexMigrator = new TestExplicitIndexMigrator( fs, indexProviders, logProvider, true ); indexMigrator.migrate( storeLayout, migrationLayout, progressMonitor, StandardV2_3.STORE_VERSION, StandardV3_0.STORE_VERSION ); indexMigrator.cleanup( migrationLayout ); verify( fs ).deleteRecursively( migratedIndexStore ); }
@Test public void transferOriginalDataToMigrationDirectory() throws IOException { ExplicitIndexProvider indexProviders = getExplicitIndexProvider(); ExplicitIndexMigrator indexMigrator = new TestExplicitIndexMigrator( fs, indexProviders, logProvider, true ); indexMigrator.migrate( storeLayout, migrationLayout, progressMonitor, StandardV2_3.STORE_VERSION, StandardV3_0.STORE_VERSION ); verify( fs ).copyRecursively( originalIndexStore, migratedIndexStore ); }
@Test public void transferMigratedIndexesToStoreDirectory() throws IOException { ExplicitIndexProvider indexProviders = getExplicitIndexProvider(); ExplicitIndexMigrator indexMigrator = new TestExplicitIndexMigrator( fs, indexProviders, logProvider, true ); indexMigrator.migrate( storeLayout, migrationLayout, progressMonitor, StandardV2_3.STORE_VERSION, StandardV3_0.STORE_VERSION ); reset( fs ); indexMigrator.moveMigratedFiles( migrationLayout, storeLayout, "any", "any" ); verify( fs ).deleteRecursively( originalIndexStore ); verify( fs ).moveToDirectory( migratedIndexStore, storeLayout.databaseDirectory() ); }