Search in sources :

Example 11 with StackV4Endpoint

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint in project cloudbreak by hortonworks.

the class SdxDeleteServiceTest method deleteSdxClustersForEnvironmentWhenSdxIsEmptyButDatalakeNot.

@Test
void deleteSdxClustersForEnvironmentWhenSdxIsEmptyButDatalakeNot() {
    PollingConfig pollingConfig = getPollingConfig();
    EnvironmentView environment = getEnvironmentView();
    when(environmentResourceDeletionService.getAttachedSdxClusterCrns(environment)).thenReturn(emptySet());
    when(environmentResourceDeletionService.getDatalakeClusterNames(environment)).thenReturn(Set.of("name"));
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    when(stackV4Endpoint.list(anyLong(), anyString(), anyBoolean())).thenReturn(new StackViewV4Responses());
    underTest.deleteSdxClustersForEnvironment(pollingConfig, environment, true);
    verify(stackV4Endpoint).deleteInternal(eq(0L), eq("name"), eq(true), nullable(String.class));
}
Also used : EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) PollingConfig(com.sequenceiq.environment.util.PollingConfig) Test(org.junit.jupiter.api.Test)

Example 12 with StackV4Endpoint

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint in project cloudbreak by hortonworks.

the class StackAttachRecipeAction method action.

@Override
public StackTestDto action(TestContext testContext, StackTestDto testDto, CloudbreakClient client) throws Exception {
    Log.whenJson(LOGGER, " attach recipe to stack request:\n", testDto.getAttachRecipeV4Request());
    AttachRecipeV4Response response = client.getDefaultClient().stackV4Endpoint().attachRecipe(client.getWorkspaceId(), testDto.getAttachRecipeV4Request(), testDto.getName(), testContext.getActingUserCrn().getAccountId());
    Log.whenJson(LOGGER, " attach recipe to stack response:\n", response);
    return testDto;
}
Also used : AttachRecipeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recipe.AttachRecipeV4Response)

Example 13 with StackV4Endpoint

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint in project cloudbreak by hortonworks.

the class StackBlueprintRequestAction method action.

@Override
public StackTestDto action(TestContext testContext, StackTestDto testDto, CloudbreakClient client) throws Exception {
    Log.whenJson(LOGGER, " Stack get generated blueprint:\n", testDto.getRequest());
    GeneratedBlueprintV4Response bp = client.getDefaultClient().stackV4Endpoint().postStackForBlueprint(client.getWorkspaceId(), testDto.getName(), testDto.getRequest(), testContext.getActingUserCrn().getAccountId());
    testDto.withGeneratedBlueprint(bp);
    Log.whenJson(LOGGER, " get generated blueprint was successfully:\n", testDto.getGeneratedBlueprint());
    return testDto;
}
Also used : GeneratedBlueprintV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.GeneratedBlueprintV4Response)

Example 14 with StackV4Endpoint

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint in project cloudbreak by hortonworks.

the class CloudbreakUtil method waitForStatuses.

private static WaitResult waitForStatuses(CloudbreakClient cloudbreakClient, Long workspaceId, String stackName, Map<String, String> desiredStatuses, String accountId) {
    WaitResult waitResult = WaitResult.SUCCESSFUL;
    Map<String, String> currentStatuses = new HashMap<>();
    int retryCount = 0;
    do {
        LOGGER.info("Waiting for status(es) {}, stack id: {}, current status(es) {} ...", desiredStatuses, stackName, currentStatuses);
        sleep();
        StackV4Endpoint stackV4Endpoint = cloudbreakClient.stackV4Endpoint();
        try {
            StackStatusV4Response statusResult = stackV4Endpoint.getStatusByName(workspaceId, stackName, accountId);
            for (String statusPath : desiredStatuses.keySet()) {
                currentStatuses.put(statusPath, statusResult.getStatus().name());
            }
        } catch (RuntimeException ignore) {
            continue;
        }
        retryCount++;
    } while (!checkStatuses(currentStatuses, desiredStatuses) && !checkFailedStatuses(currentStatuses) && retryCount < MAX_RETRY);
    LOGGER.info("Status(es) {} for {} are in desired status(es) {}", desiredStatuses.keySet(), stackName, currentStatuses.values());
    if (currentStatuses.values().stream().anyMatch(cs -> cs.contains("FAILED")) || checkNotExpectedDelete(currentStatuses, desiredStatuses)) {
        waitResult = WaitResult.FAILED;
    }
    if (retryCount == MAX_RETRY) {
        waitResult = WaitResult.TIMEOUT;
    }
    return waitResult;
}
Also used : Arrays(java.util.Arrays) StackV4Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response) CloudbreakClient(com.sequenceiq.cloudbreak.client.CloudbreakClient) HashMap(java.util.HashMap) Value(org.springframework.beans.factory.annotation.Value) List(java.util.List) Component(org.springframework.stereotype.Component) Map(java.util.Map) Entry(java.util.Map.Entry) Collections(java.util.Collections) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) HashMap(java.util.HashMap) StackV4Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint) StackV4Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint) StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)

Aggregations

Test (org.junit.jupiter.api.Test)8 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)7 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)3 ClusterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response)2 NotFoundException (javax.ws.rs.NotFoundException)2 StackV4Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint)1 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)1 GeneratedBlueprintV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.GeneratedBlueprintV4Response)1 StackStatusV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)1 StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)1 AttachRecipeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recipe.AttachRecipeV4Response)1 RecoveryV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryV4Response)1 StackCcmUpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.StackCcmUpgradeV4Response)1 CloudbreakClient (com.sequenceiq.cloudbreak.client.CloudbreakClient)1 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)1 EnvironmentView (com.sequenceiq.environment.environment.domain.EnvironmentView)1 PollingConfig (com.sequenceiq.environment.util.PollingConfig)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1