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));
}
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));
}
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());
}
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));
}
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));
}
Aggregations