Search in sources :

Example 1 with CDPEnvironmentStructuredFlowEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent in project cloudbreak by hortonworks.

the class CDPStructuredFlowEventToCDPEnvironmentRequestedConverterTest method testConvertingEmptyStructuredFlowEvent.

@Test
public void testConvertingEmptyStructuredFlowEvent() {
    CDPEnvironmentStructuredFlowEvent cdpStructuredFlowEvent = new CDPEnvironmentStructuredFlowEvent();
    UsageProto.CDPEnvironmentRequested environmentRequested = underTest.convert(cdpStructuredFlowEvent);
    Assertions.assertNotNull(environmentRequested.getOperationDetails());
    Assertions.assertNotNull(environmentRequested.getEnvironmentDetails());
    Assertions.assertNotNull(environmentRequested.getFreeIPA());
    Assertions.assertNotNull(environmentRequested.getTelemetryFeatureDetails());
}
Also used : CDPEnvironmentStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Example 2 with CDPEnvironmentStructuredFlowEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent in project cloudbreak by hortonworks.

the class EnvironmentStructuredFlowEventFactory method createStructuredFlowEvent.

@Override
public CDPStructuredFlowEvent createStructuredFlowEvent(Long resourceId, FlowDetails flowDetails, Exception exception) {
    Environment environment = environmentService.findEnvironmentByIdOrThrow(resourceId);
    String resourceType = CloudbreakEventService.ENVIRONMENT_RESOURCE_TYPE;
    CDPOperationDetails operationDetails = new CDPOperationDetails(clock.getCurrentTimeMillis(), FLOW, resourceType, environment.getId(), environment.getName(), nodeConfig.getId(), serviceVersion, environment.getAccountId(), environment.getResourceCrn(), environment.getCreator(), environment.getResourceCrn(), null);
    EnvironmentDetails environmentDetails = environmentDtoConverter.environmentToDto(environment);
    CDPEnvironmentStructuredFlowEvent event = new CDPEnvironmentStructuredFlowEvent(operationDetails, flowDetails, environmentDetails, environment.getStatus().name(), getReason(environment));
    if (exception != null) {
        event.setException(ExceptionUtils.getStackTrace(exception));
    }
    return event;
}
Also used : CDPEnvironmentStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent) EnvironmentDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails) Environment(com.sequenceiq.environment.environment.domain.Environment) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)

Example 3 with CDPEnvironmentStructuredFlowEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent in project cloudbreak by hortonworks.

the class CDPEnvironmentStructuredFlowEventToCDPEnvironmentRequestedConverterTest method testConvertingEmptyStructuredFlowEvent.

@Test
public void testConvertingEmptyStructuredFlowEvent() {
    CDPEnvironmentStructuredFlowEvent cdpStructuredFlowEvent = new CDPEnvironmentStructuredFlowEvent();
    UsageProto.CDPEnvironmentRequested environmentRequested = underTest.convert(cdpStructuredFlowEvent);
    Assertions.assertNotNull(environmentRequested.getOperationDetails());
    Assertions.assertNotNull(environmentRequested.getEnvironmentDetails());
    Assertions.assertNotNull(environmentRequested.getFreeIPA());
    Assertions.assertNotNull(environmentRequested.getTelemetryFeatureDetails());
}
Also used : CDPEnvironmentStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Example 4 with CDPEnvironmentStructuredFlowEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent in project cloudbreak by hortonworks.

the class CDPEnvironmentStructuredFlowEventToCDPEnvironmentStatusChangedConverterTest method testConvertingEmptyStructuredFlowEvent.

