Search in sources :

Example 6 with TelemetryClusterDetails

use of com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails in project cloudbreak by hortonworks.

the class TelemetryCommonConfigServiceTest method testCreateTelemetryCommonConfigs.

@Test
public void testCreateTelemetryCommonConfigs() {
    // GIVEN
    given(telemetryUpgradeConfiguration.isEnabled()).willReturn(true);
    TelemetryComponentUpgradeConfiguration cdpTelemetryConfig = new TelemetryComponentUpgradeConfiguration();
    cdpTelemetryConfig.setDesiredVersion("0.0.1");
    given(telemetryUpgradeConfiguration.getCdpTelemetry()).willReturn(cdpTelemetryConfig);
    given(altusDatabusConnectionConfiguration.getMaxTimeSeconds()).willReturn(1);
    Telemetry telemetry = new Telemetry();
    Map<String, Object> fluentAttributes = new HashMap<>();
    fluentAttributes.put(SERVICE_LOG_FOLDER_PREFIX, "/var/log");
    fluentAttributes.put(SERVER_LOG_FOLDER_PREFIX, "/custom/log");
    fluentAttributes.put(AGENT_LOG_FOLDER_PREFIX, "/grid/0/log");
    telemetry.setFluentAttributes(fluentAttributes);
    List<VmLog> vmLogs = new ArrayList<>();
    VmLog log1 = new VmLog();
    log1.setPath("${serviceLogFolderPrefix}/mylog.log");
    VmLog log2 = new VmLog();
    log2.setPath("${agentLogFolderPrefix}/*");
    VmLog log3 = new VmLog();
    log3.setPath("/my/path${serverLogFolderPrefix}/*");
    vmLogs.add(log1);
    vmLogs.add(log2);
    vmLogs.add(log3);
    TelemetryClusterDetails telemetryClusterDetails = TelemetryClusterDetails.Builder.builder().build();
    // WHEN
    TelemetryCommonConfigView result = underTest.createTelemetryCommonConfigs(telemetry, vmLogs, telemetryClusterDetails);
    // THEN
    assertEquals("/var/log/mylog.log", vmLogs.get(0).getPath());
    assertEquals("/grid/0/log/*", vmLogs.get(1).getPath());
    assertEquals("/my/path/custom/log/*", vmLogs.get(2).getPath());
    assertEquals("0.0.1", result.toMap().get("desiredCdpTelemetryVersion").toString());
    assertEquals(1, result.toMap().get("databusConnectMaxTime"));
}
Also used : VmLog(com.sequenceiq.common.api.telemetry.model.VmLog) TelemetryComponentUpgradeConfiguration(com.sequenceiq.cloudbreak.telemetry.TelemetryComponentUpgradeConfiguration) HashMap(java.util.HashMap) TelemetryClusterDetails(com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails) ArrayList(java.util.ArrayList) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Test(org.junit.Test)

Example 7 with TelemetryClusterDetails

use of com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails in project cloudbreak by hortonworks.

the class TelemetryDecoratorTest method testDecorateWithSaasMonitoring.

@Test
public void testDecorateWithSaasMonitoring() {
    // GIVEN
    Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
    TelemetryClusterDetails clusterDetails = TelemetryClusterDetails.Builder.builder().withCrn("myClusterCrn").withType("datahub").withVersion("1.0.0").build();
    MonitoringConfigView monitoringConfigView = new MonitoringConfigView.Builder().withEnabled(true).withClusterDetails(clusterDetails).build();
    NodeStatusConfigView nodeStatusConfigView = new NodeStatusConfigView.Builder().withServerUsername("admin").withServerPassword("admin".toCharArray()).build();
    DatabusConfigView dataConfigView = new DatabusConfigView.Builder().build();
    TelemetryCommonConfigView telemetryCommonConfigView = new TelemetryCommonConfigView.Builder().withClusterDetails(clusterDetails).build();
    MeteringConfigView meteringConfigView = new MeteringConfigView.Builder().build();
    mockConfigServiceResults(dataConfigView, new FluentConfigView.Builder().build(), meteringConfigView, monitoringConfigView, nodeStatusConfigView, telemetryCommonConfigView);
    given(entitlementService.isCdpSaasEnabled(anyString())).willReturn(true);
    // WHEN
    Map<String, SaltPillarProperties> result = underTest.decoratePillar(servicePillar, createStack(), new Telemetry());
    // THEN
    Map<String, Object> results = createMapFromFluentPillars(result, "monitoring");
    assertEquals(results.get("clusterType"), "datahub");
    assertEquals(results.get("clusterVersion"), "1.0.0");
    assertEquals(results.get("clusterCrn"), "myClusterCrn");
    assertEquals(results.get("enabled"), true);
}
Also used : TelemetryCommonConfigView(com.sequenceiq.cloudbreak.telemetry.common.TelemetryCommonConfigView) NodeStatusConfigView(com.sequenceiq.cloudbreak.telemetry.nodestatus.NodeStatusConfigView) HashMap(java.util.HashMap) TelemetryClusterDetails(com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DatabusConfigView(com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView) MeteringConfigView(com.sequenceiq.cloudbreak.telemetry.metering.MeteringConfigView) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) MonitoringConfigView(com.sequenceiq.cloudbreak.telemetry.monitoring.MonitoringConfigView) Test(org.junit.Test)

Aggregations

TelemetryClusterDetails (com.sequenceiq.cloudbreak.telemetry.TelemetryClusterDetails)7 SaltPillarProperties (com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)6 DatabusConfigView (com.sequenceiq.cloudbreak.telemetry.databus.DatabusConfigView)5 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)5 HashMap (java.util.HashMap)5 Test (org.junit.Test)5 TelemetryCommonConfigView (com.sequenceiq.cloudbreak.telemetry.common.TelemetryCommonConfigView)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 FluentConfigView (com.sequenceiq.cloudbreak.telemetry.fluent.FluentConfigView)3 MeteringConfigView (com.sequenceiq.cloudbreak.telemetry.metering.MeteringConfigView)2 MonitoringConfigView (com.sequenceiq.cloudbreak.telemetry.monitoring.MonitoringConfigView)2 NodeStatusConfigView (com.sequenceiq.cloudbreak.telemetry.nodestatus.NodeStatusConfigView)2 AltusCredential (com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential)1 TelemetryComponentUpgradeConfiguration (com.sequenceiq.cloudbreak.telemetry.TelemetryComponentUpgradeConfiguration)1 VmLog (com.sequenceiq.common.api.telemetry.model.VmLog)1 ArrayList (java.util.ArrayList)1