use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response in project cloudbreak by hortonworks.
the class StackToStackV4ResponseConverterTest method testConvert.
@Test
public void testConvert() throws CloudbreakImageNotFoundException {
Stack source = getSource();
// GIVEN
given(imageService.getImage(source.getId())).willReturn(mock(Image.class));
given(imageToStackImageV4ResponseConverter.convert(any(Image.class))).willReturn(new StackImageV4Response());
given(stackAuthenticationToStackAuthenticationV4ResponseConverter.convert(any(StackAuthentication.class))).willReturn(new StackAuthenticationV4Response());
given(stackToCustomDomainsSettingsV4Response.convert(any())).willReturn(new CustomDomainSettingsV4Response());
given(clusterToClusterV4ResponseConverter.convert(any())).willReturn(new ClusterV4Response());
given(networkToNetworkV4ResponseConverter.convert(any())).willReturn(new NetworkV4Response());
given(workspaceToWorkspaceResourceV4ResponseConverter.convert(any())).willReturn(new WorkspaceResourceV4Response());
given(cloudbreakDetailsToCloudbreakDetailsV4ResponseConverter.convert(any())).willReturn(new CloudbreakDetailsV4Response());
given(stackToPlacementSettingsV4ResponseConverter.convert(any())).willReturn(new PlacementSettingsV4Response());
given(telemetryConverter.convert(any())).willReturn(new TelemetryResponse());
given(instanceGroupToInstanceGroupV4ResponseConverter.convert(any())).willReturn(new InstanceGroupV4Response());
given(databaseAvailabilityTypeToDatabaseResponseConverter.convert(any(), any())).willReturn(new DatabaseResponse());
// WHEN
StackV4Response result = underTest.convert(source);
// THEN
assertAllFieldsNotNull(result, Arrays.asList("gcp", "mock", "openstack", "aws", "yarn", "azure", "environmentName", "credentialName", "credentialCrn", "telemetry", "flowIdentifier", "loadBalancers"));
verify(restRequestThreadLocalService).setWorkspace(source.getWorkspace());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response in project cloudbreak by hortonworks.
the class ClusterToClusterV4ResponseConverterTest method testConvertWithoutUpSinceField.
@Test
public void testConvertWithoutUpSinceField() {
// GIVEN
given(proxyConfigDtoService.getByCrn(anyString())).willReturn(ProxyConfig.builder().withCrn("crn").withName("name").build());
getSource().setUpSince(null);
// WHEN
ClusterV4Response result = underTest.convert(getSource());
// THEN
assertEquals(0L, result.getMinutesUp());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response in project cloudbreak by hortonworks.
the class ClusterToClusterV4ResponseConverterTest method testConvert.
@Test
public void testConvert() {
// GIVEN
getSource().setConfigStrategy(ConfigStrategy.NEVER_APPLY);
getSource().setBlueprint(new Blueprint());
getSource().setExtendedBlueprintText("asdf");
getSource().setFqdn("some.fqdn");
getSource().setCertExpirationState(CertExpirationState.HOST_CERT_EXPIRING);
given(stackUtil.extractClusterManagerIp(any(Stack.class))).willReturn("10.0.0.1");
given(stackUtil.extractClusterManagerAddress(any(Stack.class))).willReturn("some.fqdn");
Cluster source = getSource();
TestUtil.setSecretField(Cluster.class, "cloudbreakAmbariUser", source, "user", "secret/path");
TestUtil.setSecretField(Cluster.class, "cloudbreakAmbariPassword", source, "pass", "secret/path");
TestUtil.setSecretField(Cluster.class, "dpAmbariUser", source, "user", "secret/path");
TestUtil.setSecretField(Cluster.class, "dpAmbariPassword", source, "pass", "secret/path");
when(stringToSecretResponseConverter.convert("secret/path")).thenReturn(new SecretResponse("kv", "pass"));
when(blueprintToBlueprintV4ResponseConverter.convert(getSource().getBlueprint())).thenReturn(new BlueprintV4Response());
when(serviceEndpointCollector.getManagerServerUrl(any(Cluster.class), anyString())).thenReturn("http://server/");
given(proxyConfigDtoService.getByCrn(anyString())).willReturn(ProxyConfig.builder().withCrn("crn").withName("name").build());
// WHEN
ClusterV4Response result = underTest.convert(source);
// THEN
assertEquals(1L, (long) result.getId());
assertEquals(getSource().getExtendedBlueprintText(), result.getExtendedBlueprintText());
assertEquals(CertExpirationState.HOST_CERT_EXPIRING, result.getCertExpirationState());
List<String> skippedFields = Lists.newArrayList("customContainers", "cm", "creationFinished", "cloudStorage", "gateway", "customConfigurationsName", "customConfigurationsCrn");
assertAllFieldsNotNull(result, skippedFields);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response in project cloudbreak by hortonworks.
the class ClusterToClusterV4ResponseConverterTest method testExposedServices.
@Test
public void testExposedServices() {
Map<String, Collection<ClusterExposedServiceV4Response>> exposedServiceResponseMap = new HashMap<>();
exposedServiceResponseMap.put("topology1", getExpiosedServices());
given(serviceEndpointCollector.prepareClusterExposedServices(any(), anyString())).willReturn(exposedServiceResponseMap);
given(proxyConfigDtoService.getByCrn(anyString())).willReturn(ProxyConfig.builder().withCrn("crn").withName("name").build());
given(stackUtil.extractClusterManagerIp(any(Stack.class))).willReturn("10.0.0.1");
given(stackUtil.extractClusterManagerAddress(any(Stack.class))).willReturn("some.fqdn");
ClusterV4Response clusterResponse = underTest.convert(getSource());
Map<String, Collection<ClusterExposedServiceV4Response>> clusterExposedServicesForTopologies = clusterResponse.getExposedServices();
assertEquals(1L, clusterExposedServicesForTopologies.keySet().size());
Collection<ClusterExposedServiceV4Response> topology1ServiceList = clusterExposedServicesForTopologies.get("topology1");
assertEquals(2L, topology1ServiceList.size());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response in project cloudbreak by hortonworks.
the class ProvisionerServiceTest method waitCloudbreakClusterCreationSuccess.
@Test
void waitCloudbreakClusterCreationSuccess() {
long clusterId = CLUSTER_ID.incrementAndGet();
SdxCluster sdxCluster = generateValidSdxCluster(clusterId);
StackV4Response stackV4Response = new StackV4Response();
stackV4Response.setStatus(Status.AVAILABLE);
ClusterV4Response cluster = new ClusterV4Response();
cluster.setStatus(Status.AVAILABLE);
stackV4Response.setCluster(cluster);
when(stackV4Endpoint.get(anyLong(), eq(sdxCluster.getClusterName()), anySet(), anyString())).thenReturn(stackV4Response);
when(sdxService.getById(clusterId)).thenReturn(sdxCluster);
PollingConfig pollingConfig = new PollingConfig(10, TimeUnit.MILLISECONDS, 1000, TimeUnit.MILLISECONDS);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
underTest.waitCloudbreakClusterCreation(clusterId, pollingConfig);
verify(sdxStatusService, times(1)).setStatusForDatalakeAndNotify(DatalakeStatusEnum.STACK_CREATION_IN_PROGRESS, "Datalake stack creation in progress", sdxCluster);
verify(sdxStatusService, times(1)).setStatusForDatalakeAndNotify(DatalakeStatusEnum.STACK_CREATION_FINISHED, "Stack created for Datalake", sdxCluster);
}
Aggregations