Search in sources :

Example 1 with UpgradeCcmEvent

use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.

the class UpgradeCcmOnDatalakeHandlerTest method testAcceptWhenUpgradeSkipped.

@Test
void testAcceptWhenUpgradeSkipped() {
    SdxCcmUpgradeResponse response = new SdxCcmUpgradeResponse(CcmUpgradeResponseType.SKIP, new FlowIdentifier(FlowType.FLOW, "flowId"), "reason", "datalakeCrn");
    when(sdxService.upgradeCcm(TEST_ENV_CRN)).thenReturn(response);
    underTest.accept(mockEnvironmentDtoEvent);
    verify(sdxUpgradeCcmPollerService, never()).waitForUpgradeCcm(any(), any());
    UpgradeCcmEvent capturedUpgradeCcmEvent = (UpgradeCcmEvent) baseNamedFlowEvent.getValue();
    assertThat(capturedUpgradeCcmEvent.getResourceName()).isEqualTo(TEST_ENV_NAME);
    assertThat(capturedUpgradeCcmEvent.getResourceId()).isEqualTo(TEST_ENV_ID);
    assertThat(capturedUpgradeCcmEvent.getResourceCrn()).isEqualTo(TEST_ENV_CRN);
    assertThat(capturedUpgradeCcmEvent.selector()).isEqualTo("UPGRADE_CCM_DATAHUB_EVENT");
}
Also used : SdxCcmUpgradeResponse(com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse) UpgradeCcmEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) Test(org.junit.jupiter.api.Test)

Example 2 with UpgradeCcmEvent

use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.

the class UpgradeCcmOnDatalakeHandlerTest method testAcceptWhenUpgradeTriggered.

@Test
void testAcceptWhenUpgradeTriggered() {
    SdxCcmUpgradeResponse response = new SdxCcmUpgradeResponse(CcmUpgradeResponseType.TRIGGERED, new FlowIdentifier(FlowType.FLOW, "flowId"), "reason", "datalakeCrn");
    when(sdxService.upgradeCcm(TEST_ENV_CRN)).thenReturn(response);
    underTest.accept(mockEnvironmentDtoEvent);
    verify(sdxUpgradeCcmPollerService).waitForUpgradeCcm(TEST_ENV_ID, "datalakeCrn");
    UpgradeCcmEvent capturedUpgradeCcmEvent = (UpgradeCcmEvent) baseNamedFlowEvent.getValue();
    assertThat(capturedUpgradeCcmEvent.getResourceName()).isEqualTo(TEST_ENV_NAME);
    assertThat(capturedUpgradeCcmEvent.getResourceId()).isEqualTo(TEST_ENV_ID);
    assertThat(capturedUpgradeCcmEvent.getResourceCrn()).isEqualTo(TEST_ENV_CRN);
    assertThat(capturedUpgradeCcmEvent.selector()).isEqualTo("UPGRADE_CCM_DATAHUB_EVENT");
}
Also used : SdxCcmUpgradeResponse(com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse) UpgradeCcmEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) Test(org.junit.jupiter.api.Test)

Example 3 with UpgradeCcmEvent

use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.

the class UpgradeCcmOnFreeIpaHandlerTest method testFreeIpaAcceptedStatuses.

@ParameterizedTest
@EnumSource(value = Status.class, names = { "AVAILABLE", "UPGRADE_CCM_FAILED" }, mode = EnumSource.Mode.INCLUDE)
void testFreeIpaAcceptedStatuses(Status status) {
    DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
    freeipa.setStatus(status);
    freeipa.setAvailabilityStatus(AvailabilityStatus.AVAILABLE);
    Optional<DescribeFreeIpaResponse> freeipaOpt = Optional.of(freeipa);
    when(freeIpaService.describe(any())).thenReturn(freeipaOpt);
    underTest.accept(mockEnvironmentDtoEvent);
    verify(freeIpaPollerService).waitForCcmUpgrade(TEST_ENV_ID, TEST_ENV_CRN);
    UpgradeCcmEvent capturedUpgradeCcmEvent = (UpgradeCcmEvent) baseNamedFlowEvent.getValue();
    assertThat(capturedUpgradeCcmEvent.getResourceName()).isEqualTo(TEST_ENV_NAME);
    assertThat(capturedUpgradeCcmEvent.getResourceId()).isEqualTo(TEST_ENV_ID);
    assertThat(capturedUpgradeCcmEvent.getResourceCrn()).isEqualTo(TEST_ENV_CRN);
    assertThat(capturedUpgradeCcmEvent.selector()).isEqualTo("UPGRADE_CCM_TUNNEL_UPDATE_EVENT");
}
Also used : UpgradeCcmEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent) DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with UpgradeCcmEvent

