Search in sources :

Example 1 with StructuredSyncEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent in project cloudbreak by hortonworks.

the class StructuredSyncEventFactoryTest method createCDPStructuredSyncEvent.

@Test
public void createCDPStructuredSyncEvent() {
    Stack stack = TestUtil.stack();
    stack.setResourceCrn("crn");
    Cluster cluster = TestUtil.cluster();
    Blueprint blueprint = TestUtil.blueprint();
    cluster.setBlueprint(blueprint);
    stack.setCluster(cluster);
    BlueprintDetails blueprintDetails = new BlueprintDetails();
    blueprintDetails.setBlueprintName("testBpName");
    when(stackToStackDetailsConverter.convert(any())).thenReturn(null);
    when(blueprintToBlueprintDetailsConverter.convert(blueprint)).thenReturn(blueprintDetails);
    when(stackService.getByIdWithTransaction(1L)).thenReturn(stack);
    when(nodeConfig.getId()).thenReturn("cbid");
    StructuredSyncEvent result = underTest.createStructuredSyncEvent(1L);
    assertNull(result.getStack());
    assertEquals(CloudbreakEventService.DATAHUB_RESOURCE_TYPE, result.getOperation().getResourceType());
    assertEquals("crn", result.getOperation().getResourceCrn());
    assertEquals("cbid", result.getOperation().getCloudbreakId());
    assertEquals("testBpName", result.getBlueprintDetails().getBlueprintName());
}
Also used : BlueprintDetails(com.sequenceiq.cloudbreak.structuredevent.event.BlueprintDetails) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) StructuredSyncEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 2 with StructuredSyncEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent in project cloudbreak by hortonworks.

the class StructuredEventToCDPOperationDetailsConverterTest method testEnvironmentTypeSetCorrectly.

@Test
public void testEnvironmentTypeSetCorrectly() {
    StructuredFlowEvent structuredFlowEvent = new StructuredFlowEvent();
    StackDetails flowStackDetails = new StackDetails();
    flowStackDetails.setCloudPlatform(CloudPlatform.AWS.name());
    structuredFlowEvent.setStack(flowStackDetails);
    UsageProto.CDPOperationDetails flowOperationDetails = underTest.convert(structuredFlowEvent);
    Assert.assertEquals(UsageProto.CDPEnvironmentsEnvironmentType.Value.AWS, flowOperationDetails.getEnvironmentType());
    StructuredSyncEvent structuredSyncEvent = new StructuredSyncEvent();
    StackDetails syncStackDetails = new StackDetails();
    syncStackDetails.setCloudPlatform(CloudPlatform.AWS.name());
    structuredSyncEvent.setStack(syncStackDetails);
    UsageProto.CDPOperationDetails syncOperationDetails = underTest.convert(structuredSyncEvent);
    Assert.assertEquals(UsageProto.CDPEnvironmentsEnvironmentType.Value.AWS, syncOperationDetails.getEnvironmentType());
}
Also used : StructuredSyncEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent) StackDetails(com.sequenceiq.cloudbreak.structuredevent.event.StackDetails) StructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredFlowEvent) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Example 3 with StructuredSyncEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent in project cloudbreak by hortonworks.

the class StructuredEventToCDPOperationDetailsConverterTest method testConversionWithNullOperation.

@Test
public void testConversionWithNullOperation() {
    StructuredFlowEvent structuredFlowEvent = new StructuredFlowEvent();
    UsageProto.CDPOperationDetails flowOperationDetails = underTest.convert(structuredFlowEvent);
    Assert.assertEquals("", flowOperationDetails.getAccountId());
    Assert.assertEquals("", flowOperationDetails.getResourceCrn());
    Assert.assertEquals("", flowOperationDetails.getResourceName());
    Assert.assertEquals("", flowOperationDetails.getInitiatorCrn());
    Assert.assertEquals("", flowOperationDetails.getCorrelationId());
    Assert.assertEquals(UsageProto.CDPRequestProcessingStep.Value.UNSET, flowOperationDetails.getCdpRequestProcessingStep());
    Assert.assertEquals("", flowOperationDetails.getFlowId());
    Assert.assertEquals("", flowOperationDetails.getFlowChainId());
    Assert.assertEquals("", flowOperationDetails.getFlowState());
    Assert.assertEquals(UsageProto.CDPEnvironmentsEnvironmentType.Value.UNSET, flowOperationDetails.getEnvironmentType());
    Assert.assertEquals("version-1234", flowOperationDetails.getApplicationVersion());
    StructuredSyncEvent structuredSyncEvent = new StructuredSyncEvent();
    UsageProto.CDPOperationDetails syncOperationDetails = underTest.convert(structuredSyncEvent);
    Assert.assertEquals("", syncOperationDetails.getAccountId());
    Assert.assertEquals("", syncOperationDetails.getResourceCrn());
    Assert.assertEquals("", syncOperationDetails.getResourceName());
    Assert.assertEquals("", syncOperationDetails.getInitiatorCrn());
    Assert.assertEquals("", syncOperationDetails.getCorrelationId());
    Assert.assertEquals(UsageProto.CDPRequestProcessingStep.Value.SYNC, syncOperationDetails.getCdpRequestProcessingStep());
    Assert.assertEquals("", syncOperationDetails.getFlowId());
    Assert.assertEquals("", syncOperationDetails.getFlowChainId());
    Assert.assertEquals("", syncOperationDetails.getFlowState());
    Assert.assertEquals(UsageProto.CDPEnvironmentsEnvironmentType.Value.UNSET, syncOperationDetails.getEnvironmentType());
    Assert.assertEquals("version-1234", syncOperationDetails.getApplicationVersion());
}
Also used : StructuredSyncEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent) StructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredFlowEvent) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Example 4 with StructuredSyncEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent in project cloudbreak by hortonworks.

