use of com.sequenceiq.cloudbreak.clusterproxy.TunnelEntry in project cloudbreak by hortonworks.
the class ClusterProxyService method tunnelEntries.
private List<TunnelEntry> tunnelEntries(Stack stack) {
List<TunnelEntry> entries = new ArrayList<>();
stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata().forEach(md -> {
String gatewayIp = md.getPrivateIp();
TunnelEntry gatewayTunnel = new TunnelEntry(md.getInstanceId(), KnownServiceIdentifier.GATEWAY.name(), gatewayIp, ServiceFamilies.GATEWAY.getDefaultPort(), stack.getMinaSshdServiceId());
TunnelEntry knoxTunnel = new TunnelEntry(md.getInstanceId(), KnownServiceIdentifier.KNOX.name(), gatewayIp, ServiceFamilies.KNOX.getDefaultPort(), stack.getMinaSshdServiceId());
entries.add(gatewayTunnel);
entries.add(knoxTunnel);
});
return entries;
}
use of com.sequenceiq.cloudbreak.clusterproxy.TunnelEntry in project cloudbreak by hortonworks.
the class ClusterProxyServiceTest method testClusterProxyRegistrationWhenCCMV1.
@Test
public void testClusterProxyRegistrationWhenCCMV1() {
Stack aStack = getAStack();
aStack.setTunnel(Tunnel.CCM);
aStack.setMinaSshdServiceId("minaSshdServiceId");
GatewayConfig gatewayConfig = new GatewayConfig("connectionAddress", "publicAddress", PRIVATE_ADDRESS, 9443, "instanceId", false);
ConfigRegistrationResponse configRegResponse = mock(ConfigRegistrationResponse.class);
FreeIpa freeIpa = new FreeIpa();
freeIpa.setDomain("ipadom");
when(stackService.getStackById(STACK_ID)).thenReturn(aStack);
when(clusterProxyEnablementService.isClusterProxyApplicable(any())).thenReturn(true);
when(gatewayConfigService.getPrimaryGatewayConfig(aStack)).thenReturn(gatewayConfig);
when(securityConfigService.findOneByStack(aStack)).thenReturn(null);
when(clusterProxyRegistrationClient.registerConfig(any())).thenReturn(configRegResponse);
when(stackUpdater.updateClusterProxyRegisteredFlag(aStack, true)).thenReturn(aStack);
when(freeIpaService.findByStack(aStack)).thenReturn(freeIpa);
underTest.registerFreeIpaForBootstrap(STACK_ID);
ArgumentCaptor<ConfigRegistrationRequest> captor = ArgumentCaptor.forClass(ConfigRegistrationRequest.class);
verify(clusterProxyRegistrationClient).registerConfig(captor.capture());
ConfigRegistrationRequest proxyRegistrationReq = captor.getValue();
assertThat(proxyRegistrationReq.getClusterCrn()).isEqualTo(STACK_RESOURCE_CRN);
assertThat(proxyRegistrationReq.getAccountId()).isEqualTo(TEST_ACCOUNT_ID);
assertFalse(proxyRegistrationReq.isUseCcmV2(), "CCMV2 should not be enabled.");
assertTrue(proxyRegistrationReq.isUseTunnel(), "CCMV1 tunnel should be enabled");
assertEquals(List.of(new TunnelEntry("instanceId", "GATEWAY", PRIVATE_ADDRESS, 9443, "minaSshdServiceId")), proxyRegistrationReq.getTunnels(), "CCMV1 tunnel should be configured.");
assertThat(proxyRegistrationReq.getServices()).contains(new ClusterServiceConfig("freeipa", List.of("https://privateAddress:9443"), List.of(), null));
assertThat(proxyRegistrationReq.getServices()).contains(new ClusterServiceConfig("freeipa.ipadom", List.of("https://privateAddress:9443"), List.of(), null));
}
Aggregations