/** @return the backupFacade */ public Backup getBackupFacade() { backupFacade.authenticate(); return backupFacade; }
@Before public void beforeTest() throws InterruptedException { // reset invocations counter of continuable handler ContinuableHandler.resetInvocationsCount(); // reset invocation of generic listener GenericListener.reset(); // Authenticate as Administrator login("admin", "geoserver", "ROLE_ADMINISTRATOR"); }
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); // add a workspace that shouldn't get removed if "purge" is set to false this.getTestData().addWorkspace("shouldNotBeDeleted", "http://snbd", getCatalog()); }
backupFacade.runRestoreAsync( file("geoserver-full-backup.zip"), null, null, null, hints); assertNotNull(backupFacade.getRestoreExecutions()); assertTrue(!backupFacade.getRestoreExecutions().isEmpty()); final Catalog restoreCatalog = restoreExecution.getRestoreCatalog(); assertNotNull(restoreCatalog); && (restoreExecution.getStatus() != BatchStatus.COMPLETED || !restoreExecution.isRunning())) { Thread.sleep(100); cnt++; if (restoreExecution.getStatus() == BatchStatus.ABANDONED || restoreExecution.getStatus() == BatchStatus.FAILED || restoreExecution.getStatus() == BatchStatus.UNKNOWN) { for (Throwable exception : restoreExecution.getAllFailureExceptions()) { LOGGER.log(Level.INFO, "ERROR: " + exception.getLocalizedMessage(), exception); exception.printStackTrace(); if (restoreExecution.getStatus() != BatchStatus.COMPLETED && restoreExecution.isRunning()) { backupFacade.stopExecution(restoreExecution.getId()); checkExtraPropertiesExists(); if (restoreExecution.getStatus() == BatchStatus.COMPLETED) { assertThat(ContinuableHandler.getInvocationsCount() > 2, is(true));
if (backup.getId() != null) { Object lookup = lookupBackupExecutionsContext(String.valueOf(backup.getId()), false, false); if (lookup != null) { getBackupFacade().restartExecution(backup.getId()); LOGGER.log(Level.INFO, "Backup restarted: " + backup.getArchiveFile()); return wrapObject( (BackupExecutionAdapter) lookup, BackupExecutionAdapter.class); } catch (Exception e) { "Could not restart the backup: " + backup.getArchiveFile()); getBackupFacade() .runBackupAsync( backup.getArchiveFile(), backup.isOverwrite(), backup.getWsFilter(), backup.getSiFilter(), backup.getLiFilter(), asParams(backup.getOptions())); LOGGER.log(Level.INFO, "Backup file generated: " + backup.getArchiveFile()); return wrapObject((BackupExecutionAdapter) execution, BackupExecutionAdapter.class);
RestoreExecutionAdapter execution = null; if (restore.getId() != null) { Object lookup = lookupBackupExecutionsContext(String.valueOf(restore.getId()), false, false); if (lookup != null) { getBackupFacade().restartExecution(restore.getId()); LOGGER.log(Level.INFO, "Restore restarted: " + restore.getArchiveFile()); return wrapObject( (RestoreExecutionAdapter) lookup, RestoreExecutionAdapter.class); } catch (Exception e) { "Could not restart the restore: " + restore.getArchiveFile()); getBackupFacade() .runRestoreAsync( restore.getArchiveFile(), restore.getWsFilter(), restore.getSiFilter(), restore.getLiFilter(), asParams(restore.getOptions())); LOGGER.log(Level.INFO, "Restore file: " + restore.getArchiveFile()); return wrapObject((RestoreExecutionAdapter) execution, RestoreExecutionAdapter.class);
backupFacade.runBackupAsync( Files.asResource( File.createTempFile("testRunSpringBatchBackupJob", ".zip")), assertNotNull(backupFacade.getBackupExecutions()); assertTrue(!backupFacade.getBackupExecutions().isEmpty()); assertNotNull(backupExecution); && (backupExecution.getStatus() != BatchStatus.COMPLETED || backupExecution.isRunning())) { Thread.sleep(100); cnt++; if (backupExecution.getStatus() == BatchStatus.ABANDONED || backupExecution.getStatus() == BatchStatus.FAILED || backupExecution.getStatus() == BatchStatus.UNKNOWN) { for (Throwable exception : backupExecution.getAllFailureExceptions()) { LOGGER.log(Level.INFO, "ERROR: " + exception.getLocalizedMessage(), exception); exception.printStackTrace(); assertEquals(backupExecution.getStatus(), BatchStatus.COMPLETED); assertThat(ContinuableHandler.getInvocationsCount() > 2, is(true)); assertThat(GenericListener.getBackupAfterInvocations(), is(3)); assertThat(GenericListener.getBackupBeforeInvocations(), is(3)); assertThat(GenericListener.getRestoreAfterInvocations(), is(3)); assertThat(GenericListener.getRestoreBeforeInvocations(), is(3));
backupFacade.runRestoreAsync( file("geoserver-full-backup.zip"), filter, null, null, hints); assertNotNull(backupFacade.getRestoreExecutions()); assertTrue(!backupFacade.getRestoreExecutions().isEmpty()); final Catalog restoreCatalog = restoreExecution.getRestoreCatalog(); assertNotNull(restoreCatalog); while (cnt < 100 && (restoreExecution.getStatus() != BatchStatus.COMPLETED)) { Thread.sleep(100); cnt++; if (restoreExecution.getStatus() == BatchStatus.ABANDONED || restoreExecution.getStatus() == BatchStatus.FAILED || restoreExecution.getStatus() == BatchStatus.UNKNOWN) { for (Throwable exception : restoreExecution.getAllFailureExceptions()) { LOGGER.log(Level.INFO, "ERROR: " + exception.getLocalizedMessage(), exception); exception.printStackTrace(); assertEquals(restoreExecution.getStatus(), BatchStatus.COMPLETED); if (restoreCatalog.getWorkspaces().size() > 0) { assertEquals(9, restoreCatalog.getDataStores().size()); checkExtraPropertiesExists(); assertThat(ContinuableHandler.getInvocationsCount() > 2, is(true));
@Override public RepeatStatus handle( StepContribution contribution, ChunkContext chunkContext, JobExecution jobExecution, BackupRestoreItem context) { Resource inputDirectory; Resource outputDirectory; if (GenericTaskletUtils.isBackup(context)) { // we are doing a backup inputDirectory = dataDirectory.getRoot(); outputDirectory = GenericTaskletUtils.getOutputDirectory(jobExecution); } else { // we are doing a restore inputDirectory = GenericTaskletUtils.getInputDirectory(jobExecution); outputDirectory = dataDirectory.getRoot(); } copyFile(inputDirectory, EXTRA_FILE_NAME, outputDirectory, EXTRA_FILE_NAME); return RepeatStatus.FINISHED; }
/** * @param allowAll * @param mustExist * @return */ protected Object lookupBackupExecutionsContext(String i, boolean allowAll, boolean mustExist) { if (i != null) { BackupExecutionAdapter backupExecution = null; try { backupExecution = getBackupFacade().getBackupExecutions().get(Long.parseLong(i)); } catch (NumberFormatException e) { } if (backupExecution == null && mustExist) { throw new ResourceNotFoundException("No such backup execution: " + i); } return backupExecution; } else { if (allowAll) { return new ArrayList<BackupExecutionAdapter>( getBackupFacade().getBackupExecutions().values()); } throw new ResourceNotFoundException("No backup execution specified"); } }
/** * @param allowAll * @param mustExist * @return */ protected Object lookupRestoreExecutionsContext(String i, boolean allowAll, boolean mustExist) { if (i != null) { RestoreExecutionAdapter restoreExecution = null; try { restoreExecution = getBackupFacade().getRestoreExecutions().get(Long.parseLong(i)); } catch (NumberFormatException e) { } if (restoreExecution == null && mustExist) { throw new ResourceNotFoundException("No such restore execution: " + i); } return restoreExecution; } else { if (allowAll) { return new ArrayList<RestoreExecutionAdapter>( getBackupFacade().getRestoreExecutions().values()); } throw new ResourceNotFoundException("No backup execution specified"); } }
@Before public void beforeTest() throws InterruptedException { ensureCleanedQueues(); // Authenticate as Administrator login("admin", "geoserver", "ROLE_ADMINISTRATOR"); }
@Before public void beforeTest() throws InterruptedException { backupFacade = (Backup) applicationContext.getBean("backupFacade"); ensureCleanedQueues(); // Authenticate as Administrator login("admin", "geoserver", "ROLE_ADMINISTRATOR"); }
@Before public void beforeTest() throws InterruptedException { backupFacade = (Backup) applicationContext.getBean("backupFacade"); ensureCleanedQueues(); // Authenticate as Administrator login("admin", "geoserver", "ROLE_ADMINISTRATOR"); }
/** @throws InterruptedException */ protected void ensureCleanedQueues() throws InterruptedException { int cnt = 0; while (!(backupFacade.getRestoreRunningExecutions().isEmpty() && backupFacade.getBackupRunningExecutions().isEmpty())) { if (cnt > 30) { LOGGER.log(Level.SEVERE, "Could not cleanup Running Executions Queues!"); break; } // Wait a bit Thread.sleep(10); cnt++; } } }
@Before public void beforeTest() throws InterruptedException { backupFacade = (Backup) applicationContext.getBean("backupFacade"); ensureCleanedQueues(); // Authenticate as Administrator login("admin", "geoserver", "ROLE_ADMINISTRATOR"); }
@Before public void beforeTest() throws InterruptedException { backupFacade = (Backup) applicationContext.getBean("backupFacade"); ensureCleanedQueues(); // Authenticate as Administrator login("admin", "geoserver", "ROLE_ADMINISTRATOR"); }
@Override protected void onTearDown(SystemTestData testData) throws Exception { /** Dispose Services */ this.testData = new SystemTestData(); cleanCatalog(); }
backupFacade.runRestoreAsync( file("parameterized-restore.zip"), null, null, null, hints); assertNotNull(backupFacade.getRestoreExecutions()); assertTrue(!backupFacade.getRestoreExecutions().isEmpty()); final Catalog restoreCatalog = restoreExecution.getRestoreCatalog(); assertNotNull(restoreCatalog); && (restoreExecution.getStatus() != BatchStatus.COMPLETED || !restoreExecution.isRunning())) { Thread.sleep(100); cnt++; if (restoreExecution.getStatus() == BatchStatus.ABANDONED || restoreExecution.getStatus() == BatchStatus.FAILED || restoreExecution.getStatus() == BatchStatus.UNKNOWN) { for (Throwable exception : restoreExecution.getAllFailureExceptions()) { LOGGER.log(Level.INFO, "ERROR: " + exception.getLocalizedMessage(), exception); exception.printStackTrace(); if (restoreExecution.getStatus() != BatchStatus.COMPLETED && restoreExecution.isRunning()) { backupFacade.stopExecution(restoreExecution.getId()); checkExtraPropertiesExists(); if (restoreExecution.getStatus() == BatchStatus.COMPLETED) { assertThat(ContinuableHandler.getInvocationsCount() > 2, is(true));