Search in sources :

Example 1 with CcmV2Parameters

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

the class DefaultCcmV2ParameterSupplierTest method testGetCcmV2Parameter.

@Test
void testGetCcmV2Parameter() {
    setupRegisterInvertingProxyDetails();
    CcmV2Parameters resultParameters = underTest.getCcmV2Parameters(TEST_ACCOUNT_ID, Optional.of(TEST_ENVIRONMENT_CRN), TEST_GATEWAY_DOMAIN, Crn.fromString(TEST_CLUSTER_CRN).getResource());
    assertResult(resultParameters);
    verify(ccmV2Client).listInvertingProxyAgents(anyString(), eq(TEST_ACCOUNT_ID), eq(Optional.of(TEST_ENVIRONMENT_CRN)));
    verify(ccmV2Client).registerInvertingProxyAgent(anyString(), eq(TEST_ACCOUNT_ID), eq(Optional.of(TEST_ENVIRONMENT_CRN)), eq(TEST_GATEWAY_DOMAIN), eq(TEST_RESOURCE_ID));
    verify(ccmV2Client, never()).deregisterInvertingProxyAgent(any(), any());
}
Also used : CcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters) Test(org.junit.jupiter.api.Test)

Example 2 with CcmV2Parameters

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

the class CcmUserDataService method getCcmV2ConnectivityParameters.

private CcmConnectivityParameters getCcmV2ConnectivityParameters(Stack stack) {
    String generatedGatewayFqdn = getGatewayFqdn(stack);
    CcmV2Parameters ccmV2Parameters = ccmV2ParameterSupplier.getCcmV2Parameters(ThreadBasedUserCrnProvider.getAccountId(), Optional.empty(), generatedGatewayFqdn, CcmResourceUtil.getKeyId(stack.getResourceCrn()));
    CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2Parameters);
    saveCcmV2Config(stack.getId(), ccmV2Parameters);
    return ccmConnectivityParameters;
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) CcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters)

Example 3 with CcmV2Parameters

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

the class UserDataBuilderTest method testBuildUserDataWithCCMV2.

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

Example 4 with CcmV2Parameters

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

the class DefaultCcmV2ParameterSupplierTest method unregisterAgentIsCalledWhenExisted.

@Test
void unregisterAgentIsCalledWhenExisted() {
    setupRegisterInvertingProxyDetails();
    when(ccmV2Client.listInvertingProxyAgents(any(), any(), any())).thenReturn(List.of(InvertingProxyAgent.newBuilder().setAgentCrn(TEST_AGENT_CRN).build()));
    CcmV2Parameters resultParameters = underTest.getCcmV2Parameters(TEST_ACCOUNT_ID, Optional.of(TEST_ENVIRONMENT_CRN), TEST_GATEWAY_DOMAIN, Crn.fromString(TEST_CLUSTER_CRN).getResource());
    assertResult(resultParameters);
    verify(ccmV2Client).listInvertingProxyAgents(anyString(), eq(TEST_ACCOUNT_ID), eq(Optional.of(TEST_ENVIRONMENT_CRN)));
    verify(ccmV2Client).registerInvertingProxyAgent(anyString(), eq(TEST_ACCOUNT_ID), eq(Optional.of(TEST_ENVIRONMENT_CRN)), eq(TEST_GATEWAY_DOMAIN), eq(TEST_RESOURCE_ID));
    verify(ccmV2Client).deregisterInvertingProxyAgent(any(), eq(TEST_AGENT_CRN));
}
Also used : CcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters) Test(org.junit.jupiter.api.Test)

Example 5 with CcmV2Parameters

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

the class UserDataBuilderTest method testBuildUserDataWithCCMV2Params.

@Test
@DisplayName("test if CCM V2 parameters are passed the user data contains them")
void testBuildUserDataWithCCMV2Params() throws IOException {
    CcmV2Parameters ccmV2Parameters = new DefaultCcmV2Parameters("invertingProxyHost", "invertingProxyCertificate", "agentCrn", "agentKeyId", "agentEncipheredPrivateKey", "agentCertificate");
    CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2Parameters);
    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, null);
    String expectedUserData = FileReaderUtils.readFileFromClasspath("azure-ccm-v2-init.sh");
    assertEquals(expectedUserData, userData);
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters) ScriptParams(com.sequenceiq.cloudbreak.cloud.model.ScriptParams) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) CcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

CcmV2Parameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters)6 CcmConnectivityParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters)4 Test (org.junit.jupiter.api.Test)3 DefaultCcmV2Parameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters)2 PlatformParameters (com.sequenceiq.cloudbreak.cloud.PlatformParameters)1 ScriptParams (com.sequenceiq.cloudbreak.cloud.model.ScriptParams)1 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)1 Test (org.junit.Test)1 DisplayName (org.junit.jupiter.api.DisplayName)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1