use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class AmbariClusterSecurityServiceTest method testPrepareSecurityWhenCancellationExceptionOccursThenShouldThrowCancellationException.
@Test
public void testPrepareSecurityWhenCancellationExceptionOccursThenShouldThrowCancellationException() throws CloudbreakException {
Stack stack = TestUtil.stack();
Cluster cluster = TestUtil.cluster();
stack.setCluster(cluster);
AmbariClient ambariClient = Mockito.mock(AmbariClient.class);
when(clientFactory.getAmbariClient(stack, stack.getCluster())).thenReturn(ambariClient);
when(ambariClient.startService(anyString())).thenReturn(1);
when(ambariClient.stopService(anyString())).thenReturn(1);
Map<String, Integer> operationRequests = new HashMap<>();
operationRequests.put("ZOOKEEPER_SERVICE_STATE", 1);
operationRequests.put("HDFS_SERVICE_STATE", 1);
operationRequests.put("YARN_SERVICE_STATE", 1);
operationRequests.put("MAPREDUCE2_SERVICE_STATE", 1);
operationRequests.put("KERBEROS_SERVICE_STATE", 1);
ImmutablePair<PollingResult, Exception> pair = new ImmutablePair<>(PollingResult.EXIT, null);
String failed = "failed";
when(ambariOperationService.waitForOperations(stack, ambariClient, operationRequests, PREPARE_DEKERBERIZING)).thenThrow(new CancellationException("cancel"));
when(cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_PREPARE_DEKERBERIZING_FAILED.code())).thenReturn("failed");
doThrow(new CancellationException("cancel")).when(ambariClusterConnectorPollingResultChecker).checkPollingResult(pair.getLeft(), failed);
thrown.expect(CancellationException.class);
thrown.expectMessage("cancel");
underTest.prepareSecurity(stack);
verify(ambariOperationService, times(1)).waitForOperations(stack, ambariClient, operationRequests, PREPARE_DEKERBERIZING);
verify(cloudbreakMessagesService, times(1)).getMessage(AMBARI_CLUSTER_PREPARE_DEKERBERIZING_FAILED.code());
verify(ambariClusterConnectorPollingResultChecker, times(1)).checkPollingResult(pair.getLeft(), failed);
}
use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class AmbariClusterSecurityServiceTest method testDisableSecurityWhenEverythingWorks.
@Test
public void testDisableSecurityWhenEverythingWorks() throws CloudbreakException {
Stack stack = TestUtil.stack();
Cluster cluster = TestUtil.cluster();
stack.setCluster(cluster);
AmbariClient ambariClient = Mockito.mock(AmbariClient.class);
when(clientFactory.getAmbariClient(stack, stack.getCluster())).thenReturn(ambariClient);
when(ambariClient.disableKerberos()).thenReturn(1);
Map<String, Integer> operationRequests = singletonMap("DISABLE_KERBEROS_REQUEST", 1);
ImmutablePair<PollingResult, Exception> pair = new ImmutablePair<>(PollingResult.SUCCESS, null);
String failed = "failed";
when(ambariOperationService.waitForOperations(stack, ambariClient, operationRequests, DISABLE_KERBEROS_STATE)).thenReturn(pair);
when(cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_DISABLE_KERBEROS_FAILED.code())).thenReturn("failed");
doNothing().when(ambariClusterConnectorPollingResultChecker).checkPollingResult(pair.getLeft(), failed);
underTest.disableSecurity(stack);
verify(ambariOperationService, times(1)).waitForOperations(stack, ambariClient, operationRequests, DISABLE_KERBEROS_STATE);
verify(cloudbreakMessagesService, times(1)).getMessage(AMBARI_CLUSTER_DISABLE_KERBEROS_FAILED.code());
verify(ambariClusterConnectorPollingResultChecker, times(1)).checkPollingResult(pair.getLeft(), failed);
}
use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class DefaultStackHostServiceTypeTest method stack.
private Stack stack(Status stackStatus, Status clusterStatus) {
Credential gcpCredential = new Credential();
Stack stack = new Stack();
stack.setName("simplestack");
stack.setStackStatus(new StackStatus(stack, stackStatus, "", DetailedStackStatus.UNKNOWN));
stack.setCredential(gcpCredential);
stack.setId(1L);
Cluster cluster = new Cluster();
cluster.setStatus(clusterStatus);
cluster.setId(1L);
stack.setCluster(cluster);
return stack;
}
use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class AmbariClusterSetupServiceTest method testApiAvailableWhenPollerReturnFalseThenApiShouldBeNotAvailable.
@Test
public void testApiAvailableWhenPollerReturnFalseThenApiShouldBeNotAvailable() throws CloudbreakSecuritySetupException {
Stack stack = TestUtil.stack();
Cluster cluster = TestUtil.cluster();
stack.setCluster(cluster);
AmbariClient ambariClient = ambariClient();
when(ambariPollingServiceProvider.isAmbariAvailable(stack, ambariClient)).thenReturn(false);
when(clientFactory.getAmbariClient(stack, stack.getCluster())).thenReturn(ambariClient);
boolean available = underTest.available(stack);
verify(ambariPollingServiceProvider, times(1)).isAmbariAvailable(stack, ambariClient);
verify(clientFactory, times(1)).getAmbariClient(stack, stack.getCluster());
Assert.assertFalse(available);
}
use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class AmbariConfigurationServiceTest method testCreateRdsConfig.
@Test
public void testCreateRdsConfig() {
Cluster cluster = new Cluster();
Stack stack = new Stack();
when(rdsConfigService.create(any(RDSConfig.class))).thenAnswer(invocation -> invocation.getArgumentAt(0, RDSConfig.class));
Optional<RDSConfig> rdsConfig = ambariConfigurationService.createDefaultRdsConfigIfNeeded(stack, cluster);
assertTrue(rdsConfig.isPresent());
}
Aggregations