use of com.cloudera.api.swagger.MgmtServiceResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerDecomissioner method stopAndRemoveMgmtService.
public void stopAndRemoveMgmtService(Stack stack, ApiClient client) {
MgmtServiceResourceApi mgmtServiceResourceApi = clouderaManagerApiFactory.getMgmtServiceResourceApi(client);
try {
clouderaManagerPollingServiceProvider.startPollingCmManagementServiceShutdown(stack, client, mgmtServiceResourceApi.stopCommand().getId());
mgmtServiceResourceApi.deleteCMS();
} catch (ApiException e) {
LOGGER.error("Failed to stop management services.", e);
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
use of com.cloudera.api.swagger.MgmtServiceResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerModificationServiceTest method testUpgradeClusterComponentIsNotPresent.
@Test
void testUpgradeClusterComponentIsNotPresent() throws ApiException {
BigDecimal apiCommandId = new BigDecimal(200);
ApiCommandList apiCommandList = new ApiCommandList();
apiCommandList.setItems(new ArrayList<>());
when(clouderaManagerApiFactory.getMgmtServiceResourceApi(any())).thenReturn(mgmtServiceResourceApi);
when(mgmtServiceResourceApi.listActiveCommands("SUMMARY")).thenReturn(apiCommandList);
when(mgmtServiceResourceApi.restartCommand()).thenReturn(new ApiCommand().id(apiCommandId));
when(clouderaManagerPollingServiceProvider.startPollingCmServicesRestart(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());
Set<ClusterComponent> clusterComponents = TestUtil.clusterComponentSet(cluster);
Set<ClusterComponent> clusterComponentsNoCDH = clusterComponents.stream().filter(clusterComponent -> !clusterComponent.getName().equals("CDH")).collect(Collectors.toSet());
cluster.setComponents(clusterComponentsNoCDH);
NotFoundException exception = assertThrows(NotFoundException.class, () -> underTest.upgradeClusterRuntime(clusterComponentsNoCDH, false, Optional.empty()));
Assertions.assertEquals("Runtime component not found!", exception.getMessage());
}
use of com.cloudera.api.swagger.MgmtServiceResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerSetupServiceTest method testAutoconfigureWhenThrowsException.
@Test
public void testAutoconfigureWhenThrowsException() throws ApiException {
MgmtServiceResourceApi mgmtServiceResourceApi = mock(MgmtServiceResourceApi.class);
when(clouderaManagerApiFactory.getMgmtServiceResourceApi(any(ApiClient.class))).thenReturn(mgmtServiceResourceApi);
doThrow(ApiException.class).when(mgmtServiceResourceApi).autoConfigure();
Assertions.assertThrows(ClouderaManagerOperationFailedException.class, () -> underTest.autoConfigureClusterManager());
verify(mgmtServiceResourceApi, times(1)).autoConfigure();
}
use of com.cloudera.api.swagger.MgmtServiceResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerSetupServiceTest method testAutoconfigureWhenItDoesItsJob.
@Test
public void testAutoconfigureWhenItDoesItsJob() throws ApiException {
MgmtServiceResourceApi mgmtServiceResourceApi = mock(MgmtServiceResourceApi.class);
when(clouderaManagerApiFactory.getMgmtServiceResourceApi(any(ApiClient.class))).thenReturn(mgmtServiceResourceApi);
underTest.autoConfigureClusterManager();
verify(mgmtServiceResourceApi, times(1)).autoConfigure();
}
use of com.cloudera.api.swagger.MgmtServiceResourceApi in project cloudbreak by hortonworks.
the class ClouderaManagerMgmtLaunchServiceTest method testStartManagementServicesShouldNotSendStartCommandWhenTheManagementServicesAreStarted.
@Test
public void testStartManagementServicesShouldNotSendStartCommandWhenTheManagementServicesAreStarted() throws ApiException {
MgmtServiceResourceApi mgmtServiceResourceApi = mock(MgmtServiceResourceApi.class);
ApiService apiService = mock(ApiService.class);
when(clouderaManagerApiFactory.getMgmtServiceResourceApi(apiClient)).thenReturn(mgmtServiceResourceApi);
when(mgmtServiceResourceApi.readService(DataView.SUMMARY.name())).thenReturn(apiService);
when(apiService.getServiceState()).thenReturn(ApiServiceState.STARTED);
underTest.startManagementServices(stack, apiClient);
verify(mgmtServiceResourceApi).readService(DataView.SUMMARY.name());
verifyNoMoreInteractions(mgmtServiceResourceApi);
verifyZeroInteractions(clouderaManagerPollingServiceProvider);
}
Aggregations