Search in sources :

Example 51 with ClouderaManagerRepo

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

the class DefaultClouderaManagerRepoServiceTest method testDefaultRepoWithOSWhichDoesNotExists.

@Test
public void testDefaultRepoWithOSWhichDoesNotExists() throws Exception {
    ClouderaManagerRepo repo = defaultClouderaManagerRepoService.getDefault("ubuntu", CDH, "6.1.0", null);
    assertNull(repo);
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) Test(org.junit.Test)

Example 52 with ClouderaManagerRepo

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

the class ClouderaManagerClusterCreationSetupServiceTest method getClouderaManagerRepo.

private ClouderaManagerRepo getClouderaManagerRepo(boolean defaultRepo) {
    ClouderaManagerRepo clouderaManagerRepo = new ClouderaManagerRepo();
    clouderaManagerRepo.setBaseUrl("http://public-repo-1.hortonworks.com/cm/centos7/6.2.0/updates/6.2.0");
    clouderaManagerRepo.setVersion(defaultRepo ? DEFAULT_CM_VERSION : CM_VERSION);
    return clouderaManagerRepo;
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)

Example 53 with ClouderaManagerRepo

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

the class ClouderaManagerClusterCreationSetupServiceTest method setupDefaultClouderaManagerEntries.

private void setupDefaultClouderaManagerEntries() throws CloudbreakImageCatalogException {
    ClouderaManagerRepo clouderaManagerRepo = getClouderaManagerRepo(true);
    Mockito.when(defaultClouderaManagerRepoService.getDefault(REDHAT_7, "CDH", SOME_CDH_VERSION, null)).thenReturn(clouderaManagerRepo);
    Mockito.when(defaultClouderaManagerRepoService.getDefault(REDHAT_7, "CDH", NEWER_CDH_VERSION, null)).thenReturn(clouderaManagerRepo);
    Mockito.when(defaultClouderaManagerRepoService.getDefault(REDHAT_7, "CDH", OLDER_CDH_VERSION, null)).thenReturn(clouderaManagerRepo);
    Mockito.when(defaultClouderaManagerRepoService.getDefault(REDHAT_7, "CDH", null, null)).thenReturn(clouderaManagerRepo);
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)

Example 54 with ClouderaManagerRepo

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

the class ClouderaManagerModificationServiceTest method testUpgradeClusterWhenNotPatchUpgrade.

