Search in sources :

Example 46 with ClouderaManagerRepo

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

the class ClouderaManagerSetupServiceTest method testRefreshParcelReposWithPreWarmedImageShouldCallStartPollingCmParcelRepositoryRefresh.

@Test
public void testRefreshParcelReposWithPreWarmedImageShouldCallStartPollingCmParcelRepositoryRefresh() throws Exception {
    ClouderaManagerRepo clouderaManagerRepo = mock(ClouderaManagerRepo.class);
    ClouderaManagerResourceApi clouderaManagerResourceApi = mock(ClouderaManagerResourceApi.class);
    ApiCommand apiCommand = mock(ApiCommand.class);
    when(clouderaManagerRepo.getPredefined()).thenReturn(true);
    when(clusterComponentProvider.getClouderaManagerRepoDetails(anyLong())).thenReturn(clouderaManagerRepo);
    when(clouderaManagerApiFactory.getClouderaManagerResourceApi(any(ApiClient.class))).thenReturn(clouderaManagerResourceApi);
    when(apiCommand.getId()).thenReturn(BigDecimal.ONE);
    when(clouderaManagerResourceApi.refreshParcelRepos()).thenReturn(apiCommand);
    when(clouderaManagerPollingServiceProvider.startPollingCmParcelRepositoryRefresh(any(Stack.class), any(ApiClient.class), any(BigDecimal.class))).thenReturn(new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build());
    underTest.refreshParcelRepos();
    verify(clouderaManagerPollingServiceProvider, times(1)).startPollingCmParcelRepositoryRefresh(any(Stack.class), any(ApiClient.class), any(BigDecimal.class));
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) ApiClient(com.cloudera.api.swagger.client.ApiClient) BigDecimal(java.math.BigDecimal) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 47 with ClouderaManagerRepo

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

the class ClouderaManagerSetupServiceTest method testInstallClusterWhenEverythingWorksFineShouldPollTheInsallProgress.

@Test
public void testInstallClusterWhenEverythingWorksFineShouldPollTheInsallProgress() throws ApiException {
    ClustersResourceApi clustersResourceApi = mock(ClustersResourceApi.class);
    ApiCommand apiCommand = mock(ApiCommand.class);
    ApiCluster apiCluster = mock(ApiCluster.class);
    ClusterCommand clusterCommand = mock(ClusterCommand.class);
    ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
    clouderaManagerRepo.setVersion("6.2.0");
    ClouderaManagerResourceApi clouderaManagerResourceApi = mock(ClouderaManagerResourceApi.class);
    when(clusterComponentProvider.getClouderaManagerRepoDetails(anyLong())).thenReturn(clouderaManagerRepo);
    when(clouderaManagerApiFactory.getClustersResourceApi(any(ApiClient.class))).thenReturn(clustersResourceApi);
    when(clustersResourceApi.readCluster(anyString())).thenReturn(apiCluster);
    when(clusterCommandRepository.findTopByClusterIdAndClusterCommandType(anyLong(), any(ClusterCommandType.class))).thenReturn(Optional.empty());
    when(apiCommand.getId()).thenReturn(BigDecimal.ONE);
    when(clusterCommand.getCommandId()).thenReturn(BigDecimal.ONE);
    when(clouderaManagerApiFactory.getClouderaManagerResourceApi(any(ApiClient.class))).thenReturn(clouderaManagerResourceApi);
    when(clouderaManagerResourceApi.importClusterTemplate(anyBoolean(), any(ApiClusterTemplate.class))).thenReturn(apiCommand);
    when(clusterCommandRepository.save(any(ClusterCommand.class))).thenReturn(clusterCommand);
    when(clouderaManagerPollingServiceProvider.startPollingCmTemplateInstallation(any(Stack.class), any(ApiClient.class), any(BigDecimal.class))).thenReturn(new ExtendedPollingResult.ExtendedPollingResultBuilder().exit().build());
    underTest.installCluster("{}");
    verify(clouderaManagerPollingServiceProvider, times(1)).startPollingCmTemplateInstallation(any(Stack.class), any(ApiClient.class), any(BigDecimal.class));
    verify(clusterCommandRepository, times(1)).save(any(ClusterCommand.class));
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ApiCluster(com.cloudera.api.swagger.model.ApiCluster) ApiClient(com.cloudera.api.swagger.client.ApiClient) ClustersResourceApi(com.cloudera.api.swagger.ClustersResourceApi) BigDecimal(java.math.BigDecimal) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) ClusterCommand(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterCommand) ClusterCommandType(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterCommandType) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate) Test(org.junit.jupiter.api.Test)

