Search in sources :

Example 11 with WorkloadAnalytics

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));
}
Also used : Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) ApiClient(com.cloudera.api.swagger.client.ApiClient) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) WorkloadAnalytics(com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics) Test(org.junit.Test)

Example 12 with WorkloadAnalytics

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"));
}
Also used : ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) WorkloadAnalytics(com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics) Test(org.junit.Test)

Example 13 with WorkloadAnalytics

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);
}
Also used : ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) User(com.sequenceiq.cloudbreak.workspace.model.User) AltusCredential(com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential) ApiRoleList(com.cloudera.api.swagger.model.ApiRoleList) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) ApiClient(com.cloudera.api.swagger.client.ApiClient) ApiResponse(com.cloudera.api.swagger.client.ApiResponse) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) WorkloadAnalytics(com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics) Test(org.junit.Test)

Example 14 with WorkloadAnalytics

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"));
}
Also used : ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) WorkloadAnalytics(com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics) Test(org.junit.Test)

Example 15 with WorkloadAnalytics

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");
}
Also used : HashMap(java.util.HashMap) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) WorkloadAnalytics(com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics) Test(org.junit.Test)

Aggregations

WorkloadAnalytics (com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics)18 Test (org.junit.Test)11 ApiConfigList (com.cloudera.api.swagger.model.ApiConfigList)7 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)6 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)6 HashMap (java.util.HashMap)6 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)4 AltusCredential (com.sequenceiq.cloudbreak.auth.altus.model.AltusCredential)3 Features (com.sequenceiq.common.api.telemetry.model.Features)3 Logging (com.sequenceiq.common.api.telemetry.model.Logging)3 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)2 ApiClient (com.cloudera.api.swagger.client.ApiClient)2 ApiRole (com.cloudera.api.swagger.model.ApiRole)2 ConfigUtils.makeApiConfigList (com.sequenceiq.cloudbreak.cm.util.ConfigUtils.makeApiConfigList)2 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)2 Monitoring (com.sequenceiq.common.api.telemetry.model.Monitoring)2 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)2 WorkloadAnalyticsRequest (com.sequenceiq.common.api.telemetry.request.WorkloadAnalyticsRequest)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ApiResponse (com.cloudera.api.swagger.client.ApiResponse)1