Search in sources :

Example 31 with FlowIdentifier

use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.

the class StackScalePostAction method action.

@Override
public StackTestDto action(TestContext testContext, StackTestDto testDto, CloudbreakClient client) throws Exception {
    Log.when(LOGGER, String.format("Stack scale request on: %s. Hostgroup: %s, desiredCount: %d", testDto.getName(), request.getGroup(), request.getDesiredCount()));
    Log.whenJson(LOGGER, " Stack scale request: ", testDto.getRequest());
    FlowIdentifier flowIdentifier = client.getDefaultClient().stackV4Endpoint().putScaling(client.getWorkspaceId(), testDto.getName(), request, testContext.getActingUserCrn().getAccountId());
    testDto.setFlow("Stack scale", flowIdentifier);
    StackV4Response stackV4Response = client.getDefaultClient().stackV4Endpoint().get(client.getWorkspaceId(), testDto.getName(), new HashSet<>(), testContext.getActingUserCrn().getAccountId());
    testDto.setResponse(stackV4Response);
    Log.whenJson(LOGGER, " Stack scale response: ", stackV4Response);
    LOGGER.info("Hardware info for stack after upscale: {}", stackV4Response.getHardwareInfoGroups());
    return testDto;
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Example 32 with FlowIdentifier

use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.

the class SdxRetryAction method action.

@Override
public SdxInternalTestDto action(TestContext testContext, SdxInternalTestDto testDto, SdxClient sdxClient) throws Exception {
    FlowIdentifier flowIdentifier = sdxClient.getDefaultClient().sdxEndpoint().retryByCrn(testDto.getCrn());
    testDto.setFlow("Retry", flowIdentifier);
    return testDto;
}
Also used : FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Example 33 with FlowIdentifier

use of com.sequenceiq.flow.api.model.FlowIdentifier 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 34 with FlowIdentifier

use of com.sequenceiq.flow.api.model.FlowIdentifier 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 35 with FlowIdentifier

use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.

the class FreeIpaScalingServiceTest method testUpscaleIfValidationPassesAndOperationRunningThenSucceed.

@Test
public void testUpscaleIfValidationPassesAndOperationRunningThenSucceed() {
    Stack stack = mock(Stack.class);
    Set<InstanceMetaData> allInstances = createValidImSet();
    Operation operation = createOperation(true);
    when(stack.getAccountId()).thenReturn(ACCOUNT_ID);
    when(stackService.getByEnvironmentCrnAndAccountIdWithListsAndMdcContext(ENV_CRN, ACCOUNT_ID)).thenReturn(stack);
    when(operationService.startOperation(ACCOUNT_ID, OperationType.UPSCALE, List.of(ENV_CRN), List.of())).thenReturn(operation);
    when(stack.getNotDeletedInstanceMetaDataSet()).thenReturn(allInstances);
    FlowIdentifier flowIdentifier = new FlowIdentifier(FlowType.FLOW, POLLABLE_ID);
    when(flowManager.notify(anyString(), any())).thenReturn(flowIdentifier);
    UpscaleRequest request = createUpscaleRequest();
    UpscaleResponse response = underTest.upscale(ACCOUNT_ID, request);
    assertEquals(response.getOperationId(), OPERATION_ID);
    assertEquals(response.getOriginalAvailabilityType(), AvailabilityType.TWO_NODE_BASED);
    assertEquals(response.getTargetAvailabilityType(), AvailabilityType.HA);
    assertEquals(response.getFlowIdentifier(), flowIdentifier);
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) UpscaleRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.UpscaleRequest) UpscaleResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.scale.UpscaleResponse) Operation(com.sequenceiq.freeipa.entity.Operation) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)150 Test (org.junit.jupiter.api.Test)55 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)37 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)18 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)15 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)14 SdxClusterDetailResponse (com.sequenceiq.sdx.api.model.SdxClusterDetailResponse)14 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)13 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)13 SdxClusterRequest (com.sequenceiq.sdx.api.model.SdxClusterRequest)10 Supplier (java.util.function.Supplier)10 ImageChangeDto (com.sequenceiq.cloudbreak.service.image.ImageChangeDto)9 Status (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)7 StackImageChangeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackImageChangeV4Request)7 ImageInfoV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response)7 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)7 TransactionService (com.sequenceiq.cloudbreak.common.service.TransactionService)7 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)7 CloudbreakApiException (com.sequenceiq.cloudbreak.exception.CloudbreakApiException)7