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());
}
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());
}
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());
}
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");
}
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");
}
Aggregations