Search in sources :

Example 31 with StatedImage

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));
}
Also used : FlowEvent(com.sequenceiq.flow.core.FlowEvent) FlowEvent(com.sequenceiq.flow.core.FlowEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Event(reactor.bus.Event) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) ImageUpdateEvent(com.sequenceiq.cloudbreak.reactor.api.event.stack.ImageUpdateEvent) StackImageUpdateTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackImageUpdateTriggerEvent) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) ImageUpdateEvent(com.sequenceiq.cloudbreak.reactor.api.event.stack.ImageUpdateEvent) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Example 32 with StatedImage

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);
}
Also used : CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.Test)

Example 33 with StatedImage

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);
}
Also used : CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.Test)

Example 34 with StatedImage

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);
}
Also used : CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.Test)

Example 35 with StatedImage

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);
}
Also used : StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)48 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)19 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)12 Test (org.junit.Test)12 Image (com.sequenceiq.cloudbreak.cloud.model.Image)11 Test (org.junit.jupiter.api.Test)10 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)9 Json (com.sequenceiq.cloudbreak.common.json.Json)7 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)7 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)7 CheckResult (com.sequenceiq.cloudbreak.core.flow2.CheckResult)6 Map (java.util.Map)6 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 CloudbreakDetails (com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails)4 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)4 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)4 StackImageUpdateTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackImageUpdateTriggerEvent)3 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)3 ImageUpdateEvent (com.sequenceiq.cloudbreak.reactor.api.event.stack.ImageUpdateEvent)3