@Test void testCheckStatusWithFailedState() { FreeIpaPollerObject freeIpaPollerObject = new FreeIpaPollerObject(ENV_ID, ENV_CRN); DescribeFreeIpaResponse freeIpa = new DescribeFreeIpaResponse(); freeIpa.setStatus(DELETE_IN_PROGRESS); freeIpa.setName(FREE_IPA_NAME); freeIpa.setCrn(FREE_IPA_CRN); when(freeIpaService.describe(ENV_CRN)).thenReturn(Optional.of(freeIpa)); assertThrows(FreeIpaOperationFailedException.class, () -> underTest.checkStatus(freeIpaPollerObject)); }
@Override public boolean checkStatus(FreeIpaPollerObject freeIpaPollerObject) { String environmentCrn = freeIpaPollerObject.getEnvironmentCrn(); try { LOGGER.info("Checking the state of FreeIpa creation progress for environment: '{}'", environmentCrn); Optional<DescribeFreeIpaResponse> freeIpaOptional = freeIpaService.describe(environmentCrn); if (freeIpaOptional.isEmpty()) { throw new FreeIpaOperationFailedException("FreeIpa cluster not found for environment: " + environmentCrn); } DescribeFreeIpaResponse freeIpa = freeIpaOptional.get(); if (freeIpa.getStatus().isDeletionInProgress() || freeIpa.getStatus().isSuccessfullyDeleted()) { LOGGER.error("FreeIpa '{}' '{}' is getting terminated (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus()); throw new FreeIpaOperationFailedException("FreeIpa instance deleted under the creation process."); } if (freeIpa.getStatus().isFailed()) { LOGGER.error("FreeIpa '{}' '{}' is in failed state (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus()); throw new FreeIpaOperationFailedException(String.format("FreeIpa creation failed. Status: '%s' statusReason: '%s'", freeIpa.getStatus(), freeIpa.getStatusReason())); } if (freeIpa.getStatus().isAvailable()) { return true; } } catch (Exception e) { throw new FreeIpaOperationFailedException("FreeIpa creation operation failed. " + e.getMessage(), e); } return false; }
FreeIpaCreationRetrievalTask extends SimpleStatusCheckerTask<FreeIpaPollerObject> { @Override public boolean checkStatus(FreeIpaPollerObject freeIpaPollerObject) { String environmentCrn = freeIpaPollerObject.getEnvironmentCrn(); try { LOGGER.info("Checking the state of FreeIpa creation progress for environment: '{}'", environmentCrn); Optional<DescribeFreeIpaResponse> freeIpaOptional = freeIpaService.describe(environmentCrn); if (freeIpaOptional.isEmpty()) { throw new FreeIpaOperationFailedException("FreeIpa cluster not found for environment: " + environmentCrn); } DescribeFreeIpaResponse freeIpa = freeIpaOptional.get(); if (freeIpa.getStatus().isDeletionInProgress() || freeIpa.getStatus().isSuccessfullyDeleted()) { LOGGER.error("FreeIpa '{}' '{}' is getting terminated (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus()); throw new FreeIpaOperationFailedException("FreeIpa instance deleted under the creation process."); } if (freeIpa.getStatus().isFailed()) { LOGGER.error("FreeIpa '{}' '{}' is in failed state (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus()); throw new FreeIpaOperationFailedException(String.format("FreeIpa creation failed. Status: '%s' statusReason: '%s'", freeIpa.getStatus(), freeIpa.getStatusReason())); } if (freeIpa.getStatus().isAvailable()) { return true; } } catch (Exception e) { throw new FreeIpaOperationFailedException("FreeIpa creation operation failed. " + e.getMessage(), e); } return false; } }
FreeIpaCreationRetrievalTask extends SimpleStatusCheckerTask<FreeIpaPollerObject> { @Override public boolean checkStatus(FreeIpaPollerObject freeIpaPollerObject) { String environmentCrn = freeIpaPollerObject.getEnvironmentCrn(); try { LOGGER.info("Checking the state of FreeIpa creation progress for environment: '{}'", environmentCrn); Optional<DescribeFreeIpaResponse> freeIpaOptional = freeIpaService.describe(environmentCrn); if (freeIpaOptional.isEmpty()) { throw new FreeIpaOperationFailedException("FreeIpa cluster not found for environment: " + environmentCrn); } DescribeFreeIpaResponse freeIpa = freeIpaOptional.get(); if (freeIpa.getStatus().isDeletionInProgress() || freeIpa.getStatus().isSuccessfullyDeleted()) { LOGGER.error("FreeIpa '{}' '{}' is getting terminated (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus()); throw new FreeIpaOperationFailedException("FreeIpa instance deleted under the creation process."); } if (freeIpa.getStatus().isFailed()) { LOGGER.error("FreeIpa '{}' '{}' is in failed state (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus()); throw new FreeIpaOperationFailedException(String.format("FreeIpa creation failed. Status: '%s' statusReason: '%s'", freeIpa.getStatus(), freeIpa.getStatusReason())); } if (freeIpa.getStatus().isAvailable()) { return true; } } catch (Exception e) { throw new FreeIpaOperationFailedException("FreeIpa creation operation failed. " + e.getMessage(), e); } return false; } FreeIpaCreationRetrievalTask(FreeIpaService freeIpaService); }
FreeIpaCreationRetrievalTask extends SimpleStatusCheckerTask<FreeIpaPollerObject> { @Override public boolean checkStatus(FreeIpaPollerObject freeIpaPollerObject) { String environmentCrn = freeIpaPollerObject.getEnvironmentCrn(); try { LOGGER.info("Checking the state of FreeIpa creation progress for environment: '{}'", environmentCrn); Optional<DescribeFreeIpaResponse> freeIpaOptional = freeIpaService.describe(environmentCrn); if (freeIpaOptional.isEmpty()) { throw new FreeIpaOperationFailedException("FreeIpa cluster not found for environment: " + environmentCrn); } DescribeFreeIpaResponse freeIpa = freeIpaOptional.get(); if (freeIpa.getStatus().isDeletionInProgress() || freeIpa.getStatus().isSuccessfullyDeleted()) { LOGGER.error("FreeIpa '{}' '{}' is getting terminated (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus()); throw new FreeIpaOperationFailedException("FreeIpa instance deleted under the creation process."); } if (freeIpa.getStatus().isFailed()) { LOGGER.error("FreeIpa '{}' '{}' is in failed state (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus()); throw new FreeIpaOperationFailedException(String.format("FreeIpa creation failed. Status: '%s' statusReason: '%s'", freeIpa.getStatus(), freeIpa.getStatusReason())); } if (freeIpa.getStatus().isAvailable()) { return true; } } catch (Exception e) { throw new FreeIpaOperationFailedException("FreeIpa creation operation failed. " + e.getMessage(), e); } return false; } FreeIpaCreationRetrievalTask(FreeIpaService freeIpaService); @Override boolean checkStatus(FreeIpaPollerObject freeIpaPollerObject); @Override void handleTimeout(FreeIpaPollerObject freeIpaPollerObject); @Override String successMessage(FreeIpaPollerObject freeIpaPollerObject); @Override boolean exitPolling(FreeIpaPollerObject freeIpaPollerObject); }
FreeIpaCreationRetrievalTask extends SimpleStatusCheckerTask<FreeIpaPollerObject> { @Override public boolean checkStatus(FreeIpaPollerObject freeIpaPollerObject) { String environmentCrn = freeIpaPollerObject.getEnvironmentCrn(); try { LOGGER.info("Checking the state of FreeIpa creation progress for environment: '{}'", environmentCrn); Optional<DescribeFreeIpaResponse> freeIpaOptional = freeIpaService.describe(environmentCrn); if (freeIpaOptional.isEmpty()) { throw new FreeIpaOperationFailedException("FreeIpa cluster not found for environment: " + environmentCrn); } DescribeFreeIpaResponse freeIpa = freeIpaOptional.get(); if (freeIpa.getStatus().isDeletionInProgress() || freeIpa.getStatus().isSuccessfullyDeleted()) { LOGGER.error("FreeIpa '{}' '{}' is getting terminated (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus()); throw new FreeIpaOperationFailedException("FreeIpa instance deleted under the creation process."); } if (freeIpa.getStatus().isFailed()) { LOGGER.error("FreeIpa '{}' '{}' is in failed state (status:'{}'), polling is cancelled.", freeIpa.getName(), freeIpa.getCrn(), freeIpa.getStatus()); throw new FreeIpaOperationFailedException(String.format("FreeIpa creation failed. Status: '%s' statusReason: '%s'", freeIpa.getStatus(), freeIpa.getStatusReason())); } if (freeIpa.getStatus().isAvailable()) { return true; } } catch (Exception e) { throw new FreeIpaOperationFailedException("FreeIpa creation operation failed. " + e.getMessage(), e); } return false; } FreeIpaCreationRetrievalTask(FreeIpaService freeIpaService); @Override boolean checkStatus(FreeIpaPollerObject freeIpaPollerObject); @Override void handleTimeout(FreeIpaPollerObject freeIpaPollerObject); @Override String successMessage(FreeIpaPollerObject freeIpaPollerObject); @Override boolean exitPolling(FreeIpaPollerObject freeIpaPollerObject); static final int FREEIPA_RETRYING_INTERVAL; static final int FREEIPA_RETRYING_COUNT; static final int FREEIPA_FAILURE_COUNT; }