Search in sources :

Example 61 with Telemetry

use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.

the class StackToStackV4ResponseConverterTest method setUp.

@Before
public void setUp() throws CloudbreakImageNotFoundException {
    underTest = new StackToStackV4ResponseConverter();
    MockitoAnnotations.initMocks(this);
    when(imageService.getImage(anyLong())).thenReturn(new Image("cb-centos66-amb200-2015-05-25", Collections.emptyMap(), "redhat6", "redhat6", "", "default", "default-id", new HashMap<>()));
    when(componentConfigProviderService.getCloudbreakDetails(anyLong())).thenReturn(new CloudbreakDetails("version"));
    when(componentConfigProviderService.getStackTemplate(anyLong())).thenReturn(new StackTemplate("{}", "version"));
    when(componentConfigProviderService.getTelemetry(anyLong())).thenReturn(new Telemetry());
    Mockito.doAnswer(answer -> {
        StackV4Response result = answer.getArgument(1, StackV4Response.class);
        result.setSharedService(new SharedServiceV4Response());
        return null;
    }).when(datalakeService).addSharedServiceResponse(any(Stack.class), any(StackV4Response.class));
    when(serviceEndpointCollector.filterByStackType(any(StackType.class), any(List.class))).thenReturn(new ArrayList());
    credentialResponse = new CredentialResponse();
    credentialResponse.setName("cred-name");
    credentialResponse.setCrn("crn");
    when(loadBalancerService.findByStackId(any())).thenReturn(Set.of());
}
Also used : HashMap(java.util.HashMap) CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) ArrayList(java.util.ArrayList) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) SharedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.sharedservice.SharedServiceV4Response) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) StackToStackV4ResponseConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.StackToStackV4ResponseConverter) StackTemplate(com.sequenceiq.cloudbreak.cloud.model.StackTemplate) List(java.util.List) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 62 with Telemetry

use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.

the class StackV4RequestToStackConverterTest method setupForEndpointGateway.

private StackV4Request setupForEndpointGateway(boolean enabled) {
    initMocks();
    ReflectionTestUtils.setField(underTest, "defaultRegions", "AWS:eu-west-2");
    StackV4Request request = getRequest("stack-datalake-with-instancegroups.json");
    EnvironmentNetworkResponse networkResponse = new EnvironmentNetworkResponse();
    networkResponse.setPublicEndpointAccessGateway(enabled ? PublicEndpointAccessGateway.ENABLED : PublicEndpointAccessGateway.DISABLED);
    DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
    environmentResponse.setCredential(credentialResponse);
    environmentResponse.setCloudPlatform("AWS");
    environmentResponse.setTunnel(Tunnel.DIRECT);
    environmentResponse.setTags(new TagResponse());
    environmentResponse.setNetwork(networkResponse);
    when(environmentClientService.getByName(anyString())).thenReturn(environmentResponse);
    when(environmentClientService.getByCrn(anyString())).thenReturn(environmentResponse);
    given(credentialClientService.getByCrn(anyString())).willReturn(credential);
    given(credentialClientService.getByName(anyString())).willReturn(credential);
    given(providerParameterCalculator.get(request)).willReturn(getMappable());
    given(clusterV4RequestToClusterConverter.convert(any(ClusterV4Request.class))).willReturn(new Cluster());
    given(telemetryConverter.convert(null, StackType.DATALAKE)).willReturn(new Telemetry());
    given(loadBalancerConfigService.getKnoxGatewayGroups(any(Stack.class))).willReturn(Set.of("master"));
    return request;
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) TagResponse(com.sequenceiq.environment.api.v1.environment.model.response.TagResponse) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 63 with Telemetry

use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.

the class StackV4RequestToStackConverterTest method testConvertWithKnoxLoadBalancer.

@Test
public void testConvertWithKnoxLoadBalancer() {
    initMocks();
    setDefaultRegions(AWS);
    StackV4Request request = getRequest("stack-datalake-with-instancegroups.json");
    ReflectionTestUtils.setField(underTest, "defaultRegions", "AWS:eu-west-2");
    TargetGroup targetGroup = new TargetGroup();
    targetGroup.setType(TargetGroupType.KNOX);
    LoadBalancer loadBalancer = new LoadBalancer();
    loadBalancer.setType(LoadBalancerType.PRIVATE);
    loadBalancer.setTargetGroupSet(Set.of(targetGroup));
    given(credentialClientService.getByCrn(anyString())).willReturn(credential);
    given(credentialClientService.getByName(anyString())).willReturn(credential);
    given(providerParameterCalculator.get(request)).willReturn(getMappable());
    given(clusterV4RequestToClusterConverter.convert(any(ClusterV4Request.class))).willReturn(new Cluster());
    given(telemetryConverter.convert(null, StackType.DATALAKE)).willReturn(new Telemetry());
    given(loadBalancerConfigService.createLoadBalancers(any(), any(), eq(request))).willReturn(Set.of(loadBalancer));
    // WHEN
    Stack stack = underTest.convert(request);
    // THEN
    assertEquals(1, stack.getLoadBalancers().size());
    assertEquals(1, stack.getLoadBalancers().iterator().next().getTargetGroupSet().size());
    assertEquals(TargetGroupType.KNOX, stack.getLoadBalancers().iterator().next().getTargetGroupSet().iterator().next().getType());
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) AbstractJsonConverterTest(com.sequenceiq.cloudbreak.converter.AbstractJsonConverterTest) Test(org.junit.jupiter.api.Test)

