Search in sources :

Example 21 with GATEWAY

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.

the class ClusterRequestToClusterConverterTest method testConvertWithCloudStorageDetails.

@Test
public void testConvertWithCloudStorageDetails() {
    // GIVEN
    ClusterV4Request request = getRequest("cluster-with-cloud-storage.json");
    given(gatewayV4RequestToGatewayConverter.convert(request.getGateway())).willReturn(new Gateway());
    given(cloudStorageConverter.requestToFileSystem(request.getCloudStorage())).willReturn(new FileSystem());
    given(cloudStorageValidationUtil.isCloudStorageConfigured(request.getCloudStorage())).willReturn(true);
    Blueprint blueprint = new Blueprint();
    blueprint.setStackType(StackType.HDP.name());
    given(blueprintService.getByNameForWorkspaceAndLoadDefaultsIfNecessary(eq("my-blueprint"), any())).willReturn(blueprint);
    // WHEN
    Cluster result = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.convert(request));
    // THEN
    assertAllFieldsNotNull(result, Arrays.asList("stack", "blueprint", "creationStarted", "creationFinished", "upSince", "statusReason", "clusterManagerIp", "additionalFileSystem", "rdsConfigs", "attributes", "uptime", "ambariSecurityMasterKey", "proxyConfigCrn", "extendedBlueprintText", "environmentCrn", "variant", "description", "databaseServerCrn", "fqdn", "configStrategy", "customConfigurations"));
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) AbstractJsonConverterTest(com.sequenceiq.cloudbreak.converter.AbstractJsonConverterTest) Test(org.junit.jupiter.api.Test)

Example 22 with GATEWAY

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY 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);
}
Also used : SecretResponse(com.sequenceiq.cloudbreak.service.secret.model.SecretResponse) ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) BlueprintV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4Response) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest) Test(org.junit.Test)

Example 23 with GATEWAY

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.

the class ClusterRequestToGatewayConverterTest method testConvertNewTopologies.

@Test
public void testConvertNewTopologies() {
    GatewayV4Request source = new GatewayV4Request();
    GatewayTopologyV4Request topology1 = new GatewayTopologyV4Request();
    topology1.setTopologyName("topology1");
    source.setTopologies(Collections.singletonList(topology1));
    Gateway result = underTest.convert(source);
    assertFalse(result.getTopologies().isEmpty());
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) GatewayTopologyV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request) Test(org.junit.Test)

Example 24 with GATEWAY

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.

the class ClusterRequestToGatewayConverterTest method testConvertSsoType.

@Test
public void testConvertSsoType() {
    GatewayV4Request source = new GatewayV4Request();
    source.setTopologies(getTopologies());
    Gateway result = underTest.convert(source);
    assertEquals(SSOType.NONE, result.getSsoType());
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Test(org.junit.Test)

Example 25 with GATEWAY

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType.GATEWAY in project cloudbreak by hortonworks.

the class ClusterRequestToGatewayConverterTest method testConvertBasicProperties.

@Test
public void testConvertBasicProperties() {
    GatewayV4Request source = new GatewayV4Request();
    source.setPath(PATH);
    source.setSsoProvider(SSO_PROVIDER);
    source.setSsoType(SSOType.SSO_PROVIDER);
    source.setTokenCert(TOKEN_CERT);
    source.setGatewayType(GatewayType.CENTRAL);
    source.setTopologies(getTopologies());
    Gateway result = underTest.convert(source);
    assertEquals(SSOType.SSO_PROVIDER, result.getSsoType());
    assertEquals(TOKEN_CERT, result.getTokenCert());
    assertEquals(GatewayType.CENTRAL, result.getGatewayType());
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Test(org.junit.Test)

Aggregations

Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)20 Test (org.junit.Test)18 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)16 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)16 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)15 Set (java.util.Set)15 Map (java.util.Map)14 List (java.util.List)13 Test (org.junit.jupiter.api.Test)12 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)10 Json (com.sequenceiq.cloudbreak.common.json.Json)9 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)9 Optional (java.util.Optional)9 Collectors (java.util.stream.Collectors)9 GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)8 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)8 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)8 HashSet (java.util.HashSet)8 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)7 InstanceMetaDataService (com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService)7