use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class ClusterProxyServiceTest method testReRegisterClusterWhenCCMV2.
@Test
void testReRegisterClusterWhenCCMV2() throws ClusterProxyException, JsonProcessingException {
Stack stack = testStack();
stack.setTunnel(Tunnel.CCMV2);
stack.setCcmV2AgentCrn("testAgentCrn");
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);
assertTrue(proxyRegistrationReq.isUseCcmV2(), "CCMV2 should be enabled");
assertEquals("https://10.10.10.10:9443/knox/test-cluster", proxyRegistrationReq.getUriOfKnox(), "CCMV2 Knox URI should match");
assertTrue(proxyRegistrationReq.getCcmV2Configs().contains(new CcmV2Config("testAgentCrn", "10.10.10.10", ServiceFamilies.GATEWAY.getDefaultPort(), "testAgentCrn-i-abc123", "cloudera-manager")));
assertTrue(proxyRegistrationReq.getCcmV2Configs().contains(new CcmV2Config("testAgentCrn", "10.10.10.11", ServiceFamilies.GATEWAY.getDefaultPort(), "testAgentCrn-i-def456", "cloudera-manager")));
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 CentralCmTemplateUpdaterTest method getKafkaPropertiesWhenNoHdfsInClusterShouldPresentCoreSettings.
@Test
public void getKafkaPropertiesWhenNoHdfsInClusterShouldPresentCoreSettings() {
CoreConfigProvider coreConfigProvider = new CoreConfigProvider();
ReflectionTestUtils.setField(coreConfigProvider, "s3ConfigProvider", s3ConfigProvider);
List<CmTemplateComponentConfigProvider> cmTemplateComponentConfigProviders = List.of(coreConfigProvider);
ReflectionTestUtils.setField(cmTemplateComponentConfigProviderProcessor, "providers", cmTemplateComponentConfigProviders);
S3FileSystem s3FileSystem = new S3FileSystem();
s3FileSystem.setInstanceProfile("profile");
s3FileSystem.setS3GuardDynamoTableName("cb-table");
s3FileSystem.setStorageContainer("cloudbreak-bucket");
StorageLocation storageLocation = new StorageLocation();
storageLocation.setProperty("core_defaultfs");
storageLocation.setValue("s3a://cloudbreak-bucket/kafka");
storageLocation.setConfigFile("core_settings");
StorageLocationView storageLocationView = new StorageLocationView(storageLocation);
BaseFileSystemConfigurationsView baseFileSystemConfigurationsView = new S3FileSystemConfigurationsView(s3FileSystem, Sets.newHashSet(storageLocationView), false);
when(templatePreparationObject.getFileSystemConfigurationView()).thenReturn(Optional.of(baseFileSystemConfigurationsView));
when(templatePreparationObject.getGatewayView()).thenReturn(new GatewayView(new Gateway(), "signkey", new HashSet<>()));
Set<HostgroupView> hostgroupViews = new HashSet<>();
hostgroupViews.add(new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1));
when(templatePreparationObject.getHostgroupViews()).thenReturn(hostgroupViews);
when(templatePreparationObject.getGatewayView()).thenReturn(new GatewayView(new Gateway(), "signkey", new HashSet<>()));
when(blueprintView.getBlueprintText()).thenReturn(getBlueprintText("input/kafka-without-hdfs.bp"));
String generated = generator.getBlueprintText(templatePreparationObject);
String expected = new CmTemplateProcessor(getBlueprintText("output/kafka-without-hdfs.bp")).getTemplate().toString();
String output = new CmTemplateProcessor(generated).getTemplate().toString();
Assert.assertEquals(expected, output);
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class ClusterBootstrapperTest method testcleanupOldSaltState.
@Test
public void testcleanupOldSaltState() throws Exception {
doAnswer(invocation -> {
invocation.getArgument(0, Runnable.class).run();
return null;
}).when(transactionService).required(any(Runnable.class));
when(stackService.getByIdWithListsInTransaction(1L)).thenReturn(stack);
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setPrivateIp("1.1.1.1");
instanceMetaData.setPublicIp("2.2.2.2");
instanceMetaData.setDiscoveryFQDN("FQDN");
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setGroupName("master");
Template template = new Template();
template.setInstanceType("GATEWAY");
instanceGroup.setTemplate(template);
instanceMetaData.setInstanceGroup(instanceGroup);
when(stack.getId()).thenReturn(1L);
when(instanceMetaDataService.getReachableInstanceMetadataByStackId(stack.getId())).thenReturn(Set.of(instanceMetaData));
when(stack.getCustomDomain()).thenReturn("CUSTOM_DOMAIN");
Cluster cluster = new Cluster();
cluster.setGateway(new Gateway());
when(stack.getCluster()).thenReturn(cluster);
GatewayConfig deadConfig = new GatewayConfig("host1", "1.1.1.1", "1.1.1.1", 22, "i-1839", false);
GatewayConfig aliveConfig = new GatewayConfig("host2", "1.1.1.2", "1.1.1.2", 22, "i-1839", false);
when(gatewayConfigService.getAllGatewayConfigs(any())).thenReturn(List.of(deadConfig, aliveConfig));
when(componentConfigProviderService.getImage(anyLong())).thenReturn(image);
when(hostClusterAvailabilityPollingService.pollWithAbsoluteTimeout(any(), any(), anyInt(), anyLong())).thenReturn(new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build());
underTest.bootstrapNewNodes(1L, Set.of("1.1.1.1"));
verify(instanceMetaDataService).getReachableInstanceMetadataByStackId(1L);
verify(gatewayConfigService).getAllGatewayConfigs(stack);
verify(componentConfigProviderService).getImage(1L);
verify(instanceMetaDataService).saveAll(Set.of(instanceMetaData));
verify(hostOrchestrator, never()).removeDeadSaltMinions(deadConfig);
verify(hostOrchestrator, times(1)).removeDeadSaltMinions(aliveConfig);
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class ClusterBootstrapperTest method testcleanupOldSaltStateBothMasterRepaired.
@Test
public void testcleanupOldSaltStateBothMasterRepaired() throws Exception {
doAnswer(invocation -> {
invocation.getArgument(0, Runnable.class).run();
return null;
}).when(transactionService).required(any(Runnable.class));
when(stackService.getByIdWithListsInTransaction(1L)).thenReturn(stack);
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setPrivateIp("1.1.1.1");
instanceMetaData.setPublicIp("2.2.2.2");
instanceMetaData.setDiscoveryFQDN("FQDN");
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setGroupName("master");
Template template = new Template();
template.setInstanceType("GATEWAY");
instanceGroup.setTemplate(template);
instanceMetaData.setInstanceGroup(instanceGroup);
InstanceMetaData instanceMetaData2 = new InstanceMetaData();
instanceMetaData2.setPrivateIp("1.1.1.2");
instanceMetaData2.setPublicIp("3.3.3.3");
instanceMetaData2.setDiscoveryFQDN("FQDN");
instanceMetaData2.setInstanceGroup(instanceGroup);
when(stack.getId()).thenReturn(1L);
when(instanceMetaDataService.getReachableInstanceMetadataByStackId(stack.getId())).thenReturn(Set.of(instanceMetaData, instanceMetaData2));
when(stack.getCustomDomain()).thenReturn("CUSTOM_DOMAIN");
Cluster cluster = new Cluster();
cluster.setGateway(new Gateway());
when(stack.getCluster()).thenReturn(cluster);
GatewayConfig deadConfig1 = new GatewayConfig("host1", "1.1.1.1", "1.1.1.1", 22, "i-1839", false);
GatewayConfig deadConfig2 = new GatewayConfig("host2", "1.1.1.2", "1.1.1.2", 22, "i-1839", false);
when(gatewayConfigService.getAllGatewayConfigs(any())).thenReturn(List.of(deadConfig1, deadConfig2));
when(componentConfigProviderService.getImage(anyLong())).thenReturn(image);
when(hostClusterAvailabilityPollingService.pollWithAbsoluteTimeout(any(), any(), anyInt(), anyLong())).thenReturn(new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build());
underTest.bootstrapNewNodes(1L, Set.of("1.1.1.1", "1.1.1.2"));
verify(instanceMetaDataService).getReachableInstanceMetadataByStackId(1L);
verify(gatewayConfigService).getAllGatewayConfigs(stack);
verify(componentConfigProviderService).getImage(1L);
verify(instanceMetaDataService).saveAll(Set.of(instanceMetaData, instanceMetaData2));
verify(hostOrchestrator, never()).removeDeadSaltMinions(deadConfig1);
verify(hostOrchestrator, never()).removeDeadSaltMinions(deadConfig2);
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class ClusterBootstrapperTest method shouldUseReachableInstances.
@Test
public void shouldUseReachableInstances() throws Exception {
doAnswer(invocation -> {
invocation.getArgument(0, Runnable.class).run();
return null;
}).when(transactionService).required(any(Runnable.class));
when(stackService.getByIdWithListsInTransaction(1L)).thenReturn(stack);
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setPrivateIp("1.1.1.1");
instanceMetaData.setPublicIp("2.2.2.2");
instanceMetaData.setDiscoveryFQDN("FQDN");
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setGroupName("master");
Template template = new Template();
template.setInstanceType("GATEWAY");
instanceGroup.setTemplate(template);
instanceMetaData.setInstanceGroup(instanceGroup);
when(stack.getId()).thenReturn(1L);
when(instanceMetaDataService.getReachableInstanceMetadataByStackId(stack.getId())).thenReturn(Set.of(instanceMetaData));
when(stack.getCustomDomain()).thenReturn("CUSTOM_DOMAIN");
Cluster cluster = new Cluster();
cluster.setGateway(new Gateway());
when(stack.getCluster()).thenReturn(cluster);
GatewayConfig gatewayConfig = new GatewayConfig("host1", "1.1.1.1", "1.1.1.1", 22, "i-1839", false);
when(gatewayConfigService.getAllGatewayConfigs(any())).thenReturn(List.of(gatewayConfig));
when(componentConfigProviderService.getImage(anyLong())).thenReturn(image);
when(hostClusterAvailabilityPollingService.pollWithAbsoluteTimeout(any(), any(), anyInt(), anyLong())).thenReturn(new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build());
underTest.bootstrapNewNodes(1L, Set.of("1.1.1.1"));
verify(instanceMetaDataService).getReachableInstanceMetadataByStackId(1L);
verify(gatewayConfigService).getAllGatewayConfigs(stack);
verify(componentConfigProviderService).getImage(1L);
verify(instanceMetaDataService).saveAll(Set.of(instanceMetaData));
verify(hostOrchestrator, never()).removeDeadSaltMinions(gatewayConfig);
}
Aggregations