Search in sources :

Example 1 with CcmConnectivityParameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters in project cloudbreak by hortonworks.

the class CcmUserDataServiceTest method testFetchAndSaveCcmParametersWhenCcmV2IsEnabled.

@Test
public void testFetchAndSaveCcmParametersWhenCcmV2IsEnabled() {
    Stack stack = getAStack();
    stack.setTunnel(Tunnel.CCMV2);
    DefaultCcmV2Parameters defaultCcmV2Parameters = mock(DefaultCcmV2Parameters.class);
    when(ccmV2ParameterSupplier.getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString())).thenReturn(defaultCcmV2Parameters);
    when(defaultCcmV2Parameters.getAgentCrn()).thenReturn("testAgentCrn");
    when(hostDiscoveryService.determineGatewayFqdn(any(), any())).thenReturn("datahub.master0.cldr.work.site");
    CcmConnectivityParameters ccmParameters = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.fetchAndSaveCcmParameters(stack));
    assertEquals(CcmConnectivityMode.CCMV2, ccmParameters.getConnectivityMode(), "CCM V2 should be enabled.");
    assertEquals(defaultCcmV2Parameters, ccmParameters.getCcmV2Parameters(), "CCM V2 Parameters should match.");
    verify(ccmV2ParameterSupplier, times(1)).getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString());
    verifyNoInteractions(ccmParameterSupplier);
    verify(stackService, times(1)).setCcmV2AgentCrnByStackId(100L, "testAgentCrn");
    verify(stackService, never()).setMinaSshdServiceIdByStackId(any(), any());
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) Optional(java.util.Optional) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 2 with CcmConnectivityParameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters in project cloudbreak by hortonworks.

the class CcmUserDataServiceTest method testFetchAndSaveCcmParametersWhenCcmTunnelNotEnabled.

