Search in sources :

Example 41 with ClouderaManagerRepo

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.

the class ClouderaManagerSetupServiceTest method testConfigureKerberosWhenCMVersionIsHigherThen630ShouldCallConfigureKerberos.

@Test
public void testConfigureKerberosWhenCMVersionIsHigherThen630ShouldCallConfigureKerberos() throws Exception {
    KerberosConfig kerberosConfig = mock(KerberosConfig.class);
    ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
    clouderaManagerRepo.setVersion("6.5.0");
    when(clusterComponentProvider.getClouderaManagerRepoDetails(anyLong())).thenReturn(clouderaManagerRepo);
    underTest.configureKerberos(kerberosConfig);
    verify(kerberosService, times(0)).configureKerberosViaApi(any(ApiClient.class), any(HttpClientConfig.class), any(Stack.class), any(KerberosConfig.class));
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) KerberosConfig(com.sequenceiq.cloudbreak.dto.KerberosConfig) ApiClient(com.cloudera.api.swagger.client.ApiClient) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 42 with ClouderaManagerRepo

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.

the class ClouderaManagerSetupServiceTest method testSetupProxyWhenProxysetupThrowApiExceptionShouldThrowClouderaManagerOperationFailedException.

@Test
public void testSetupProxyWhenProxysetupThrowApiExceptionShouldThrowClouderaManagerOperationFailedException() throws ApiException {
    ApiException error = mock(ApiException.class);
    ClouderaManagerResourceApi clouderaManagerResourceApi = mock(ClouderaManagerResourceApi.class);
    when(clouderaManagerApiFactory.getClouderaManagerResourceApi(any(ApiClient.class))).thenReturn(clouderaManagerResourceApi);
    doThrow(error).when(clouderaManagerResourceApi).updateConfig(anyString(), any(ApiConfigList.class));
    ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
    clouderaManagerRepo.setVersion("7.1.0");
    when(clusterComponentProvider.getClouderaManagerRepoDetails(anyLong())).thenReturn(clouderaManagerRepo);
    ClouderaManagerOperationFailedException actual = assertThrows(ClouderaManagerOperationFailedException.class, () -> underTest.setupProxy(testProxyConfig()));
    verify(clouderaManagerResourceApi, times(1)).updateConfig(anyString(), any(ApiConfigList.class));
    assertEquals(ClouderaManagerOperationFailedException.class, actual.getClass());
}
Also used : ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) ApiClient(com.cloudera.api.swagger.client.ApiClient) ApiException(com.cloudera.api.swagger.client.ApiException) Test(org.junit.jupiter.api.Test)

Example 43 with ClouderaManagerRepo

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.

the class ClouderaManagerSetupServiceTest method testConfigureKerberosWhenCMVersionIsLowerThen630ShouldCallConfigureKerberos.

@Test
public void testConfigureKerberosWhenCMVersionIsLowerThen630ShouldCallConfigureKerberos() throws Exception {
    KerberosConfig kerberosConfig = mock(KerberosConfig.class);
    ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
    clouderaManagerRepo.setVersion("6.2.0");
    when(clusterComponentProvider.getClouderaManagerRepoDetails(anyLong())).thenReturn(clouderaManagerRepo);
    doNothing().when(kerberosService).configureKerberosViaApi(any(ApiClient.class), any(HttpClientConfig.class), any(Stack.class), any(KerberosConfig.class));
    underTest.configureKerberos(kerberosConfig);
    verify(kerberosService, times(1)).configureKerberosViaApi(any(ApiClient.class), any(HttpClientConfig.class), any(Stack.class), any(KerberosConfig.class));
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) KerberosConfig(com.sequenceiq.cloudbreak.dto.KerberosConfig) ApiClient(com.cloudera.api.swagger.client.ApiClient) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 44 with ClouderaManagerRepo

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.

the class ClouderaManagerSetupServiceTest method testRefreshParcelReposWhenApiExceptionOccursShouldThrowCloudbreakServiceException.

@Test
public void testRefreshParcelReposWhenApiExceptionOccursShouldThrowCloudbreakServiceException() {
    ClouderaManagerRepo clouderaManagerRepo = mock(ClouderaManagerRepo.class);
    when(clouderaManagerRepo.getPredefined()).thenReturn(true);
    when(clusterComponentProvider.getClouderaManagerRepoDetails(anyLong())).thenReturn(clouderaManagerRepo);
    doThrow(new ClouderaManagerOperationFailedException("error")).when(clouderaManagerApiFactory).getClouderaManagerResourceApi(any(ApiClient.class));
    CloudbreakServiceException actual = assertThrows(CloudbreakServiceException.class, () -> underTest.refreshParcelRepos());
    assertEquals(CloudbreakServiceException.class, actual.getClass());
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) ApiClient(com.cloudera.api.swagger.client.ApiClient) Test(org.junit.jupiter.api.Test)

Example 45 with ClouderaManagerRepo

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo in project cloudbreak by hortonworks.

the class ClouderaManagerSetupServiceTest method testConfigureKerberosWhenThrowApiExceptionThenShouldThrowClouderaManagerOperationFailedException.

@Test
public void testConfigureKerberosWhenThrowApiExceptionThenShouldThrowClouderaManagerOperationFailedException() throws Exception {
    ApiException error = mock(ApiException.class);
    KerberosConfig kerberosConfig = mock(KerberosConfig.class);
    ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
    clouderaManagerRepo.setVersion("6.2.0");
    when(error.getResponseBody()).thenReturn(null);
    when(error.getMessage()).thenReturn("error");
    when(clusterComponentProvider.getClouderaManagerRepoDetails(anyLong())).thenReturn(clouderaManagerRepo);
    doThrow(error).when(kerberosService).configureKerberosViaApi(any(ApiClient.class), any(HttpClientConfig.class), any(Stack.class), any(KerberosConfig.class));
    ClouderaManagerOperationFailedException actual = assertThrows(ClouderaManagerOperationFailedException.class, () -> underTest.configureKerberos(kerberosConfig));
    verify(kerberosService, times(1)).configureKerberosViaApi(any(ApiClient.class), any(HttpClientConfig.class), any(Stack.class), any(KerberosConfig.class));
    assertEquals(ClouderaManagerOperationFailedException.class, actual.getClass());
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) KerberosConfig(com.sequenceiq.cloudbreak.dto.KerberosConfig) ApiClient(com.cloudera.api.swagger.client.ApiClient) ApiException(com.cloudera.api.swagger.client.ApiException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)96 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)40 Test (org.junit.jupiter.api.Test)38 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)28 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)17 ApiClient (com.cloudera.api.swagger.client.ApiClient)15 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)15 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)15 Test (org.junit.Test)15 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)14 DisplayName (org.junit.jupiter.api.DisplayName)14 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)13 MethodSource (org.junit.jupiter.params.provider.MethodSource)13 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)12 Map (java.util.Map)10 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)9 BigDecimal (java.math.BigDecimal)9 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)8