use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.
the class ClouderaManagerMgmtTelemetryServiceTest method testSetupTelemetryForDatalake.
@Test
public void testSetupTelemetryForDatalake() throws ApiException {
// GIVEN
Stack stack = new Stack();
stack.setType(StackType.DATALAKE);
WorkloadAnalytics wa = new WorkloadAnalytics();
Telemetry telemetry = new Telemetry();
telemetry.setWorkloadAnalytics(wa);
when(entitlementService.useDataBusCNameEndpointEnabled(anyString())).thenReturn(false);
when(dataBusEndpointProvider.getDataBusEndpoint(anyString(), anyBoolean())).thenReturn("https://dbusapi.us-west-1.sigma.altus.cloudera.com");
// WHEN
underTest.setupTelemetryRole(stack, null, null, null, telemetry, SDX_STACK_CRN);
// THEN
verify(externalAccountService, times(0)).createExternalAccount(anyString(), anyString(), anyString(), anyMap(), any(ApiClient.class));
}
use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.
the class ClouderaManagerMgmtTelemetryServiceTest method testSetupTelemetry.
@Test
public void testSetupTelemetry() throws ApiException {
// GIVEN
Stack stack = new Stack();
stack.setType(StackType.WORKLOAD);
User user = new User();
user.setUserCrn("crn:cdp:iam:us-west-1:accountId:user:name");
stack.setCreator(user);
stack.setResourceCrn("crn:cdp:datahub:us-west-1:accountId:cluster:name");
WorkloadAnalytics wa = new WorkloadAnalytics();
Telemetry telemetry = new Telemetry();
telemetry.setWorkloadAnalytics(wa);
ApiConfigList apiConfigList = new ApiConfigList();
ApiResponse response = new ApiResponse<>(0, null, apiConfigList);
AltusCredential credential = new AltusCredential("accessKey", "secretKey".toCharArray());
when(entitlementService.useDataBusCNameEndpointEnabled(anyString())).thenReturn(false);
when(dataBusEndpointProvider.getDataBusEndpoint(anyString(), anyBoolean())).thenReturn("https://dbusapi.us-west-1.sigma.altus.cloudera.com");
when(apiClient.execute(any(), any())).thenReturn(response);
when(clouderaManagerDatabusService.getAltusCredential(stack, SDX_STACK_CRN)).thenReturn(credential);
when(clouderaManagerApiFactory.getClouderaManagerResourceApi(apiClient)).thenReturn(cmResourceApi);
when(cmResourceApi.updateConfig(anyString(), any())).thenReturn(apiConfigList);
// WHEN
underTest.setupTelemetryRole(stack, apiClient, null, new ApiRoleList(), telemetry, SDX_STACK_CRN);
// THEN
verify(externalAccountService, times(1)).createExternalAccount(anyString(), anyString(), anyString(), anyMap(), any(ApiClient.class));
verify(clouderaManagerDatabusService, times(1)).getAltusCredential(stack, SDX_STACK_CRN);
}
use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.
the class ClouderaManagerMgmtTelemetryServiceTest method testSetupTelemetryWaDisabled.
@Test
public void testSetupTelemetryWaDisabled() throws ApiException {
// GIVEN
Stack stack = new Stack();
stack.setType(StackType.WORKLOAD);
Telemetry telemetry = new Telemetry();
// WHEN
underTest.setupTelemetryRole(stack, null, null, null, telemetry, SDX_STACK_CRN);
// THEN
verify(externalAccountService, times(0)).createExternalAccount(anyString(), anyString(), anyString(), anyMap(), any(ApiClient.class));
}
use of com.sequenceiq.common.api.telemetry.model.Telemetry 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);
}
use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.
the class TelemetryDecoratorTest method testDecorateWithMetering.
@Test
public void testDecorateWithMetering() {
// GIVEN
Map<String, SaltPillarProperties> servicePillar = new HashMap<>();
MeteringConfigView meteringConfigView = new MeteringConfigView.Builder().withEnabled(true).withPlatform("AWS").withServiceType("DATAHUB").withServiceVersion("1.0.0").withClusterCrn("myClusterCrn").build();
DatabusConfigView dataConfigView = new DatabusConfigView.Builder().build();
mockConfigServiceResults(dataConfigView, new FluentConfigView.Builder().build(), meteringConfigView);
// WHEN
Map<String, SaltPillarProperties> result = underTest.decoratePillar(servicePillar, createStack(), new Telemetry());
// THEN
Map<String, Object> results = createMapFromFluentPillars(result, "metering");
assertEquals(results.get("serviceType"), "DATAHUB");
assertEquals(results.get("serviceVersion"), "1.0.0");
assertEquals(results.get("clusterCrn"), "myClusterCrn");
assertEquals(results.get("enabled"), true);
}
Aggregations