@Test
void testFetchAndSaveCcmParametersWhenCcmTunnelNotEnabled() {
    Stack stack = getAStack();
    CcmConnectivityParameters ccmNotEnabled = underTest.fetchAndSaveCcmParameters(stack);
    assertEquals(CcmConnectivityMode.NONE, ccmNotEnabled.getConnectivityMode(), "CCM should not be enabled.");
    verify(stackService, never()).setCcmV2AgentCrnByStackId(any(), any());
    verify(stackService, never()).setMinaSshdServiceIdByStackId(any(), any());
    verifyNoInteractions(ccmV2ParameterSupplier);
    verifyNoInteractions(ccmParameterSupplier);
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 3 with CcmConnectivityParameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters in project cloudbreak by hortonworks.

the class UserDataBuilderTest method testBuildUserDataAzure.

@Test
public void testBuildUserDataAzure() throws IOException {
    String expectedGwScript = FileReaderUtils.readFileFromClasspath("azure-gateway-init.sh");
    String expectedCoreScript = FileReaderUtils.readFileFromClasspath("azure-core-init.sh");
    Map<InstanceGroupType, String> userdata = underTest.buildUserData(Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", getPlatformParameters(), "pass", "cert", new CcmConnectivityParameters(), null);
    Assert.assertEquals(expectedGwScript, userdata.get(InstanceGroupType.GATEWAY));
    Assert.assertEquals(expectedCoreScript, userdata.get(InstanceGroupType.CORE));
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) Test(org.junit.Test)

Example 4 with CcmConnectivityParameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters in project cloudbreak by hortonworks.

the class SaltConfigProviderTest method testGetSaltConfig.

@Test
public void testGetSaltConfig() throws Exception {
    Stack stack = mock(Stack.class);
    when(stack.getCcmParameters()).thenReturn(new CcmConnectivityParameters(new DefaultCcmV2JumpgateParameters()));
    FreeIpaConfigView freeIpaConfigView = mock(FreeIpaConfigView.class);
    Map freeIpaConfigViewMap = mock(Map.class);
    when(freeIpaConfigService.createFreeIpaConfigs(any(), any())).thenReturn(freeIpaConfigView);
    when(stack.getCloudPlatform()).thenReturn(CLOUD_PLATFORM);
    when(freeIpaConfigView.toMap()).thenReturn(freeIpaConfigViewMap);
    when(telemetryConfigService.createTelemetryPillarConfig(any())).thenReturn(Map.of());
    when(proxyConfigService.createProxyPillarConfig(any())).thenReturn(Map.of());
    when(tagConfigService.createTagsPillarConfig(any())).thenReturn(Map.of());
    when(ccmParametersConfigService.createCcmParametersPillarConfig(any(), any())).thenReturn(Map.of(PILLAR, new SaltPillarProperties(PILLARPATH, Map.of(PILLARKEY, PILLARVALUE))));
    SaltConfig saltConfig = underTest.getSaltConfig(stack, Set.of());
    Map<String, SaltPillarProperties> servicePillarConfig = saltConfig.getServicePillarConfig();
    assertNotNull(servicePillarConfig);
    SaltPillarProperties freeIpaProperties = servicePillarConfig.get("freeipa");
    assertNotNull(freeIpaProperties);
    assertEquals("/freeipa/init.sls", freeIpaProperties.getPath());
    assertEquals(freeIpaConfigViewMap, freeIpaProperties.getProperties().get("freeipa"));
    SaltPillarProperties discoveryProperties = servicePillarConfig.get("discovery");
    assertNotNull(discoveryProperties);
    assertEquals("/discovery/init.sls", discoveryProperties.getPath());
    assertEquals(CLOUD_PLATFORM, discoveryProperties.getProperties().get("platform"));
    SaltPillarProperties pillarProperties = servicePillarConfig.get(PILLAR);
    assertNotNull(pillarProperties);
    assertEquals(PILLARPATH, pillarProperties.getPath());
    assertEquals(PILLARVALUE, pillarProperties.getProperties().get(PILLARKEY));
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) FreeIpaConfigView(com.sequenceiq.freeipa.service.freeipa.config.FreeIpaConfigView) Map(java.util.Map) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 5 with CcmConnectivityParameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters in project cloudbreak by hortonworks.

the class CcmUserDataServiceTest method testFetchAndSaveCcmParametersWhenCcmV2IsEnabled.

@Test
void testFetchAndSaveCcmParametersWhenCcmV2IsEnabled() {
    Stack stack = getAStack();
    stack.setTunnel(Tunnel.CCMV2);
    DefaultCcmV2Parameters defaultCcmV2Parameters = mock(DefaultCcmV2Parameters.class);
    FreeIpa freeIpa = mock(FreeIpa.class);
    when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
    when(freeIpa.getDomain()).thenReturn("cldr.work.site");
    when(ccmV2ParameterSupplier.getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString())).thenReturn(defaultCcmV2Parameters);
    when(defaultCcmV2Parameters.getAgentCrn()).thenReturn("testAgentCrn");
    when(hostDiscoveryService.determineGatewayFqdn(any(), any())).thenReturn("datahub.master0.cldr.work.site");
    CcmConnectivityParameters ccmParameters = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.fetchAndSaveCcmParameters(stack));
    assertEquals(CcmConnectivityMode.CCMV2, ccmParameters.getConnectivityMode(), "CCM V2 should be enabled.");
    assertEquals(defaultCcmV2Parameters, ccmParameters.getCcmV2Parameters(), "CCM V2 Parameters should match.");
    verify(ccmV2ParameterSupplier, times(1)).getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString());
    verifyNoInteractions(ccmParameterSupplier);
    verify(stackService, times(1)).setCcmV2AgentCrnByStackId(100L, "testAgentCrn");
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) Optional(java.util.Optional) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

CcmConnectivityParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters)28 Test (org.junit.jupiter.api.Test)12 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)7 PlatformParameters (com.sequenceiq.cloudbreak.cloud.PlatformParameters)6 Stack (com.sequenceiq.freeipa.entity.Stack)6 Test (org.junit.Test)6 DefaultCcmV2JumpgateParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters)5 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)5 ProxyConfig (com.sequenceiq.cloudbreak.dto.ProxyConfig)5 CcmParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmParameters)4 CcmV2Parameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters)4 DefaultCcmParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmParameters)4 DefaultCcmV2Parameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters)4 ScriptParams (com.sequenceiq.cloudbreak.cloud.model.ScriptParams)4 DisplayName (org.junit.jupiter.api.DisplayName)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 CcmV2JumpgateParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters)3 Optional (java.util.Optional)3 DefaultInstanceParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultInstanceParameters)2 DefaultServerParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultServerParameters)2