Search in sources :

Example 36 with Gateway

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.

the class ClusterProxyServiceTest method testReRegisterClusterWhenCCMV1.

@Test
void testReRegisterClusterWhenCCMV1() throws ClusterProxyException, JsonProcessingException {
    Stack stack = testStackUsingCCM();
    Gateway gateway = new Gateway();
    gateway.setPath("test-cluster");
    stack.getCluster().setGateway(gateway);
    when(securityConfigService.findOneByStackId(STACK_ID)).thenReturn(Optional.of(gatewaySecurityConfig()));
    ArgumentCaptor<ConfigRegistrationRequest> captor = ArgumentCaptor.forClass(ConfigRegistrationRequest.class);
    underTest.reRegisterCluster(stack);
    verify(clusterProxyRegistrationClient).registerConfig(captor.capture());
    ConfigRegistrationRequest proxyRegistrationReq = captor.getValue();
    assertThat(proxyRegistrationReq.getClusterCrn()).isEqualTo(STACK_CRN);
    assertThat(proxyRegistrationReq.getAccountId()).isEqualTo(TEST_ACCOUNT_ID);
    assertFalse(proxyRegistrationReq.isUseCcmV2(), "CCMV2 should not be enabled.");
    assertNull(proxyRegistrationReq.getCcmV2Configs(), "CCMV2 config should not be initialized.");
    assertEquals("https://10.10.10.10/test-cluster", proxyRegistrationReq.getUriOfKnox(), "CCMV1 Knox URI should match");
    assertTrue(proxyRegistrationReq.isUseTunnel(), "CCMV1 tunnel should be enabled");
    assertThat(proxyRegistrationReq.getTunnels()).withFailMessage("CCMV1 tunnel should be configured.").hasSameElementsAs(tunnelEntries());
    assertEquals(4, proxyRegistrationReq.getServices().size());
    assertTrue(proxyRegistrationReq.getServices().contains(cmServiceConfigWithInstanceId(PRIMARY_PRIVATE_IP, PRIMARY_INSTANCE_ID)));
    assertTrue(proxyRegistrationReq.getServices().contains(cmServiceConfigWithInstanceId(OTHER_PRIVATE_IP, OTHER_INSTANCE_ID)));
    assertTrue(proxyRegistrationReq.getServices().contains(cmServiceConfig()));
    assertTrue(proxyRegistrationReq.getServices().contains(cmInternalServiceConfig(true)));
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) ConfigRegistrationRequest(com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationRequest) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 37 with Gateway

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.

the class ClusterProxyServiceTest method testReRegisterClusterWhenCCMV2Jumpgate.

@Test
void testReRegisterClusterWhenCCMV2Jumpgate() throws ClusterProxyException, JsonProcessingException {
    Stack stack = testStack();
    stack.setTunnel(Tunnel.CCMV2_JUMPGATE);
    stack.setCcmV2AgentCrn("testAgentCrn");
    Gateway gateway = new Gateway();
    gateway.setPath("test-cluster");
    stack.getCluster().setId(1L);
    stack.getCluster().setGateway(gateway);
    when(securityConfigService.findOneByStackId(STACK_ID)).thenReturn(Optional.of(gatewaySecurityConfig()));
    ArgumentCaptor<ConfigRegistrationRequest> captor = ArgumentCaptor.forClass(ConfigRegistrationRequest.class);
    underTest.reRegisterCluster(stack);
    verify(clusterProxyRegistrationClient).registerConfig(captor.capture());
    ConfigRegistrationRequest proxyRegistrationReq = captor.getValue();
    assertThat(proxyRegistrationReq.getClusterCrn()).isEqualTo(STACK_CRN);
    assertThat(proxyRegistrationReq.getAccountId()).isEqualTo(TEST_ACCOUNT_ID);
    assertTrue(proxyRegistrationReq.isUseCcmV2(), "CCMV2 should be enabled");
    assertNull(proxyRegistrationReq.getCcmV2Configs(), "CCMV2 config should be empty for Jumpgate");
    assertTrue(proxyRegistrationReq.getServices().contains(cmServiceConfigWithInstanceId(PRIMARY_PRIVATE_IP, PRIMARY_INSTANCE_ID)));
    assertTrue(proxyRegistrationReq.getServices().contains(cmServiceConfigWithInstanceId(OTHER_PRIVATE_IP, OTHER_INSTANCE_ID)));
    assertTrue(proxyRegistrationReq.getServices().contains(cmInternalServiceConfig(true)));
    assertEquals("https://10.10.10.10:9443/knox/test-cluster", proxyRegistrationReq.getUriOfKnox(), "CCMV2 Knox URI should match");
    assertTrue(proxyRegistrationReq.getServices().contains(cmServiceConfigWithInstanceId(PRIMARY_PRIVATE_IP, PRIMARY_INSTANCE_ID)));
    assertTrue(proxyRegistrationReq.getServices().contains(cmServiceConfigWithInstanceId(OTHER_PRIVATE_IP, OTHER_INSTANCE_ID)));
    assertTrue(proxyRegistrationReq.getServices().contains(cmInternalServiceConfig(true)));
    assertFalse(proxyRegistrationReq.isUseTunnel(), "CCMV1 tunnel should be disabled.");
    assertNull(proxyRegistrationReq.getTunnels(), "CCMV1 tunnel should not be configured.");
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) ConfigRegistrationRequest(com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationRequest) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 38 with Gateway

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.

