Search in sources :

Example 21 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.");
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 22 with CcmConnectivityParameters

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

the class CcmUserDataServiceTest method testFetchAndSaveCcmParametersWhenCcmV1IsEnabled.

@Test
void testFetchAndSaveCcmParametersWhenCcmV1IsEnabled() {
    Stack stack = getAStack();
    stack.setTunnel(Tunnel.CCM);
    DefaultCcmParameters defaultCcmParameters = mock(DefaultCcmParameters.class);
    ServerParameters serverParameters = mock(ServerParameters.class);
    when(crnService.getUserCrn()).thenReturn(TEST_USER_CRN);
    when(ccmParameterSupplier.getCcmParameters(anyString(), anyString(), anyString(), anyMap())).thenReturn(Optional.of(defaultCcmParameters));
    when(defaultCcmParameters.getServerParameters()).thenReturn(serverParameters);
    when(serverParameters.getMinaSshdServiceId()).thenReturn("minaSshServiceId");
    when(stackService.getStackById(stack.getId())).thenReturn(stack);
    CcmConnectivityParameters ccmParameters = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.fetchAndSaveCcmParameters(stack));
    assertEquals(CcmConnectivityMode.CCMV1, ccmParameters.getConnectivityMode(), "CCM V1 should be enabled.");
    assertEquals(defaultCcmParameters, ccmParameters.getCcmParameters(), "CCM Parameters should match.");
    verify(ccmParameterSupplier, times(1)).getCcmParameters(anyString(), anyString(), anyString(), anyMap());
    verifyNoInteractions(ccmV2ParameterSupplier);
    assertEquals("minaSshServiceId", stack.getMinaSshdServiceId(), "Ccm V1 Config should be initialized");
    verify(stackService, times(1)).save(stack);
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) ServerParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.ServerParameters) DefaultCcmParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmParameters) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 23 with CcmConnectivityParameters

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

the class CcmUserDataServiceTest method testFetchAndSaveCcmParametersWhenCcmV2JumpgateIsEnabled.

@Test
void testFetchAndSaveCcmParametersWhenCcmV2JumpgateIsEnabled() {
    Stack stack = getAStack();
    stack.setTunnel(Tunnel.CCMV2_JUMPGATE);
    DefaultCcmV2JumpgateParameters defaultCcmV2JumpgateParameters = mock(DefaultCcmV2JumpgateParameters.class);
    FreeIpa freeIpa = mock(FreeIpa.class);
    when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
    when(freeIpa.getDomain()).thenReturn("cldr.work.site");
    when(ccmV2JumpgateParameterSupplier.getCcmV2JumpgateParameters(anyString(), any(Optional.class), anyString(), anyString())).thenReturn(defaultCcmV2JumpgateParameters);
    when(defaultCcmV2JumpgateParameters.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_JUMPGATE, ccmParameters.getConnectivityMode(), "CCM V2 Jumpgate should be enabled.");
    assertEquals(defaultCcmV2JumpgateParameters, ccmParameters.getCcmV2JumpgateParameters(), "CCM V2 Jumpgate Parameters should match.");
    verify(ccmV2JumpgateParameterSupplier, times(1)).getCcmV2JumpgateParameters(anyString(), any(Optional.class), anyString(), anyString());
    verifyNoInteractions(ccmParameterSupplier);
    verify(stackService, times(1)).setCcmV2AgentCrnByStackId(100L, "testAgentCrn");
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) Optional(java.util.Optional) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 24 with CcmConnectivityParameters

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

the class UserDataBuilderTest method testBuildUserDataWithoutCCMParams.

@Test
@DisplayName("test if NO CCM parameters are passed the user data does not contain them")
void testBuildUserDataWithoutCCMParams() throws IOException {
    PlatformParameters platformParameters = mock(PlatformParameters.class);
    ScriptParams scriptParams = mock(ScriptParams.class);
    when(scriptParams.getDiskPrefix()).thenReturn("sd");
    when(scriptParams.getStartLabel()).thenReturn(98);
    when(platformParameters.scriptParams()).thenReturn(scriptParams);
    String userData = underTest.buildUserData(ACCOUNT_ID, environment, Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", platformParameters, "pass", "cert", new CcmConnectivityParameters(), null);
    String expectedUserData = FileReaderUtils.readFileFromClasspath("azure-init.sh");
    assertEquals(expectedUserData, userData);
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) ScriptParams(com.sequenceiq.cloudbreak.cloud.model.ScriptParams) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 25 with CcmConnectivityParameters

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

the class UserDataBuilderTest method testBuildUserDataWithCCMParams.

@Test
@DisplayName("test if CCM parameters are passed the user data contains them")
void testBuildUserDataWithCCMParams() throws IOException {
    BaseServiceEndpoint serviceEndpoint = new BaseServiceEndpoint(new HostEndpoint("ccm.cloudera.com"));
    DefaultServerParameters serverParameters = new DefaultServerParameters(serviceEndpoint, "pub-key", "mina-id");
    DefaultInstanceParameters instanceParameters = new DefaultInstanceParameters("tunnel-id", "key-id", "private-key");
    DefaultTunnelParameters nginxTunnel = new DefaultTunnelParameters(KnownServiceIdentifier.GATEWAY, 9443);
    CcmParameters ccmParameters = new DefaultCcmParameters(serverParameters, instanceParameters, List.of(nginxTunnel));
    CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmParameters);
    ProxyAuthentication proxyAuthentication = ProxyAuthentication.builder().withUserName("user").withPassword("pwd").build();
    ProxyConfig proxyConfig = ProxyConfig.builder().withServerHost("proxy.host").withServerPort(1234).withProxyAuthentication(proxyAuthentication).withNoProxyHosts("noproxy.com").withProtocol("https").build();
    PlatformParameters platformParameters = mock(PlatformParameters.class);
    ScriptParams scriptParams = mock(ScriptParams.class);
    when(scriptParams.getDiskPrefix()).thenReturn("sd");
    when(scriptParams.getStartLabel()).thenReturn(98);
    when(platformParameters.scriptParams()).thenReturn(scriptParams);
    String userData = underTest.buildUserData(ACCOUNT_ID, environment, Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", platformParameters, "pass", "cert", ccmConnectivityParameters, proxyConfig);
    String expectedUserData = FileReaderUtils.readFileFromClasspath("azure-ccm-init.sh");
    assertEquals(expectedUserData, userData);
}
Also used : DefaultCcmParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmParameters) ProxyAuthentication(com.sequenceiq.cloudbreak.dto.ProxyAuthentication) ScriptParams(com.sequenceiq.cloudbreak.cloud.model.ScriptParams) ProxyConfig(com.sequenceiq.cloudbreak.dto.ProxyConfig) DefaultCcmParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmParameters) CcmParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmParameters) CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) BaseServiceEndpoint(com.sequenceiq.cloudbreak.ccm.endpoint.BaseServiceEndpoint) DefaultInstanceParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultInstanceParameters) HostEndpoint(com.sequenceiq.cloudbreak.ccm.endpoint.HostEndpoint) DefaultServerParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultServerParameters) DefaultTunnelParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultTunnelParameters) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

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