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());
}
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;
}
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());
}
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());
}
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());
}
Aggregations