use of com.sequenceiq.flow.core.FlowEvent in project cloudbreak by hortonworks.
the class StackImageUpdateActionsTest method handleImageUpdateFailure.
@Test
public void handleImageUpdateFailure() {
FlowEvent flowEvent = Mockito.mock(FlowEvent.class);
when(stateContext.getEvent()).thenReturn(flowEvent);
when(flowEvent.name()).thenReturn(EVENT_NAME);
StackFailureEvent payload = new StackFailureEvent(StackImageUpdateEvent.STACK_IMAGE_UPDATE_FAILED_EVENT.event(), 1L, new CloudbreakServiceException("test"));
when(stateContext.getMessageHeader(HEADERS.DATA.name())).thenReturn(payload);
when(state.getId()).thenReturn(StackImageUpdateState.STACK_IMAGE_UPDATE_FAILED_STATE);
when(stackService.getViewByIdWithoutAuth(anyLong())).thenReturn(new StackView(1L, null, null, null));
when(runningFlows.get(anyString())).thenReturn(flow);
handleImageUpdateFailureAction.execute(stateContext);
verify(flowMessageService, times(1)).fireEventAndLog(anyLong(), eq(Status.UPDATE_FAILED.name()), eq(ResourceEvent.STACK_IMAGE_UPDATE_FAILED), eq("test"));
verify(eventBus, times(1)).notify(eq(StackImageUpdateEvent.STACK_IMAGE_UPDATE_FAILE_HANDLED_EVENT.event()), any(Event.class));
verify(stackUpdater).updateStackStatus(eq(1L), eq(DetailedStackStatus.STACK_IMAGE_UPDATE_FAILED), eq("test"));
verifyNoInteractions(componentConfigProviderService);
}
use of com.sequenceiq.flow.core.FlowEvent in project cloudbreak by hortonworks.
the class StackImageUpdateActionsTest method checkImageVersion.
@Test
public void checkImageVersion() {
FlowEvent flowEvent = Mockito.mock(FlowEvent.class);
when(stateContext.getEvent()).thenReturn(flowEvent);
when(flowEvent.name()).thenReturn(EVENT_NAME);
StackImageUpdateTriggerEvent payload = new StackImageUpdateTriggerEvent(StackImageUpdateEvent.STACK_IMAGE_UPDATE_EVENT.event(), 1L, "imageId");
when(stateContext.getMessageHeader(HEADERS.DATA.name())).thenReturn(payload);
when(state.getId()).thenReturn(StackImageUpdateState.CHECK_IMAGE_VERSIONS_STATE);
when(stackImageUpdateService.isCbVersionOk(any(Stack.class))).thenReturn(true);
checkImageAction.execute(stateContext);
verify(flowMessageService, times(1)).fireEventAndLog(anyLong(), eq(Status.UPDATE_IN_PROGRESS.name()), eq(ResourceEvent.STACK_IMAGE_UPDATE_STARTED));
verify(stackImageUpdateService, times(1)).getNewImageIfVersionsMatch(any(Stack.class), anyString(), eq(null), eq(null));
verify(eventBus, times(1)).notify(eq(StackImageUpdateEvent.CHECK_IMAGE_VERESIONS_FINISHED_EVENT.event()), any(Event.class));
}
use of com.sequenceiq.flow.core.FlowEvent in project cloudbreak by hortonworks.
the class StackImageUpdateActionsTest method checkPackageVersions.
@Test
public void checkPackageVersions() {
FlowEvent flowEvent = Mockito.mock(FlowEvent.class);
when(stateContext.getEvent()).thenReturn(flowEvent);
when(flowEvent.name()).thenReturn(EVENT_NAME);
ImageUpdateEvent payload = new ImageUpdateEvent(StackImageUpdateEvent.STACK_IMAGE_UPDATE_EVENT.event(), 1L, statedImage);
when(stateContext.getMessageHeader(HEADERS.DATA.name())).thenReturn(payload);
when(state.getId()).thenReturn(StackImageUpdateState.CHECK_IMAGE_VERSIONS_STATE);
when(stackImageUpdateService.checkPackageVersions(any(Stack.class), any(StatedImage.class))).thenReturn(CheckResult.ok());
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));
}
use of com.sequenceiq.flow.core.FlowEvent in project cloudbreak by hortonworks.
the class StackImageUpdateActionsTest method setImageAction.
@Test
public void setImageAction() {
FlowEvent flowEvent = Mockito.mock(FlowEvent.class);
when(stateContext.getEvent()).thenReturn(flowEvent);
when(flowEvent.name()).thenReturn(EVENT_NAME);
Stack stack = new Stack();
StackEvent payload = new StackEvent(StackImageUpdateEvent.UPDATE_IMAGE_FINESHED_EVENT.event(), 1L);
when(stateContext.getMessageHeader(HEADERS.DATA.name())).thenReturn(payload);
when(state.getId()).thenReturn(StackImageUpdateState.SET_IMAGE_STATE);
when(resourceService.getAllByStackId(anyLong())).thenReturn(Collections.singletonList(new Resource(ResourceType.CLOUDFORMATION_STACK, "cf", stack, "az1")));
when(resourceToCloudResourceConverter.convert(any(Resource.class))).thenReturn(CloudResource.builder().type(ResourceType.CLOUDFORMATION_STACK).name("cfresource").build());
setImageAction.execute(stateContext);
verify(eventBus, times(1)).notify(eq(CloudPlatformRequest.selector(UpdateImageRequest.class)), any(Event.class));
}
use of com.sequenceiq.flow.core.FlowEvent in project cloudbreak by hortonworks.
the class StackImageUpdateActionsTest method updateImage.
@Test
public void updateImage() {
FlowEvent flowEvent = Mockito.mock(FlowEvent.class);
when(stateContext.getEvent()).thenReturn(flowEvent);
when(flowEvent.name()).thenReturn(EVENT_NAME);
ImageUpdateEvent payload = new ImageUpdateEvent(StackImageUpdateEvent.CHECK_PACKAGE_VERSIONS_FINISHED_EVENT.event(), 1L, statedImage);
when(stateContext.getMessageHeader(HEADERS.DATA.name())).thenReturn(payload);
when(state.getId()).thenReturn(StackImageUpdateState.UPDATE_IMAGE_STATE);
updateImageAction.execute(stateContext);
verify(stackImageService, times(1)).storeNewImageComponent(any(Stack.class), any(StatedImage.class));
verify(eventBus, times(1)).notify(eq(StackImageUpdateEvent.UPDATE_IMAGE_FINESHED_EVENT.event()), any(Event.class));
assertTrue(variables.containsKey(AbstractStackImageUpdateAction.ORIGINAL_IMAGE));
}
Aggregations