@Test
void testUpgradeClusterWhenNotPatchUpgrade() throws CloudbreakException, ApiException {
    TestUtil.clusterComponents(cluster);
    when(clouderaManagerApiFactory.getMgmtServiceResourceApi(any())).thenReturn(mgmtServiceResourceApi);
    when(clouderaManagerApiFactory.getParcelResourceApi(any())).thenReturn(parcelResourceApi);
    when(clouderaManagerApiFactory.getClustersResourceApi(any())).thenReturn(clustersResourceApi);
    when(clouderaManagerApiFactory.getClouderaManagerResourceApi(any())).thenReturn(clouderaManagerResourceApi);
    when(clouderaManagerApiFactory.getServicesResourceApi(apiClientMock)).thenReturn(servicesResourceApi);
    BigDecimal apiCommandId = new BigDecimal(200);
    // Mgmt Service restart
    ApiCommandList apiCommandList = new ApiCommandList();
    apiCommandList.setItems(new ArrayList<>());
    when(mgmtServiceResourceApi.listActiveCommands("SUMMARY")).thenReturn(apiCommandList);
    when(mgmtServiceResourceApi.restartCommand()).thenReturn(new ApiCommand().id(apiCommandId));
    when(clouderaManagerPollingServiceProvider.startPollingCmServicesRestart(stack, apiClientMock, apiCommandId)).thenReturn(success);
    ApiService apiService = new ApiService().name("SERVICE").configStalenessStatus(ApiConfigStalenessStatus.STALE).clientConfigStalenessStatus(ApiConfigStalenessStatus.STALE);
    List<ApiService> apiServices = List.of(apiService);
    ApiServiceList apiServiceList = new ApiServiceList();
    apiServiceList.setItems(apiServices);
    when(clouderaManagerCommonCommandService.getApiCommand(any(), any(), any(), any())).thenReturn(new ApiCommand().id(apiCommandId));
    when(servicesResourceApi.readServices(stack.getName(), "SUMMARY")).thenReturn(apiServiceList);
    when(clustersResourceApi.listActiveCommands(stack.getName(), "SUMMARY")).thenReturn(apiCommandList);
    when(clustersResourceApi.startCommand(stack.getName())).thenReturn(new ApiCommand().id(apiCommandId));
    when(clouderaManagerCommonCommandService.getDeployClientConfigCommandId(any(), any(), any())).thenReturn(apiCommandId);
    when(clouderaManagerPollingServiceProvider.startPollingCmClientConfigDeployment(stack, apiClientMock, apiCommandId)).thenReturn(success);
    when(clouderaManagerPollingServiceProvider.startPollingCmConfigurationRefresh(stack, apiClientMock, apiCommandId)).thenReturn(success);
    when(clouderaManagerPollingServiceProvider.startPollingCmHostStatus(stack, apiClientMock)).thenReturn(success);
    ClouderaManagerRepo clouderaManagerRepo = mock(ClouderaManagerRepo.class);
    when(clusterComponentProvider.getClouderaManagerRepoDetails(CLUSTER_ID)).thenReturn(clouderaManagerRepo);
    when(clouderaManagerRepo.getVersion()).thenReturn(CLOUDERAMANAGER_VERSION_7_5_1.getVersion());
    underTest.upgradeClusterRuntime(cluster.getComponents(), false, Optional.empty());
    verify(clouderaManagerPollingServiceProvider, times(1)).startPollingCmStartup(stack, apiClientMock);
    verify(clouderaManagerPollingServiceProvider, times(1)).startPollingCmHostStatus(stack, apiClientMock);
    verify(clouderaManagerParcelManagementService, times(1)).checkParcelApiAvailability(stack, apiClientMock);
    verify(clouderaManagerParcelManagementService, times(1)).setParcelRepos(any(), eq(clouderaManagerResourceApi));
    verify(clouderaManagerParcelManagementService, times(1)).refreshParcelRepos(clouderaManagerResourceApi, stack, apiClientMock);
    verify(clouderaManagerParcelManagementService, times(2)).downloadParcels(any(), eq(parcelResourceApi), eq(stack), eq(apiClientMock));
    verify(clouderaManagerParcelManagementService, times(2)).distributeParcels(any(), eq(parcelResourceApi), eq(stack), eq(apiClientMock));
    verify(clouderaManagerUpgradeService, times(1)).callUpgradeCdhCommand(TestUtil.CDH_VERSION, clustersResourceApi, stack, apiClientMock);
    verify(clouderaManagerParcelManagementService).activateParcels(any(), eq(parcelResourceApi), eq(stack), eq(apiClientMock));
    verify(clouderaManagerCommonCommandService, times(1)).getDeployClientConfigCommandId(any(), any(), any());
    verify(clouderaManagerCommonCommandService, times(1)).getApiCommand(any(), any(), any(), any());
    InOrder inOrder = Mockito.inOrder(clouderaManagerPollingServiceProvider, clouderaManagerParcelManagementService, clouderaManagerUpgradeService, clustersResourceApi, clouderaManagerCommonCommandService, servicesResourceApi);
    inOrder.verify(clouderaManagerPollingServiceProvider).startPollingCmStartup(stack, apiClientMock);
    inOrder.verify(clouderaManagerPollingServiceProvider).startPollingCmHostStatus(stack, apiClientMock);
    inOrder.verify(clouderaManagerParcelManagementService).checkParcelApiAvailability(stack, apiClientMock);
    inOrder.verify(clouderaManagerParcelManagementService).setParcelRepos(any(), eq(clouderaManagerResourceApi));
    inOrder.verify(clouderaManagerParcelManagementService).refreshParcelRepos(clouderaManagerResourceApi, stack, apiClientMock);
    inOrder.verify(clouderaManagerParcelManagementService).downloadParcels(any(), eq(parcelResourceApi), eq(stack), eq(apiClientMock));
    inOrder.verify(clouderaManagerParcelManagementService).distributeParcels(any(), eq(parcelResourceApi), eq(stack), eq(apiClientMock));
    inOrder.verify(clouderaManagerParcelManagementService).activateParcels(any(), eq(parcelResourceApi), eq(stack), eq(apiClientMock));
    inOrder.verify(clouderaManagerUpgradeService).callUpgradeCdhCommand(TestUtil.CDH_VERSION, clustersResourceApi, stack, apiClientMock);
    inOrder.verify(servicesResourceApi).readServices(stack.getName(), "SUMMARY");
    inOrder.verify(clouderaManagerCommonCommandService).getDeployClientConfigCommandId(stack, clustersResourceApi, apiCommandList.getItems());
    inOrder.verify(clouderaManagerCommonCommandService).getApiCommand(any(), any(), any(), any());
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ApiCommandList(com.cloudera.api.swagger.model.ApiCommandList) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) InOrder(org.mockito.InOrder) ApiService(com.cloudera.api.swagger.model.ApiService) ApiServiceList(com.cloudera.api.swagger.model.ApiServiceList) BigDecimal(java.math.BigDecimal) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 55 with ClouderaManagerRepo

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

