Restore extends AbstractRestore { @Inject public Restore( IConfiguration config, @Named("backup") IBackupFileSystem fs, Sleeper sleeper, ICassandraProcess cassProcess, Provider<AbstractBackupPath> pathProvider, InstanceIdentity instanceIdentity, RestoreTokenSelector tokenSelector, MetaData metaData, InstanceState instanceState, IPostRestoreHook postRestoreHook) { super( config, fs, JOBNAME, sleeper, pathProvider, instanceIdentity, tokenSelector, cassProcess, metaData, instanceState, postRestoreHook); } @Inject  Restore(
            IConfiguration config,
            @Named("backup") IBackupFileSystem fs,
            Sleeper sleeper,
            ICassandraProcess cassProcess,
            Provider<AbstractBackupPath> pathProvider,
            InstanceIdentity instanceIdentity,
            RestoreTokenSelector tokenSelector,
            MetaData metaData,
            InstanceState instanceState,
            IPostRestoreHook postRestoreHook); static TaskTimer getTimer(); @Override String getName(); static final String JOBNAME; }
@Test public void testRestore() throws Exception { populateBackupFileSystem("test_backup"); String dateRange = "201108110030,201108110530"; restore.restore(new DateUtil.DateRange(dateRange)); Assert.assertTrue(filesystem.downloadedFiles.contains(fileList.get(0))); Assert.assertTrue(filesystem.downloadedFiles.contains(fileList.get(1))); Assert.assertTrue(filesystem.downloadedFiles.contains(fileList.get(2))); Assert.assertTrue(filesystem.downloadedFiles.contains(fileList.get(3))); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(4))); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(5))); Assert.assertEquals(Status.FINISHED, instanceState.getRestoreStatus().getStatus()); }
@Test public void testRestoreWithIncremental() throws Exception { populateBackupFileSystem("test_backup"); String dateRange = "201108110030,201108110730"; restore.restore(new DateUtil.DateRange(dateRange)); Assert.assertTrue(filesystem.downloadedFiles.contains(fileList.get(0))); Assert.assertTrue(filesystem.downloadedFiles.contains(fileList.get(1))); Assert.assertTrue(filesystem.downloadedFiles.contains(fileList.get(2))); Assert.assertTrue(filesystem.downloadedFiles.contains(fileList.get(3))); Assert.assertTrue(filesystem.downloadedFiles.contains(fileList.get(4))); Assert.assertTrue(filesystem.downloadedFiles.contains(fileList.get(5))); Assert.assertEquals(Status.FINISHED, instanceState.getRestoreStatus().getStatus()); }
@Test public void testRestoreLatestWithEmptyMeta() throws Exception { populateBackupFileSystem("test_backup"); String metafile = "test_backup/" + region + "/fakecluster/123456/201108110130/META/meta.json"; filesystem.addFile(metafile); String dateRange = "201108110030,201108110530"; restore.restore(new DateUtil.DateRange(dateRange)); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(0))); Assert.assertTrue(filesystem.downloadedFiles.contains(metafile)); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(1))); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(2))); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(3))); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(4))); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(5))); Assert.assertEquals(Status.FINISHED, instanceState.getRestoreStatus().getStatus()); Assert.assertEquals(metafile, instanceState.getRestoreStatus().getSnapshotMetaFile()); }
@Test public void testRestoreLatest() throws Exception { populateBackupFileSystem("test_backup"); String metafile = "test_backup/" + region + "/fakecluster/123456/201108110130/META/meta.json"; filesystem.addFile(metafile); String snapFile = "test_backup/" + region + "/fakecluster/123456/201108110130/SNAP/ks1/cf1/f9.db"; filesystem.addFile(snapFile); String dateRange = "201108110030,201108110530"; restore.restore(new DateUtil.DateRange(dateRange)); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(0))); Assert.assertTrue(filesystem.downloadedFiles.contains(metafile)); Assert.assertTrue(filesystem.downloadedFiles.contains(snapFile)); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(1))); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(2))); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(3))); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(4))); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(5))); Assert.assertEquals(Status.FINISHED, instanceState.getRestoreStatus().getStatus()); Assert.assertEquals(metafile, instanceState.getRestoreStatus().getSnapshotMetaFile()); }
@Test public void testNoSnapshots() throws Exception { populateBackupFileSystem("test_backup"); filesystem.setupTest(fileList); String dateRange = "201109110030,201109110530"; restore.restore(new DateUtil.DateRange(dateRange)); Assert.assertEquals(Status.FAILED, instanceState.getRestoreStatus().getStatus()); }
@Test public void testRestoreFromDiffCluster() throws Exception { populateBackupFileSystem("test_backup_new"); String dateRange = "201108110030,201108110530"; restore.restore(new DateUtil.DateRange(dateRange)); System.out.println("Downloaded files: " + filesystem.downloadedFiles); Assert.assertTrue(filesystem.downloadedFiles.contains(fileList.get(0))); Assert.assertTrue(filesystem.downloadedFiles.contains(fileList.get(1))); Assert.assertTrue(filesystem.downloadedFiles.contains(fileList.get(2))); Assert.assertTrue(filesystem.downloadedFiles.contains(fileList.get(3))); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(4))); Assert.assertFalse(filesystem.downloadedFiles.contains(fileList.get(5))); Assert.assertEquals(Status.FINISHED, instanceState.getRestoreStatus().getStatus()); }