@Test
public void testConvertingEmptyStructuredFlowEvent() {
    CDPEnvironmentStructuredFlowEvent cdpStructuredFlowEvent = new CDPEnvironmentStructuredFlowEvent();
    UsageProto.CDPEnvironmentStatusChanged environmentStatusChanged = underTest.convert(cdpStructuredFlowEvent, UsageProto.CDPEnvironmentStatus.Value.CREATE_STARTED);
    Assertions.assertEquals(UsageProto.CDPEnvironmentStatus.Value.CREATE_STARTED, environmentStatusChanged.getNewStatus());
    Assertions.assertEquals(UsageProto.CDPEnvironmentStatus.Value.UNSET, environmentStatusChanged.getOldStatus());
    Assertions.assertNotNull(environmentStatusChanged.getOperationDetails());
    Assertions.assertNotNull(environmentStatusChanged.getEnvironmentDetails());
    Assertions.assertNotNull(environmentStatusChanged.getFreeIPA());
    Assertions.assertNotNull(environmentStatusChanged.getTelemetryFeatureDetails());
}
Also used : CDPEnvironmentStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Example 5 with CDPEnvironmentStructuredFlowEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent in project cloudbreak by hortonworks.

the class CDPStructuredFlowEventToCDPOperationDetailsConverterTest method testFlowStateOnlyFilledOutInCaseOfFailure.

@Test
public void testFlowStateOnlyFilledOutInCaseOfFailure() {
    CDPEnvironmentStructuredFlowEvent cdpStructuredFlowEvent = new CDPEnvironmentStructuredFlowEvent();
    FlowDetails flowDetails = new FlowDetails();
    cdpStructuredFlowEvent.setFlow(flowDetails);
    flowDetails.setFlowState("FLOW_STATE");
    flowDetails.setNextFlowState("ENV_CREATION_FAILED_STATE");
    UsageProto.CDPOperationDetails details = underTest.convert(cdpStructuredFlowEvent, null);
    Assertions.assertEquals("FLOW_STATE", details.getFlowState());
    flowDetails.setFlowState("FLOW_STATE");
    flowDetails.setNextFlowState("DOWNSCALE_FAIL_STATE");
    details = underTest.convert(cdpStructuredFlowEvent, null);
    Assertions.assertEquals("FLOW_STATE", details.getFlowState());
    flowDetails.setFlowState("FLOW_STATE");
    flowDetails.setNextFlowState("ENV_CREATION_FINISHED_STATE");
    details = underTest.convert(cdpStructuredFlowEvent, null);
    Assertions.assertEquals("", details.getFlowState());
    flowDetails.setFlowState("FLOW_STATE");
    flowDetails.setNextFlowState("INIT_STATE");
    details = underTest.convert(cdpStructuredFlowEvent, null);
    Assertions.assertEquals("", details.getFlowState());
    flowDetails.setFlowState(null);
    flowDetails.setNextFlowState("ENV_CREATION_FAILED_STATE");
    details = underTest.convert(cdpStructuredFlowEvent, null);
    Assertions.assertEquals("", details.getFlowState());
    flowDetails.setFlowState(null);
    flowDetails.setNextFlowState("DOWNSCALE_FAIL_STATE");
    details = underTest.convert(cdpStructuredFlowEvent, null);
    Assertions.assertEquals("", details.getFlowState());
    flowDetails.setFlowState("unknown");
    flowDetails.setNextFlowState("ENV_CREATION_FAILED_STATE");
    details = underTest.convert(cdpStructuredFlowEvent, null);
    Assertions.assertEquals("", details.getFlowState());
    flowDetails.setFlowState("unknown");
    flowDetails.setNextFlowState("DOWNSCALE_FAIL_STATE");
    details = underTest.convert(cdpStructuredFlowEvent, null);
    Assertions.assertEquals("", details.getFlowState());
    flowDetails.setFlowState("FLOW_STATE");
    flowDetails.setNextFlowState(null);
    details = underTest.convert(cdpStructuredFlowEvent, null);
    Assertions.assertEquals("", details.getFlowState());
}
Also used : CDPEnvironmentStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent) FlowDetails(com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Aggregations

CDPEnvironmentStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent)15 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)12 Test (org.junit.jupiter.api.Test)12 FlowDetails (com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails)7 CDPOperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)3 EnvironmentDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails)2 Environment (com.sequenceiq.environment.environment.domain.Environment)2