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