Search in sources :

Example 1 with SdxCcmUpgradeResponse

use of com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse in project cloudbreak by hortonworks.

the class SdxCcmUpgradeServiceTest method testNotAvailableError.

@Test
void testNotAvailableError() {
    SdxCluster sdxCluster = getSdxCluster();
    when(sdxService.listSdxByEnvCrn(anyString())).thenReturn(List.of(sdxCluster));
    when(sdxService.getAccountIdFromCrn(any())).thenReturn(ACCOUNT_ID);
    when(sdxService.getDetail(CLUSTER_NAME, null, ACCOUNT_ID)).thenReturn(getStack(Tunnel.CCM, Status.STOPPED));
    when(messagesService.getMessage(any())).thenReturn("unavailable");
    SdxCcmUpgradeResponse response = underTest.upgradeCcm(ENV_CRN);
    assertThat(response.getReason()).isEqualTo("unavailable");
    assertThat(response.getFlowIdentifier()).isEqualTo(FlowIdentifier.notTriggered());
}
Also used : SdxCcmUpgradeResponse(com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with SdxCcmUpgradeResponse

use of com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse in project cloudbreak by hortonworks.

the class SdxCcmUpgradeServiceTest method testNoDatalakeForEnv.

@Test
void testNoDatalakeForEnv() {
    when(sdxService.listSdxByEnvCrn(anyString())).thenReturn(List.of());
    when(messagesService.getMessage(any(), any())).thenReturn("no datalake");
    SdxCcmUpgradeResponse response = underTest.upgradeCcm(ENV_CRN);
    assertThat(response.getReason()).isEqualTo("no datalake");
    assertThat(response.getFlowIdentifier()).isEqualTo(FlowIdentifier.notTriggered());
}
Also used : SdxCcmUpgradeResponse(com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with SdxCcmUpgradeResponse

use of com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse in project cloudbreak by hortonworks.

the class SdxCcmUpgradeServiceTest method testLatestSkipUpgrade.

@Test
void testLatestSkipUpgrade() {
    SdxCluster sdxCluster = getSdxCluster();
    when(sdxService.listSdxByEnvCrn(anyString())).thenReturn(List.of(sdxCluster));
    when(sdxService.getAccountIdFromCrn(any())).thenReturn(ACCOUNT_ID);
    when(sdxService.getDetail(CLUSTER_NAME, null, ACCOUNT_ID)).thenReturn(getStack(Tunnel.CCMV2_JUMPGATE, Status.AVAILABLE));
    when(messagesService.getMessage(any())).thenReturn("latest");
    SdxCcmUpgradeResponse response = underTest.upgradeCcm(ENV_CRN);
    assertThat(response.getReason()).isEqualTo("latest");
    assertThat(response.getFlowIdentifier()).isEqualTo(FlowIdentifier.notTriggered());
}
Also used : SdxCcmUpgradeResponse(com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with SdxCcmUpgradeResponse

use of com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse 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 5 with SdxCcmUpgradeResponse

use of com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse 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)

Aggregations

SdxCcmUpgradeResponse (com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse)11 Test (org.junit.jupiter.api.Test)8 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)4 UpgradeCcmEvent (com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent)3 OperationException (com.sequenceiq.cloudbreak.service.OperationException)1 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)1 UpgradeCcmFailedEvent (com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1