the class ClusterProxyServiceTest method testStack.

private Stack testStack() throws JsonProcessingException {
    Stack stack = new Stack();
    stack.setResourceCrn(STACK_CRN);
    stack.setId(STACK_ID);
    stack.setCluster(testCluster());
    stack.setGatewayPort(9443);
    stack.setClusterProxyRegistered(true);
    Cluster cluster = new Cluster();
    Gateway gateway = new Gateway();
    gateway.setPath("test-cluster");
    cluster.setGateway(gateway);
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setInstanceGroupType(InstanceGroupType.GATEWAY);
    InstanceMetaData primaryInstanceMetaData = new InstanceMetaData();
    primaryInstanceMetaData.setPrivateIp(PRIMARY_PRIVATE_IP);
    primaryInstanceMetaData.setPublicIp(PRIMARY_PUBLIC_IP);
    primaryInstanceMetaData.setInstanceId(PRIMARY_INSTANCE_ID);
    primaryInstanceMetaData.setInstanceMetadataType(InstanceMetadataType.GATEWAY_PRIMARY);
    InstanceMetaData instanceMetaData = new InstanceMetaData();
    instanceMetaData.setPrivateIp(OTHER_PRIVATE_IP);
    instanceMetaData.setPublicIp(OTHER_PUBLIC_IP);
    instanceMetaData.setInstanceId(OTHER_INSTANCE_ID);
    instanceGroup.setInstanceMetaData(Set.of(instanceMetaData, primaryInstanceMetaData));
    stack.setInstanceGroups(Set.of(instanceGroup));
    ReflectionTestUtils.setField(cluster, "cloudbreakClusterManagerPassword", new Secret("cloudbreak", vaultSecretString("cbpassword")));
    ReflectionTestUtils.setField(cluster, "cloudbreakClusterManagerUser", new Secret("cloudbreak", vaultSecretString("cbuser")));
    ReflectionTestUtils.setField(cluster, "cloudbreakAmbariPassword", new Secret("cloudbreak", vaultSecretString("cbpassword")));
    ReflectionTestUtils.setField(cluster, "cloudbreakAmbariUser", new Secret("cloudbreak", vaultSecretString("cbuser")));
    ReflectionTestUtils.setField(cluster, "dpClusterManagerUser", new Secret("cmmgmt", vaultSecretString("dpuser")));
    ReflectionTestUtils.setField(cluster, "dpClusterManagerPassword", new Secret("cmmgmt", vaultSecretString("dppassword")));
    ReflectionTestUtils.setField(cluster, "cloudbreakAmbariPassword", new Secret("cmmgmt", vaultSecretString("cbpassword")));
    ReflectionTestUtils.setField(cluster, "cloudbreakAmbariUser", new Secret("cmmgmt", vaultSecretString("cbuser")));
    stack.setCluster(cluster);
    stack.getCluster().setId(1L);
    return stack;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) VaultSecret(com.sequenceiq.cloudbreak.service.secret.vault.VaultSecret) Secret(com.sequenceiq.cloudbreak.service.secret.domain.Secret) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 39 with Gateway

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.

the class ClusterProxyServiceTest method testStackUsingCCMAndKnox.

private Stack testStackUsingCCMAndKnox() throws JsonProcessingException {
    Stack stack = testStackUsingCCM();
    Gateway gateway = new Gateway();
    gateway.setPath("test-cluster");
    stack.getCluster().setGateway(gateway);
    return stack;
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 40 with Gateway

use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.

the class ClusterProxyServiceTest method testStackWithKnox.

private Stack testStackWithKnox() throws JsonProcessingException {
    Stack stack = testStack();
    Gateway gateway = new Gateway();
    gateway.setPath("test-cluster");
    stack.getCluster().setGateway(gateway);
    return stack;
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)69 Test (org.junit.Test)30 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)20 HashSet (java.util.HashSet)17 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)15 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)15 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)15 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)13 ExposedService (com.sequenceiq.cloudbreak.api.service.ExposedService)12 GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)12 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)11 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)11 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)10 IOException (java.io.IOException)10 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)8 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)8 ArrayList (java.util.ArrayList)8 Json (com.sequenceiq.cloudbreak.common.json.Json)7 IdBroker (com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)7 ExposedServices (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices)7