use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.

the class UpgradeCcmTunnelUpdateHandlerTest method accept.

@Test
void accept() {
    underTest.accept(mockEnvironmentDtoEvent);
    verify(environmentService).updateTunnelByEnvironmentId(TEST_ENV_ID, Tunnel.latestUpgradeTarget());
    UpgradeCcmEvent capturedUpgradeCcmEvent = (UpgradeCcmEvent) baseNamedFlowEvent.getValue();
    assertThat(capturedUpgradeCcmEvent.getResourceName()).isEqualTo(TEST_ENV_NAME);
    assertThat(capturedUpgradeCcmEvent.getResourceId()).isEqualTo(TEST_ENV_ID);
    assertThat(capturedUpgradeCcmEvent.getResourceCrn()).isEqualTo(TEST_ENV_CRN);
    assertThat(capturedUpgradeCcmEvent.selector()).isEqualTo("UPGRADE_CCM_DATALAKE_EVENT");
}
Also used : UpgradeCcmEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent) Test(org.junit.jupiter.api.Test)

Example 5 with UpgradeCcmEvent

use of com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent in project cloudbreak by hortonworks.

the class UpgradeCcmActionsTest method setUp.

@BeforeEach
void setUp() {
    FlowParameters flowParameters = new FlowParameters(FLOW_ID, FLOW_TRIGGER_USER_CRN, null);
    when(stateContext.getMessageHeader(MessageFactory.HEADERS.FLOW_PARAMETERS.name())).thenReturn(flowParameters);
    actionPayload = new UpgradeCcmEvent(ACTION_PAYLOAD_SELECTOR, ENVIRONMENT_ID, ENVIRONMENT_NAME, ENVIRONMENT_CRN);
    when(stateContext.getMessageHeader(MessageFactory.HEADERS.DATA.name())).thenReturn(actionPayload);
    when(stateContext.getExtendedState()).thenReturn(extendedState);
    when(extendedState.getVariables()).thenReturn(new HashMap<>());
    when(stateContext.getStateMachine()).thenReturn(stateMachine);
    when(stateMachine.getState()).thenReturn(state);
    lenient().when(reactorEventFactory.createEvent(anyMap(), isNotNull())).thenReturn(event);
    when(stateContext.getEvent()).thenReturn(flowEvent);
    when(tracer.buildSpan(anyString())).thenReturn(spanBuilder);
    when(spanBuilder.addReference(anyString(), any())).thenReturn(spanBuilder);
    when(spanBuilder.ignoreActiveSpan()).thenReturn(spanBuilder);
    when(spanBuilder.start()).thenReturn(span);
    when(tracer.activateSpan(span)).thenReturn(scope);
    when(span.context()).thenReturn(spanContext);
    when(flowEvent.name()).thenReturn("eventName");
}
Also used : UpgradeCcmEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent) FlowParameters(com.sequenceiq.flow.core.FlowParameters) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

UpgradeCcmEvent (com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent)17 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)11 CommonContext (com.sequenceiq.flow.core.CommonContext)6 Map (java.util.Map)6 Bean (org.springframework.context.annotation.Bean)6 UpgradeCcmFailedEvent (com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent)4 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)3 SdxCcmUpgradeResponse (com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse)3 Test (org.junit.jupiter.api.Test)3 OperationException (com.sequenceiq.cloudbreak.service.OperationException)1 EnvStackConfigUpdatesEvent (com.sequenceiq.environment.environment.flow.config.update.event.EnvStackConfigUpdatesEvent)1 EnvCreationEvent (com.sequenceiq.environment.environment.flow.creation.event.EnvCreationEvent)1 EnvDeleteEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent)1 LoadBalancerUpdateEvent (com.sequenceiq.environment.environment.flow.loadbalancer.event.LoadBalancerUpdateEvent)1 EnvStartEvent (com.sequenceiq.environment.environment.flow.start.event.EnvStartEvent)1 EnvStopEvent (com.sequenceiq.environment.environment.flow.stop.event.EnvStopEvent)1 FreeIpaOperationFailedException (com.sequenceiq.environment.exception.FreeIpaOperationFailedException)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1