use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class StackImageUpdateActionsTest method checkPackageVersionsNotOk.
@Test
public void checkPackageVersionsNotOk() {
FlowEvent flowEvent = Mockito.mock(FlowEvent.class);
when(stateContext.getEvent()).thenReturn(flowEvent);
when(flowEvent.name()).thenReturn(EVENT_NAME);
ImageUpdateEvent payload = new ImageUpdateEvent(StackImageUpdateEvent.CHECK_IMAGE_VERESIONS_FINISHED_EVENT.event(), 1L, statedImage);
when(stateContext.getMessageHeader(HEADERS.DATA.name())).thenReturn(payload);
when(state.getId()).thenReturn(StackImageUpdateState.CHECK_PACKAGE_VERSIONS_STATE);
when(stackImageUpdateService.checkPackageVersions(any(Stack.class), any(StatedImage.class))).thenReturn(CheckResult.failed(""));
checkPackageVersionsAction.setFailureEvent(StackImageUpdateEvent.STACK_IMAGE_UPDATE_FAILED_EVENT);
checkPackageVersionsAction.execute(stateContext);
verify(stackImageUpdateService, times(1)).checkPackageVersions(any(Stack.class), any(StatedImage.class));
verify(eventBus, times(1)).notify(eq(StackImageUpdateEvent.CHECK_PACKAGE_VERSIONS_FINISHED_EVENT.event()), any(Event.class));
verify(eventBus, times(0)).notify(eq(StackImageUpdateEvent.STACK_IMAGE_UPDATE_FAILED_EVENT.event()), any(Event.class));
}
use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class StackImageUpdateServiceTest method testOsCheckFailedThenResultShouldNotBeSkipped.
@Test
public void testOsCheckFailedThenResultShouldNotBeSkipped() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
com.sequenceiq.cloudbreak.cloud.model.Image imageInComponent = new com.sequenceiq.cloudbreak.cloud.model.Image("imageOldName", Collections.emptyMap(), "redhat7", "redhat", statedImage.getImageCatalogUrl(), statedImage.getImageCatalogName(), "uuid2", packageVersions);
CloudbreakDetails cloudbreakDetails = new CloudbreakDetails();
cloudbreakDetails.setVersion(StackImageUpdateService.MIN_VERSION);
when(componentConfigProviderService.getCloudbreakDetails(stack.getId())).thenReturn(cloudbreakDetails);
when(stackImageService.getCurrentImage(stack)).thenReturn(imageInComponent);
when(imageCatalogService.getImage(anyString(), anyString(), anyString())).thenReturn(statedImage);
when(packageVersionChecker.checkInstancesHaveAllMandatoryPackageVersion(anySet())).thenReturn(CheckResult.ok());
boolean validImage = underTest.isValidImage(stack, "imageId", "imageCatalogName", "imageCatalogUrl");
assertFalse(validImage);
}
use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class StackImageUpdateServiceTest method testIsValidImageFalse.
@Test
public void testIsValidImageFalse() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
com.sequenceiq.cloudbreak.cloud.model.Image imageInComponent = new com.sequenceiq.cloudbreak.cloud.model.Image("imageOldName", Collections.emptyMap(), "centos6", "centos", statedImage.getImageCatalogUrl(), statedImage.getImageCatalogName(), "uuid2", packageVersions);
when(stackImageService.getCurrentImage(stack)).thenReturn(imageInComponent);
when(imageCatalogService.getImage(anyString(), anyString(), anyString())).thenReturn(statedImage);
CloudbreakDetails cloudbreakDetails = new CloudbreakDetails();
cloudbreakDetails.setVersion("2.4.0");
when(componentConfigProviderService.getCloudbreakDetails(stack.getId())).thenReturn(cloudbreakDetails);
boolean validImage = underTest.isValidImage(stack, "imageId", "imageCatalogName", "imageCatalogUrl");
assertFalse(validImage);
}
use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class StackImageUpdateServiceTest method testPackageVersionCheckerFailedThenResultShouldBeSkipped.
@Test
public void testPackageVersionCheckerFailedThenResultShouldBeSkipped() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
com.sequenceiq.cloudbreak.cloud.model.Image imageInComponent = new com.sequenceiq.cloudbreak.cloud.model.Image("imageOldName", Collections.emptyMap(), "centos7", "centos", statedImage.getImageCatalogUrl(), statedImage.getImageCatalogName(), "uuid2", packageVersions);
CloudbreakDetails cloudbreakDetails = new CloudbreakDetails();
cloudbreakDetails.setVersion(StackImageUpdateService.MIN_VERSION);
when(componentConfigProviderService.getCloudbreakDetails(stack.getId())).thenReturn(cloudbreakDetails);
when(stackImageService.getCurrentImage(stack)).thenReturn(imageInComponent);
when(imageCatalogService.getImage(anyString(), anyString(), anyString())).thenReturn(statedImage);
when(packageVersionChecker.checkInstancesHaveAllMandatoryPackageVersion(anySet())).thenReturn(CheckResult.failed("Instance ID: instance-id Packages without version: salt"));
boolean validImage = underTest.isValidImage(stack, "imageId", "imageCatalogName", "imageCatalogUrl");
assertTrue(validImage);
}
use of com.sequenceiq.cloudbreak.service.image.StatedImage in project cloudbreak by hortonworks.
the class ClusterUpgradeServiceTest method testClusterUpgradeFinishedWhenNeeded.
@ParameterizedTest
@MethodSource("upgradeNeededVersions")
public void testClusterUpgradeFinishedWhenNeeded(String currentStackVersion, String targetStackVersion) {
// GIVEN
Image currentImmage = createImage(CURRENT_BUILD_NUMBER, currentStackVersion);
StatedImage currentImage = StatedImage.statedImage(currentImmage, null, null);
Image targetImmage = createImage(CURRENT_BUILD_NUMBER, targetStackVersion);
StatedImage targetImage = StatedImage.statedImage(targetImmage, null, null);
// WHEN
underTest.clusterUpgradeFinished(STACK_ID, currentImage, targetImage);
// THEN
verify(flowMessageService).fireEventAndLog(STACK_ID, Status.AVAILABLE.name(), CLUSTER_UPGRADE_FINISHED, V_7_0_2);
}
Aggregations