Search in sources :

Example 16 with Gateway

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.");
}
Also used : Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) ConfigRegistrationRequest(com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationRequest) CcmV2Config(com.sequenceiq.cloudbreak.clusterproxy.CcmV2Config) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with Gateway

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);
}
Also used : StorageLocationView(com.sequenceiq.cloudbreak.template.filesystem.StorageLocationView) CoreConfigProvider(com.sequenceiq.cloudbreak.cmtemplate.configproviders.core.CoreConfigProvider) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) S3FileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.s3.S3FileSystemConfigurationsView) S3FileSystem(com.sequenceiq.common.api.filesystem.S3FileSystem) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) StorageLocation(com.sequenceiq.cloudbreak.domain.StorageLocation) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) GatewayView(com.sequenceiq.cloudbreak.template.views.GatewayView) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 18 with Gateway

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);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Template(com.sequenceiq.cloudbreak.domain.Template) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Test(org.junit.Test)

Example 19 with Gateway

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);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Template(com.sequenceiq.cloudbreak.domain.Template) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Test(org.junit.Test)

Example 20 with Gateway

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);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Template(com.sequenceiq.cloudbreak.domain.Template) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Test(org.junit.Test)

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