Example 48 with ClouderaManagerRepo

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

the class ClouderaManagerSetupServiceTest method testConfigureKerberosWhenThrowClouderaManagerOperationFailedExceptionThenShouldThrowClouderaManagerOperationFailedException.

@Test
public void testConfigureKerberosWhenThrowClouderaManagerOperationFailedExceptionThenShouldThrowClouderaManagerOperationFailedException() throws Exception {
    KerberosConfig kerberosConfig = mock(KerberosConfig.class);
    ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
    clouderaManagerRepo.setVersion("6.2.0");
    when(clusterComponentProvider.getClouderaManagerRepoDetails(anyLong())).thenReturn(clouderaManagerRepo);
    doThrow(new ClouderaManagerOperationFailedException("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) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 49 with ClouderaManagerRepo

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

the class ClouderaManagerSetupServiceTest method testRefreshParcelReposWithNONPreWarmedImageShouldNotCallStartPollingCmParcelRepositoryRefresh.

@Test
public void testRefreshParcelReposWithNONPreWarmedImageShouldNotCallStartPollingCmParcelRepositoryRefresh() {
    ClouderaManagerRepo clouderaManagerRepo = mock(ClouderaManagerRepo.class);
    when(clouderaManagerRepo.getPredefined()).thenReturn(false);
    when(clusterComponentProvider.getClouderaManagerRepoDetails(anyLong())).thenReturn(clouderaManagerRepo);
    underTest.refreshParcelRepos();
    verify(clouderaManagerPollingServiceProvider, times(0)).startPollingCmParcelRepositoryRefresh(any(Stack.class), any(ApiClient.class), any(BigDecimal.class));
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ApiClient(com.cloudera.api.swagger.client.ApiClient) BigDecimal(java.math.BigDecimal) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 50 with ClouderaManagerRepo

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

the class ClouderaManagerSetupServiceTest method testSetupProxyWhenProxyPresentedShouldEverythingWorksFineButNoProxyHostBecauseOfVersion.

@Test
public void testSetupProxyWhenProxyPresentedShouldEverythingWorksFineButNoProxyHostBecauseOfVersion() throws ApiException {
    ClouderaManagerResourceApi clouderaManagerResourceApi = mock(ClouderaManagerResourceApi.class);
    when(clouderaManagerApiFactory.getClouderaManagerResourceApi(any(ApiClient.class))).thenReturn(clouderaManagerResourceApi);
    when(clouderaManagerResourceApi.updateConfig(anyString(), any(ApiConfigList.class))).thenReturn(new ApiConfigList());
    ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
    clouderaManagerRepo.setVersion("7.1.0");
    when(clusterComponentProvider.getClouderaManagerRepoDetails(anyLong())).thenReturn(clouderaManagerRepo);
    underTest.setupProxy(testProxyConfig());
    ArgumentCaptor<String> messageCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<ApiConfigList> configsCaptor = ArgumentCaptor.forClass(ApiConfigList.class);
    verify(clouderaManagerResourceApi, times(1)).updateConfig(messageCaptor.capture(), configsCaptor.capture());
    String capturedMessage = messageCaptor.getValue();
    ApiConfigList capturedConfigs = configsCaptor.getValue();
    assertThat(capturedMessage).isEqualTo("Update proxy settings");
    assertThat(capturedConfigs.getItems()).containsExactlyInAnyOrder(new ApiConfig().name("parcel_proxy_server").value(PROXY_HOST), new ApiConfig().name("parcel_proxy_port").value(Integer.toString(PROXY_PORT)), new ApiConfig().name("parcel_proxy_protocol").value(PROXY_PROTOCOL.toUpperCase()), new ApiConfig().name("parcel_proxy_user").value(PROXY_USER), new ApiConfig().name("parcel_proxy_password").value(PROXY_PASSWORD));
}
Also used : ApiConfigList(com.cloudera.api.swagger.model.ApiConfigList) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ClouderaManagerResourceApi(com.cloudera.api.swagger.ClouderaManagerResourceApi) ApiConfig(com.cloudera.api.swagger.model.ApiConfig) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ApiClient(com.cloudera.api.swagger.client.ApiClient) 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