Example 64 with Telemetry

use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.

the class StackV4RequestToStackConverterTest method testNoLoadBalancersCreatedWhenEntitlementIsDisabled.

@Test
public void testNoLoadBalancersCreatedWhenEntitlementIsDisabled() {
    initMocks();
    setDefaultRegions(AWS);
    StackV4Request request = getRequest("stack-datalake-with-instancegroups.json");
    given(credentialClientService.getByCrn(anyString())).willReturn(credential);
    given(credentialClientService.getByName(anyString())).willReturn(credential);
    given(providerParameterCalculator.get(request)).willReturn(getMappable());
    given(clusterV4RequestToClusterConverter.convert(any(ClusterV4Request.class))).willReturn(new Cluster());
    given(telemetryConverter.convert(null, StackType.DATALAKE)).willReturn(new Telemetry());
    given(loadBalancerConfigService.getKnoxGatewayGroups(any(Stack.class))).willReturn(Set.of("master"));
    // WHEN
    Stack stack = underTest.convert(request);
    // THEN
    assertEquals(0, stack.getLoadBalancers().size());
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) AbstractJsonConverterTest(com.sequenceiq.cloudbreak.converter.AbstractJsonConverterTest) Test(org.junit.jupiter.api.Test)

Example 65 with Telemetry

use of com.sequenceiq.common.api.telemetry.model.Telemetry in project cloudbreak by hortonworks.

the class StackV4RequestToStackConverterTest method testConvert.

@Test
public void testConvert() {
    initMocks();
    setDefaultRegions(AWS);
    StackV4Request request = getRequest("stack.json");
    given(credentialClientService.getByCrn(anyString())).willReturn(credential);
    given(credentialClientService.getByName(anyString())).willReturn(credential);
    given(providerParameterCalculator.get(request)).willReturn(getMappable());
    given(clusterV4RequestToClusterConverter.convert(any(ClusterV4Request.class))).willReturn(new Cluster());
    given(telemetryConverter.convert(null, StackType.WORKLOAD)).willReturn(new Telemetry());
    given(autoTlsFlagPreparatory.provideAutoTlsFlag(any(ClusterV4Request.class), any(Stack.class), any(Optional.class))).willReturn(Boolean.TRUE);
    // WHEN
    Stack stack = underTest.convert(request);
    // THEN
    assertAllFieldsNotNull(stack, Arrays.asList("description", "cluster", "environmentCrn", "gatewayPort", "useCcm", "network", "securityConfig", "version", "created", "platformVariant", "cloudPlatform", "customHostname", "customDomain", "clusterNameAsSubdomain", "hostgroupNameAsHostname", "parameters", "creator", "environmentCrn", "terminated", "datalakeCrn", "type", "inputs", "failurePolicy", "resourceCrn", "minaSshdServiceId", "ccmV2AgentCrn", "externalDatabaseCreationType", "stackVersion", "externalDatabaseEngineVersion", "originalName"));
    assertEquals("eu-west-1", stack.getRegion());
    assertEquals("AWS", stack.getCloudPlatform());
    assertEquals("mystack", stack.getName());
    verify(telemetryConverter, times(1)).convert(null, StackType.WORKLOAD);
    verify(environmentClientService, times(1)).getByCrn(anyString());
    verify(gatewaySecurityGroupDecorator, times(1)).extendGatewaySecurityGroupWithDefaultGatewayCidrs(any(Stack.class), any(Tunnel.class));
    assertTrue(stack.getCluster().getAutoTlsEnabled());
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) Tunnel(com.sequenceiq.common.api.type.Tunnel) Optional(java.util.Optional) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) AbstractJsonConverterTest(com.sequenceiq.cloudbreak.converter.AbstractJsonConverterTest) Test(org.junit.jupiter.api.Test)

Aggregations

Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)109 Test (org.junit.Test)55 Test (org.junit.jupiter.api.Test)31 Logging (com.sequenceiq.common.api.telemetry.model.Logging)30 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)20 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)16 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)15 BaseDiagnosticsCollectionRequest (com.sequenceiq.common.api.diagnostics.BaseDiagnosticsCollectionRequest)13 AdlsGen2CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters)12 Backup (com.sequenceiq.freeipa.api.model.Backup)12 HashMap (java.util.HashMap)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)11 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)10 Features (com.sequenceiq.common.api.telemetry.model.Features)10 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)8 SaltPillarProperties (com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)8 ApiClient (com.cloudera.api.swagger.client.ApiClient)7 GcsCloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.GcsCloudStorageV1Parameters)7 WorkloadAnalytics (com.sequenceiq.common.api.telemetry.model.WorkloadAnalytics)6 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)6