Search in sources :

Example 11 with StackV4Response

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

the class DiagnosticsCollectionValidatorTest method testWithValidEngDestination.

@Test
void testWithValidEngDestination() {
    BaseDiagnosticsCollectionRequest request = new BaseDiagnosticsCollectionRequest();
    request.setDestination(DiagnosticsDestination.ENG);
    StackV4Response stackV4Response = new StackV4Response();
    stackV4Response.setCrn(DATALAKE_CRN);
    TelemetryResponse telemetry = new TelemetryResponse();
    FeaturesResponse features = new FeaturesResponse();
    FeatureSetting featureSetting = new FeatureSetting();
    featureSetting.setEnabled(true);
    features.setClusterLogsCollection(featureSetting);
    telemetry.setFeatures(features);
    stackV4Response.setTelemetry(telemetry);
    underTest.validate(request, stackV4Response);
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) BaseDiagnosticsCollectionRequest(com.sequenceiq.common.api.diagnostics.BaseDiagnosticsCollectionRequest) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) FeaturesResponse(com.sequenceiq.common.api.telemetry.response.FeaturesResponse) FeatureSetting(com.sequenceiq.common.api.type.FeatureSetting) Test(org.junit.jupiter.api.Test)

Example 12 with StackV4Response

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

the class DiagnosticsCollectionValidatorTest method testWithCloudStorageWithDisabledLogging.

@Test
void testWithCloudStorageWithDisabledLogging() {
    BaseDiagnosticsCollectionRequest request = new BaseDiagnosticsCollectionRequest();
    request.setDestination(DiagnosticsDestination.CLOUD_STORAGE);
    StackV4Response stackV4Response = new StackV4Response();
    stackV4Response.setCrn(DATALAKE_CRN);
    TelemetryResponse telemetry = new TelemetryResponse();
    stackV4Response.setTelemetry(telemetry);
    BadRequestException thrown = assertThrows(BadRequestException.class, () -> underTest.validate(request, stackV4Response));
    assertTrue(thrown.getMessage().contains("Cloud storage logging is disabled for Data Lake"));
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) BaseDiagnosticsCollectionRequest(com.sequenceiq.common.api.diagnostics.BaseDiagnosticsCollectionRequest) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Test(org.junit.jupiter.api.Test)

Example 13 with StackV4Response

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

the class DiagnosticsCollectionValidatorTest method testWithEngDestinationAndDisabledLogCollection.

@Test
void testWithEngDestinationAndDisabledLogCollection() {
    BaseDiagnosticsCollectionRequest request = new BaseDiagnosticsCollectionRequest();
    request.setDestination(DiagnosticsDestination.ENG);
    StackV4Response stackV4Response = new StackV4Response();
    stackV4Response.setCrn(DATALAKE_CRN);
    TelemetryResponse telemetry = new TelemetryResponse();
    stackV4Response.setTelemetry(telemetry);
    BadRequestException thrown = assertThrows(BadRequestException.class, () -> underTest.validate(request, stackV4Response));
    assertTrue(thrown.getMessage().contains("Cluster log collection is not enabled for Data Lake"));
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) BaseDiagnosticsCollectionRequest(com.sequenceiq.common.api.diagnostics.BaseDiagnosticsCollectionRequest) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Test(org.junit.jupiter.api.Test)

Example 14 with StackV4Response

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

the class DistroXCreateAction method action.

@Override
public DistroXTestDto action(TestContext testContext, DistroXTestDto testDto, CloudbreakClient client) throws Exception {
    if (StringUtils.isEmpty(testDto.getRequest().getEnvironmentName())) {
        Log.when(LOGGER, " Env name cannot be null ");
        throw new TestFailException("Env name cannot be null");
    }
    Log.whenJson(LOGGER, " Distrox create request: ", testDto.getRequest());
    StackV4Response stackV4Response = client.getDefaultClient().distroXV1Endpoint().post(testDto.getRequest());
    testDto.setFlow("Distrox create", stackV4Response.getFlowIdentifier());
    testDto.setResponse(stackV4Response);
    Log.whenJson(LOGGER, " Distrox create response: ", stackV4Response);
    return testDto;
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 15 with StackV4Response

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

the class DistroXRemoveInstancesAction method action.

@Override
public DistroXTestDto action(TestContext testContext, DistroXTestDto testDto, CloudbreakClient client) throws Exception {
    List<String> removableInstanceIds = testDto.getInstanceIdsForAction();
    if (!removableInstanceIds.isEmpty()) {
        MultipleInstanceDeleteRequest instanceDeleteRequest = new MultipleInstanceDeleteRequest();
        instanceDeleteRequest.setInstances(removableInstanceIds);
        Log.when(LOGGER, String.format(" Removing instances [%s] from distrox '%s'... ", instanceDeleteRequest.getInstances(), testDto.getName()));
        FlowIdentifier flowIdentifier = client.getDefaultClient().distroXV1Endpoint().deleteInstancesByCrn(testDto.getCrn(), removableInstanceIds, instanceDeleteRequest, false);
        testDto.setFlow("Instance deletion", flowIdentifier);
        StackV4Response stackV4Response = client.getDefaultClient().distroXV1Endpoint().getByName(testDto.getName(), new HashSet<>(Arrays.asList("hardware_info", "events")));
        testDto.setResponse(stackV4Response);
        Log.whenJson(LOGGER, " Distrox remove instances response: ", stackV4Response);
        LOGGER.info(String.format("Hardware info for distrox '%s' after remove instances [%s].", testDto.getName(), stackV4Response.getHardwareInfoGroups()));
        return testDto;
    } else {
        throw new TestFailException(String.format("Cannot find any instance to remove from distrox '%s'!", testDto.getName()));
    }
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) MultipleInstanceDeleteRequest(com.sequenceiq.distrox.api.v1.distrox.model.MultipleInstanceDeleteRequest) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Aggregations

StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)101 Test (org.junit.jupiter.api.Test)26 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)22 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)19 ClusterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response)14 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)13 Test (org.junit.Test)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)11 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)8 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)8 MockedTestContext (com.sequenceiq.it.cloudbreak.context.MockedTestContext)7 TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)7 DistroXTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto)7 ArrayList (java.util.ArrayList)7 Test (org.testng.annotations.Test)7 InstanceGroupV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response)6 TagsV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response)6 TransactionExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException)6 TransactionRuntimeExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)6 BaseDiagnosticsCollectionRequest (com.sequenceiq.common.api.diagnostics.BaseDiagnosticsCollectionRequest)6