Search in sources :

Example 21 with StructuredSyncEvent

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

the class StructuredEventToCDPClusterDetailsConverterTest method testVariantConversionWithNullVariant.

@Test
public void testVariantConversionWithNullVariant() {
    StackDetails stackDetails = new StackDetails();
    stackDetails.setPlatformVariant(null);
    StructuredFlowEvent structuredFlowEvent = new StructuredFlowEvent();
    structuredFlowEvent.setStack(stackDetails);
    UsageProto.CDPClusterDetails clusterDetails = underTest.convert(structuredFlowEvent);
    Assertions.assertEquals(UsageProto.CDPCloudProviderVariantType.Value.UNSET, clusterDetails.getCloudProviderVariant());
    StructuredSyncEvent structuredSyncEvent = new StructuredSyncEvent();
    structuredSyncEvent.setStack(stackDetails);
    clusterDetails = underTest.convert(structuredSyncEvent);
    Assertions.assertEquals(0, clusterDetails.getCloudProviderVariantValue());
}
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 22 with StructuredSyncEvent

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

the class StructuredEventToCDPClusterDetailsConverterTest method testUserTagsConversionWithNullTags.

@Test
public void testUserTagsConversionWithNullTags() {
    StackDetails stackDetails = new StackDetails();
    stackDetails.setTags(null);
    StructuredFlowEvent structuredFlowEvent = new StructuredFlowEvent();
    structuredFlowEvent.setStack(stackDetails);
    UsageProto.CDPClusterDetails clusterDetails = underTest.convert(structuredFlowEvent);
    Assertions.assertEquals("", clusterDetails.getUserTags());
    StructuredSyncEvent structuredSyncEvent = new StructuredSyncEvent();
    structuredSyncEvent.setStack(stackDetails);
    clusterDetails = underTest.convert(structuredSyncEvent);
    Assertions.assertEquals("", clusterDetails.getUserTags());
}
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 23 with StructuredSyncEvent

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

the class StructuredEventToCDPClusterDetailsConverterTest method testUserTagsConversionWithCorrectTags.

@Test
public void testUserTagsConversionWithCorrectTags() {
    StackDetails stackDetails = new StackDetails();
    Map<String, String> userTags = new HashMap<>();
    userTags.put("key1", "value1");
    userTags.put("key2", "value2");
    Map<String, String> appTags = new HashMap<>();
    appTags.put("appKey1", "appValue1");
    appTags.put("appKey2", "appValue2");
    stackDetails.setTags(new Json(new StackTags(userTags, appTags, new HashMap<>())));
    StructuredFlowEvent structuredFlowEvent = new StructuredFlowEvent();
    structuredFlowEvent.setStack(stackDetails);
    UsageProto.CDPClusterDetails clusterDetails = underTest.convert(structuredFlowEvent);
    Assertions.assertEquals("{\"key1\":\"value1\",\"key2\":\"value2\"}", clusterDetails.getUserTags());
    Assertions.assertEquals("{\"appKey1\":\"appValue1\",\"appKey2\":\"appValue2\"}", clusterDetails.getApplicationTags());
    StructuredSyncEvent structuredSyncEvent = new StructuredSyncEvent();
    structuredSyncEvent.setStack(stackDetails);
    clusterDetails = underTest.convert(structuredSyncEvent);
    Assertions.assertEquals("{\"key1\":\"value1\",\"key2\":\"value2\"}", clusterDetails.getUserTags());
    Assertions.assertEquals("{\"appKey1\":\"appValue1\",\"appKey2\":\"appValue2\"}", clusterDetails.getApplicationTags());
}
Also used : StackTags(com.sequenceiq.cloudbreak.cloud.model.StackTags) HashMap(java.util.HashMap) StructuredSyncEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent) StackDetails(com.sequenceiq.cloudbreak.structuredevent.event.StackDetails) Json(com.sequenceiq.cloudbreak.common.json.Json) StructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredFlowEvent) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Example 24 with StructuredSyncEvent

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

