Search in sources :

Example 1 with ServerParameters

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

the class CcmUserDataServiceTest method testFetchAndSaveCcmParametersWhenCcmV1IsEnabled.

@Test
public void testFetchAndSaveCcmParametersWhenCcmV1IsEnabled() {
    Stack stack = getAStack();
    stack.setTunnel(Tunnel.CCM);
    DefaultCcmParameters defaultCcmParameters = mock(DefaultCcmParameters.class);
    ServerParameters mockServerParameters = mock(ServerParameters.class);
    when(ccmParameterSupplier.getCcmParameters(anyString(), anyString(), anyString(), anyMap())).thenReturn(Optional.of(defaultCcmParameters));
    when(defaultCcmParameters.getServerParameters()).thenReturn(mockServerParameters);
    when(mockServerParameters.getMinaSshdServiceId()).thenReturn("minaSshdServiceId");
    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);
    verify(stackService, times(1)).setMinaSshdServiceIdByStackId(100L, "minaSshdServiceId");
    verify(stackService, never()).setCcmV2AgentCrnByStackId(any(), any());
}
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.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 2 with ServerParameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.ServerParameters 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)

Aggregations

CcmConnectivityParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters)2 DefaultCcmParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmParameters)2 ServerParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.ServerParameters)2 Test (org.junit.jupiter.api.Test)2 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 Stack (com.sequenceiq.freeipa.entity.Stack)1