use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class LoggingAgentAutoRestartPatchServiceTest method testIsAffectedByDate.
@Test
public void testIsAffectedByDate() throws Exception {
// GIVEN
Stack stack = createStack();
Image image = mock(Image.class);
ImageCatalog imageCatalog = mock(ImageCatalog.class);
StatedImage statedImageMock = mock(StatedImage.class);
com.sequenceiq.cloudbreak.cloud.model.catalog.Image imageFromStated = mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class);
given(image.getPackageVersions()).willReturn(new HashMap<>());
given(stackImageService.getCurrentImage(stack)).willReturn(image);
given(stackImageService.getImageCatalogFromStackAndImage(any(), any())).willReturn(imageCatalog);
given(stackImageService.getStatedImageInternal(any(Stack.class), any(Image.class), any(ImageCatalog.class))).willReturn(Optional.of(statedImageMock));
given(statedImageMock.getImage()).willReturn(imageFromStated);
long sampleTimestamp = underTest.dateStringToTimestampForImage("2022-01-10");
given(imageFromStated.getCreated()).willReturn(sampleTimestamp);
initIsAffectedMocks();
// WHEN
underTest.init();
boolean result = underTest.isAffected(stack);
// THEN
assertTrue(result);
}
use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class MeteringAzureMetadataPatchServiceTest method testIsNotAffectedByDate.
@Test
public void testIsNotAffectedByDate() throws Exception {
// GIVEN
Stack stack = createStack();
StatedImage statedImageMock = mock(StatedImage.class);
Image imageFromStated = mock(Image.class);
given(stackImageService.getStatedImageInternal(stack)).willReturn(Optional.of(statedImageMock));
given(statedImageMock.getImage()).willReturn(imageFromStated);
given(meteringAzureMetadataPatchConfig.getDateBefore()).willReturn(DATE_SAMPLE);
long sampleTimestamp = underTest.dateStringToTimestampForImage("2022-02-02");
given(imageFromStated.getCreated()).willReturn(sampleTimestamp);
// WHEN
boolean result = underTest.isAffected(stack);
// THEN
assertFalse(result);
}
use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class UpgradeImageInfoFactory method create.
public UpgradeImageInfo create(String targetImageId, Long stackId) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
Image currentImage = componentConfigProviderService.getImage(stackId);
StatedImage currentStatedImage = imageCatalogService.getImage(currentImage.getImageCatalogUrl(), currentImage.getImageCatalogName(), currentImage.getImageId());
StatedImage targetStatedImage = imageCatalogService.getImage(currentImage.getImageCatalogUrl(), currentImage.getImageCatalogName(), targetImageId);
UpgradeImageInfo upgradeImageInfo = new UpgradeImageInfo(currentImage, currentStatedImage, targetStatedImage);
LOGGER.debug("Provided upgradeImageInfo values to create UpgradeImageInfo: {}", upgradeImageInfo);
return upgradeImageInfo;
}
use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class MaintenanceModeValidationService method validateImageCatalog.
public List<Warning> validateImageCatalog(Stack stack) {
List<Warning> warnings = new ArrayList<>();
try {
Image image = componentConfigProviderService.getImage(stack.getId());
StatedImage statedImage = imageCatalogService.getImage(image.getImageCatalogUrl(), image.getImageCatalogName(), image.getImageId());
if (!image.getPackageVersions().isEmpty()) {
CheckResult checkResult = stackImageUpdateService.checkPackageVersions(stack, statedImage);
if (checkResult.getStatus().equals(EventStatus.FAILED)) {
warnings.add(new Warning(WarningType.IMAGE_INCOMPATIBILITY_WARNING, checkResult.getMessage()));
}
}
} catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) {
throw new CloudbreakServiceException("Image info could not be validated!", e);
}
return warnings;
}
use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class ClusterUpgradeActions method clusterUpgradeFinished.
@Bean(name = "CLUSTER_UPGRADE_FINISHED_STATE")
public Action<?, ?> clusterUpgradeFinished() {
return new AbstractClusterUpgradeAction<>(ClusterUpgradeSuccess.class) {
@Inject
private StackImageService stackImageService;
@Override
protected ClusterUpgradeContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, ClusterUpgradeSuccess payload) {
return ClusterUpgradeContext.from(flowParameters, payload);
}
@Override
protected void doExecute(ClusterUpgradeContext context, ClusterUpgradeSuccess payload, Map<Object, Object> variables) {
StatedImage currentImage = getCurrentImage(variables);
StatedImage targetImage = getTargetImage(variables);
clusterUpgradeService.clusterUpgradeFinished(context.getStackId(), currentImage, targetImage);
stackImageService.removeImageByComponentName(context.getStackId(), TARGET_IMAGE);
sendEvent(context);
}
@Override
protected Selectable createRequest(ClusterUpgradeContext context) {
return new StackEvent(ClusterUpgradeEvent.CLUSTER_UPGRADE_FINALIZED_EVENT.event(), context.getStackId());
}
@Override
protected Object getFailurePayload(ClusterUpgradeSuccess payload, Optional<ClusterUpgradeContext> flowContext, Exception ex) {
return null;
}
};
}
Aggregations