the class StructuredEventToCDPClusterShapeConverterTest method testConversionWithBlueprintDetails.

@Test
public void testConversionWithBlueprintDetails() {
    String blueprintJson = "{ \"cdhVersion\": \"7.2.14\", \"displayName\": \"dataengineering ha\", \"services\": [{ \"refName\": \"zookeeper\", " + "\"serviceType\": \"ZOOKEEPER\", \"roleConfigGroups\": [{ \"refName\": \"zookeeper-SERVER-BASE\", \"roleType\": \"SERVER\", \"base\": true " + "}]},{ \"refName\": \"hdfs\", \"serviceType\": \"HDFS\", \"serviceConfigs\": [{ \"name\": \"zookeeper_service\", \"ref\": \"zookeeper\" }]}," + "{ \"refName\": \"hms\", \"serviceType\": \"HIVE\", \"displayName\": \"Hive Metastore\", \"roleConfigGroups\": [{ \"refName\": " + "\"hms-GATEWAY-BASE\", \"roleType\": \"GATEWAY\", \"base\": true }] }, { \"refName\": \"hive\", \"serviceType\": \"HIVE_ON_TEZ\", " + "\"displayName\": \"Hive\", \"serviceConfigs\": [{ \"name\": \"tez_auto_reducer_parallelism\", \"value\": \"false\" }] }, " + "{ \"refName\": \"hue\", \"serviceType\": \"HUE\", \"serviceConfigs\": [{ \"name\": \"hue_service_safety_valve\", \"value\": \"[desktop]" + "\\napp_blacklist=spark,zookeeper,hbase,impala,search,sqoop,security,pig\" }] }, { \"refName\": \"livy\", \"serviceType\": \"LIVY\", " + "\"roleConfigGroups\": [{ \"refName\": \"livy-GATEWAY-BASE\", \"roleType\": \"GATEWAY\", \"base\": true }] }, { \"refName\": \"oozie\", " + "\"serviceType\": \"OOZIE\", \"roleConfigGroups\": [{ \"refName\": \"oozie-OOZIE_SERVER-BASE\", \"roleType\": \"OOZIE_SERVER\", " + "\"base\": true }] }, { \"refName\": \"sqoop\", \"serviceType\": \"SQOOP_CLIENT\", \"roleConfigGroups\": [{ \"refName\": " + "\"sqoop-SQOOP_CLIENT-GATEWAY-BASE\", \"roleType\": \"GATEWAY\", \"configs\": [], \"base\": true }] }, { \"refName\": \"yarn\", " + "\"serviceType\": \"YARN\", \"serviceConfigs\": [{ \"name\": \"yarn_admin_acl\", \"value\": \"yarn,hive,hdfs,mapred\" }] }, { \"refName\": " + "\"spark_on_yarn\", \"serviceType\": \"SPARK_ON_YARN\", \"roleConfigGroups\": [{ \"refName\": " + "\"spark_on_yarn-SPARK_YARN_HISTORY_SERVER-BASE\", \"roleType\": \"SPARK_YARN_HISTORY_SERVER\", \"base\": true }] }, { \"refName\": \"tez\"," + "\"serviceType\": \"TEZ\", \"roleConfigGroups\": [{ \"refName\": \"tez-GATEWAY-BASE\", \"roleType\": \"GATEWAY\", \"base\": true }] }, " + "{ \"refName\": \"das\", \"serviceType\": \"DAS\" }] }";
    StructuredFlowEvent structuredFlowEvent = new StructuredFlowEvent();
    structuredFlowEvent.setStack(createStackDetails());
    BlueprintDetails flowBlueprintDetails = new BlueprintDetails();
    flowBlueprintDetails.setName("My Blueprint");
    flowBlueprintDetails.setBlueprintJson(blueprintJson);
    structuredFlowEvent.setBlueprintDetails(flowBlueprintDetails);
    UsageProto.CDPClusterShape flowClusterShape = underTest.convert(structuredFlowEvent);
    Assert.assertEquals("My Blueprint", flowClusterShape.getClusterTemplateName());
    Assert.assertEquals(10, flowClusterShape.getNodes());
    Assert.assertEquals("compute=3, gw=4, master=1, worker=2", flowClusterShape.getHostGroupNodeCount());
    Assert.assertTrue(flowClusterShape.getTemporaryStorageUsed());
    Assert.assertEquals("{\"services\":{\"HIVE_ON_TEZ\":1,\"HIVE\":1,\"LIVY\":1,\"DAS\":1,\"HDFS\":1," + "\"OOZIE\":1,\"TEZ\":1,\"HUE\":1,\"SQOOP_CLIENT\":1,\"ZOOKEEPER\":1,\"YARN\":1,\"SPARK_ON_YARN\":1}}", flowClusterShape.getClusterTemplateDetails());
    StructuredSyncEvent structuredSyncEvent = new StructuredSyncEvent();
    structuredSyncEvent.setStack(createStackDetails());
    BlueprintDetails syncBlueprintDetails = new BlueprintDetails();
    syncBlueprintDetails.setName("My Blueprint");
    syncBlueprintDetails.setBlueprintJson(blueprintJson);
    structuredSyncEvent.setBlueprintDetails(syncBlueprintDetails);
    UsageProto.CDPClusterShape syncClusterShape = underTest.convert(structuredSyncEvent);
    Assert.assertEquals("My Blueprint", syncClusterShape.getClusterTemplateName());
    Assert.assertEquals(10, syncClusterShape.getNodes());
    Assert.assertEquals("compute=3, gw=4, master=1, worker=2", syncClusterShape.getHostGroupNodeCount());
    Assert.assertTrue(syncClusterShape.getTemporaryStorageUsed());
    Assert.assertEquals("{\"services\":{\"HIVE_ON_TEZ\":1,\"HIVE\":1,\"LIVY\":1,\"DAS\":1,\"HDFS\":1," + "\"OOZIE\":1,\"TEZ\":1,\"HUE\":1,\"SQOOP_CLIENT\":1,\"ZOOKEEPER\":1,\"YARN\":1,\"SPARK_ON_YARN\":1}}", syncClusterShape.getClusterTemplateDetails());
}
Also used : BlueprintDetails(com.sequenceiq.cloudbreak.structuredevent.event.BlueprintDetails) 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 25 with StructuredSyncEvent

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