the class StructuredEventToCDPStatusDetailsConverterTest method testConversionWithEmptyStructuredEvent.

@Test
public void testConversionWithEmptyStructuredEvent() {
    StructuredFlowEvent structuredFlowEvent = new StructuredFlowEvent();
    UsageProto.CDPStatusDetails flowStatusDetails = underTest.convert(structuredFlowEvent);
    Assert.assertEquals("", flowStatusDetails.getStackStatus());
    Assert.assertEquals("", flowStatusDetails.getStackDetailedStatus());
    Assert.assertEquals("", flowStatusDetails.getStackStatusReason());
    Assert.assertEquals("", flowStatusDetails.getClusterStatus());
    Assert.assertEquals("", flowStatusDetails.getClusterStatusReason());
    StructuredSyncEvent structuredSyncEvent = new StructuredSyncEvent();
    UsageProto.CDPStatusDetails syncStatusDetails = underTest.convert(structuredSyncEvent);
    Assert.assertEquals("", syncStatusDetails.getStackStatus());
    Assert.assertEquals("", syncStatusDetails.getStackDetailedStatus());
    Assert.assertEquals("", syncStatusDetails.getStackStatusReason());
    Assert.assertEquals("", syncStatusDetails.getClusterStatus());
    Assert.assertEquals("", syncStatusDetails.getClusterStatusReason());
}
Also used : StructuredSyncEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent) StructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredFlowEvent) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Example 5 with StructuredSyncEvent

use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent in project cloudbreak by hortonworks.

the class StructuredEventToCDPVersionDetailsConverterTest method testConversionFileldOutValues.

@Test
public void testConversionFileldOutValues() {
    StructuredFlowEvent structuredFlowEvent = new StructuredFlowEvent();
    structuredFlowEvent.setStack(createStackDetails());
    UsageProto.CDPVersionDetails flowVersionDetails = underTest.convert(structuredFlowEvent);
    Assert.assertEquals("7.3.0-11", flowVersionDetails.getCmVersion());
    Assert.assertEquals("7.2.7-22", flowVersionDetails.getCdpdVersion());
    Assert.assertEquals("7.2.7", flowVersionDetails.getCrVersion());
    Assert.assertEquals("2021-02-04", flowVersionDetails.getOsPatchLevel());
    Assert.assertEquals("3000.5", flowVersionDetails.getSaltVersion());
    Assert.assertEquals("bootstrap=something, cdh-build-number=22, cm-build-number=11, cm=7.3.0, date=2021-02-04," + " salt=3000.5, stack=7.2.7", flowVersionDetails.getAll());
    StructuredSyncEvent structuredSyncEvent = new StructuredSyncEvent();
    structuredSyncEvent.setStack(createStackDetails());
    UsageProto.CDPVersionDetails syncVersionDetails = underTest.convert(structuredSyncEvent);
    Assert.assertEquals("7.3.0-11", syncVersionDetails.getCmVersion());
    Assert.assertEquals("7.2.7-22", syncVersionDetails.getCdpdVersion());
    Assert.assertEquals("7.2.7", syncVersionDetails.getCrVersion());
    Assert.assertEquals("2021-02-04", syncVersionDetails.getOsPatchLevel());
    Assert.assertEquals("3000.5", syncVersionDetails.getSaltVersion());
    Assert.assertEquals("bootstrap=something, cdh-build-number=22, cm-build-number=11, cm=7.3.0, date=2021-02-04," + " salt=3000.5, stack=7.2.7", syncVersionDetails.getAll());
}
Also used : StructuredSyncEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent) StructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredFlowEvent) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Aggregations

StructuredSyncEvent (com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent)32 Test (org.junit.jupiter.api.Test)30 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)28 StructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.StructuredFlowEvent)22 StackDetails (com.sequenceiq.cloudbreak.structuredevent.event.StackDetails)10 BlueprintDetails (com.sequenceiq.cloudbreak.structuredevent.event.BlueprintDetails)5 ClusterDetails (com.sequenceiq.cloudbreak.structuredevent.event.ClusterDetails)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 Json (com.sequenceiq.cloudbreak.common.json.Json)2 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)2 InstanceGroupDetails (com.sequenceiq.cloudbreak.structuredevent.event.InstanceGroupDetails)2 OperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.legacy.OperationDetails)2 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)1 StackTags (com.sequenceiq.cloudbreak.cloud.model.StackTags)1 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)1 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)1 HashMap (java.util.HashMap)1 JobExecutionException (org.quartz.JobExecutionException)1