the class ClouderaManagerModificationServiceTest method testUpgradeClusterWhenPatchUpgradeAndPostUpgradeCommandIsAvailableAndRestartIsRunning.

@Test
void testUpgradeClusterWhenPatchUpgradeAndPostUpgradeCommandIsAvailableAndRestartIsRunning() throws CloudbreakException, ApiException, ClouderaManagerClientInitException {
    TestUtil.clusterComponents(cluster);
    when(clouderaManagerApiFactory.getParcelResourceApi(any())).thenReturn(parcelResourceApi);
    when(clouderaManagerApiFactory.getClustersResourceApi(any())).thenReturn(clustersResourceApi);
    when(clouderaManagerApiFactory.getClouderaManagerResourceApi(any())).thenReturn(clouderaManagerResourceApi);
    when(clouderaManagerApiFactory.getMgmtServiceResourceApi(any())).thenReturn(mgmtServiceResourceApi);
    when(clouderaManagerApiFactory.getServicesResourceApi(any())).thenReturn(servicesResourceApi);
    BigDecimal apiCommandId = new BigDecimal(200);
    // Mgmt Service restart
    ApiCommandList apiCommandList = new ApiCommandList();
    apiCommandList.setItems(new ArrayList<>());
    when(mgmtServiceResourceApi.listActiveCommands("SUMMARY")).thenReturn(apiCommandList);
    when(mgmtServiceResourceApi.restartCommand()).thenReturn(new ApiCommand().id(apiCommandId));
    when(clouderaManagerPollingServiceProvider.startPollingCmServicesRestart(stack, apiClientMock, apiCommandId)).thenReturn(success);
    // Start services if they are not running
    ApiServiceList serviceList = new ApiServiceList();
    ApiService service = new ApiService();
    service.setServiceState(ApiServiceState.STOPPED);
    serviceList.addItemsItem(service);
    ApiCommand startCommand = mock(ApiCommand.class);
    when(startCommand.getId()).thenReturn(apiCommandId);
    when(servicesResourceApi.readServices(any(), any())).thenReturn(serviceList);
    when(clustersResourceApi.startCommand(STACK_NAME)).thenReturn(startCommand);
    // Post parcel activation
    ClouderaManagerRepo clouderaManagerRepo = mock(ClouderaManagerRepo.class);
    when(clusterComponentConfigProvider.getClouderaManagerRepoDetails(CLUSTER_ID)).thenReturn(clouderaManagerRepo);
    when(clouderaManagerRepo.getVersion()).thenReturn(CLOUDERAMANAGER_VERSION_7_5_1.getVersion());
    // Restart services
    when(clustersResourceApi.listActiveCommands(stack.getName(), "SUMMARY")).thenReturn(new ApiCommandList().items(List.of(new ApiCommand().id(apiCommandId).name("Restart"))));
    when(clouderaManagerPollingServiceProvider.startPollingCmServicesRestart(stack, apiClientMock, apiCommandId)).thenReturn(success);
    when(clouderaManagerPollingServiceProvider.startPollingCmHostStatus(stack, apiClientMock)).thenReturn(success);
    when(clusterComponentProvider.getClouderaManagerRepoDetails(CLUSTER_ID)).thenReturn(clouderaManagerRepo);
    when(clouderaManagerRepo.getVersion()).thenReturn(CLOUDERAMANAGER_VERSION_7_5_1.getVersion());
    when(clouderaManagerApiClientProvider.getV45Client(any(), any(), any(), any())).thenReturn(apiClientMock);
    underTest.upgradeClusterRuntime(cluster.getComponents(), true, Optional.empty());
    verify(clouderaManagerPollingServiceProvider, times(1)).startPollingCmStartup(stack, apiClientMock);
    verify(clouderaManagerPollingServiceProvider, times(1)).startPollingCmHostStatus(stack, apiClientMock);
    verify(clouderaManagerParcelManagementService, times(1)).checkParcelApiAvailability(stack, apiClientMock);
    verify(clouderaManagerParcelManagementService, times(1)).setParcelRepos(any(), eq(clouderaManagerResourceApi));
    verify(clouderaManagerParcelManagementService, times(1)).refreshParcelRepos(clouderaManagerResourceApi, stack, apiClientMock);
    verify(mgmtServiceResourceApi, times(1)).listActiveCommands("SUMMARY");
    verify(mgmtServiceResourceApi, times(1)).restartCommand();
    verify(clouderaManagerPollingServiceProvider, times(3)).startPollingCmServicesRestart(stack, apiClientMock, apiCommandId);
    verify(clouderaManagerParcelManagementService, times(1)).downloadParcels(any(), eq(parcelResourceApi), eq(stack), eq(apiClientMock));
    verify(clouderaManagerParcelManagementService, times(1)).distributeParcels(any(), eq(parcelResourceApi), eq(stack), eq(apiClientMock));
    verify(clouderaManagerParcelManagementService, times(1)).activateParcels(any(), eq(parcelResourceApi), eq(stack), eq(apiClientMock));
    verify(eventService, times(1)).fireCloudbreakEvent(stack.getId(), UPDATE_IN_PROGRESS.name(), ResourceEvent.CLUSTER_UPGRADE_START_POST_UPGRADE);
    verify(clouderaManagerUpgradeService, times(1)).callPostRuntimeUpgradeCommand(clustersResourceApi, stack, apiClientMock);
    verify(clustersResourceApi, times(0)).restartCommand(eq(stack.getName()), any(ApiRestartClusterArgs.class));
    verify(clustersResourceApi, times(2)).listActiveCommands(stack.getName(), "SUMMARY");
    verify(clouderaManagerApiClientProvider, times(1)).getV45Client(any(), any(), any(), any());
    InOrder inOrder = Mockito.inOrder(clouderaManagerPollingServiceProvider, clouderaManagerParcelManagementService, clustersResourceApi, clouderaManagerApiClientProvider, clouderaManagerUpgradeService);
    inOrder.verify(clouderaManagerPollingServiceProvider).startPollingCmStartup(stack, apiClientMock);
    inOrder.verify(clouderaManagerPollingServiceProvider).startPollingCmHostStatus(stack, apiClientMock);
    inOrder.verify(clouderaManagerParcelManagementService).checkParcelApiAvailability(stack, apiClientMock);
    inOrder.verify(clouderaManagerParcelManagementService).setParcelRepos(any(), eq(clouderaManagerResourceApi));
    inOrder.verify(clouderaManagerParcelManagementService).refreshParcelRepos(clouderaManagerResourceApi, stack, apiClientMock);
    inOrder.verify(clouderaManagerParcelManagementService).downloadParcels(any(), eq(parcelResourceApi), eq(stack), eq(apiClientMock));
    inOrder.verify(clouderaManagerParcelManagementService).distributeParcels(any(), eq(parcelResourceApi), eq(stack), eq(apiClientMock));
    inOrder.verify(clouderaManagerParcelManagementService).activateParcels(any(), eq(parcelResourceApi), eq(stack), eq(apiClientMock));
    inOrder.verify(clustersResourceApi).listActiveCommands(eq(stack.getName()), any());
    inOrder.verify(clouderaManagerApiClientProvider).getV45Client(any(), any(), any(), any());
    inOrder.verify(clouderaManagerUpgradeService).callPostRuntimeUpgradeCommand(eq(clustersResourceApi), eq(stack), eq(apiClientMock));
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) ApiCommandList(com.cloudera.api.swagger.model.ApiCommandList) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) InOrder(org.mockito.InOrder) ApiService(com.cloudera.api.swagger.model.ApiService) ApiServiceList(com.cloudera.api.swagger.model.ApiServiceList) ApiRestartClusterArgs(com.cloudera.api.swagger.model.ApiRestartClusterArgs) BigDecimal(java.math.BigDecimal) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) 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