the class StructuredEventToCDPClusterShapeConverterTest method testConversionWithoutCustomConfigurations.

@Test
public void testConversionWithoutCustomConfigurations() {
    StructuredFlowEvent structuredFlowEvent = new StructuredFlowEvent();
    StackDetails stackDetails = new StackDetails();
    InstanceGroupDetails master = createInstanceGroupDetails("master", 2, null);
    stackDetails.setInstanceGroups(List.of(master));
    structuredFlowEvent.setStack(stackDetails);
    UsageProto.CDPClusterShape flowClusterShape = underTest.convert(structuredFlowEvent);
    Assert.assertEquals(2, flowClusterShape.getNodes());
    Assert.assertEquals("master=2", flowClusterShape.getHostGroupNodeCount());
    Assert.assertEquals("null", flowClusterShape.getClusterTemplateOverridesDetails());
    StructuredSyncEvent structuredSyncEvent = new StructuredSyncEvent();
    structuredSyncEvent.setStack(stackDetails);
    UsageProto.CDPClusterShape syncClusterShape = underTest.convert(structuredSyncEvent);
    Assert.assertEquals(2, syncClusterShape.getNodes());
    Assert.assertEquals("master=2", syncClusterShape.getHostGroupNodeCount());
    Assert.assertEquals("null", syncClusterShape.getClusterTemplateOverridesDetails());
}
Also used : StructuredSyncEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredSyncEvent) InstanceGroupDetails(com.sequenceiq.cloudbreak.structuredevent.event.InstanceGroupDetails) 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)

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