use of com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics 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.WorkloadAnalytics in project cloudbreak by hortonworks.
the class ClouderaManagerMgmtTelemetryServiceTest method testBuildTelemetryConfigList.
@Test
public void testBuildTelemetryConfigList() {
// GIVEN
Stack stack = new Stack();
Cluster cluster = new Cluster();
cluster.setId(1L);
cluster.setName("cl1");
stack.setCluster(cluster);
WorkloadAnalytics wa = new WorkloadAnalytics();
// WHEN
ApiConfigList result = underTest.buildTelemetryConfigList(stack, wa, null, null, null);
// THEN
assertEquals(1, result.getItems().size());
assertTrue(result.getItems().get(0).getValue().contains("cluster.type=DATALAKE"));
}
use of com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics 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.WorkloadAnalytics in project cloudbreak by hortonworks.
the class ClouderaManagerMgmtTelemetryServiceTest method testBuildTelemetryCMConfigList.
@Test
public void testBuildTelemetryCMConfigList() {
// GIVEN
// WHEN
WorkloadAnalytics workloadAnalytics = new WorkloadAnalytics();
ApiConfigList result = underTest.buildTelemetryCMConfigList(workloadAnalytics, null);
// THEN
assertEquals(4, result.getItems().size());
assertTrue(containsConfigWithValue(result, "telemetry_wa", "true"));
assertTrue(containsConfigWithValue(result, "telemetry_master", "true"));
assertTrue(containsConfigWithValue(result, "telemetry_altus_account", "cb-altus-access"));
}
use of com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics in project cloudbreak by hortonworks.
the class ClouderaManagerMgmtTelemetryServiceTest method testEnrichWithSdxDataWithExistingSdxData.
@Test
public void testEnrichWithSdxDataWithExistingSdxData() {
// GIVEN
Map<String, String> safetyValveMap = new HashMap<>();
WorkloadAnalytics workloadAnalytics = new WorkloadAnalytics();
workloadAnalytics.setDatabusEndpoint("customEndpoint");
// WHEN
underTest.enrichWithSdxData("mySdxName", "crn:cdp:iam:us-west-1:accountId:user:mySdxId", null, workloadAnalytics, safetyValveMap);
// THEN
assertTrue(safetyValveMap.containsKey("databus.header.sdx.id"));
assertTrue(safetyValveMap.containsKey("databus.header.sdx.name"));
assertEquals(safetyValveMap.get("databus.header.sdx.id"), "mySdxId");
assertEquals(safetyValveMap.get("databus.header.sdx.name"), "mySdxName");
}
Aggregations