use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class AmbariClusterSecurityServiceTest method testPrepareSecurityWhenEverythingWorks.
@Test
public void testPrepareSecurityWhenEverythingWorks() 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.SUCCESS, null);
String failed = "failed";
when(ambariOperationService.waitForOperations(stack, ambariClient, operationRequests, PREPARE_DEKERBERIZING)).thenReturn(pair);
when(cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_PREPARE_DEKERBERIZING_FAILED.code())).thenReturn("failed");
doNothing().when(ambariClusterConnectorPollingResultChecker).checkPollingResult(pair.getLeft(), failed);
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 testDisableSecurityWhenExceptionOccursWhichNotCancellationThenShouldThrowAmbariOperationFailedException.
@Test
public void testDisableSecurityWhenExceptionOccursWhichNotCancellationThenShouldThrowAmbariOperationFailedException() 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.EXIT, null);
String failed = "failed";
when(ambariOperationService.waitForOperations(stack, ambariClient, operationRequests, DISABLE_KERBEROS_STATE)).thenThrow(new AmbariConnectionException("failed"));
when(cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_DISABLE_KERBEROS_FAILED.code())).thenReturn("failed");
doThrow(new AmbariOperationFailedException("cancel")).when(ambariClusterConnectorPollingResultChecker).checkPollingResult(pair.getLeft(), failed);
thrown.expect(AmbariOperationFailedException.class);
thrown.expectMessage("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 StackToStackResponseConverterTest method createSource.
@Override
public Stack createSource() {
Stack stack = TestUtil.stack();
Cluster cluster = TestUtil.cluster(TestUtil.blueprint(), stack, 1L);
stack.setCluster(cluster);
stack.setAvailabilityZone("avZone");
Network network = new Network();
network.setId(1L);
stack.setNetwork(network);
stack.setFailurePolicy(new FailurePolicy());
Orchestrator orchestrator = new Orchestrator();
orchestrator.setId(1L);
orchestrator.setApiEndpoint("endpoint");
orchestrator.setType("type");
stack.setOrchestrator(orchestrator);
stack.setParameters(new HashMap<>());
stack.setCloudPlatform("OPENSTACK");
stack.setGatewayPort(9443);
stack.setCustomDomain("custom.domain");
stack.setCustomHostname("hostname");
stack.setStackAuthentication(new StackAuthentication());
stack.getStackAuthentication().setPublicKey("rsakey");
stack.getStackAuthentication().setLoginUserName("cloudbreak");
stack.setHostgroupNameAsHostname(false);
stack.setClusterNameAsSubdomain(false);
Resource s3ArnResource = new Resource(ResourceType.S3_ACCESS_ROLE_ARN, "s3Arn", stack);
stack.setResources(Collections.singleton(s3ArnResource));
return stack;
}
use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class StackDeletionBasedExitCriteriaTest method exitNeededScenariosTest.
@Test
public void exitNeededScenariosTest() {
Stack stack = TestUtil.stack();
Cluster cluster = TestUtil.cluster(TestUtil.blueprint(), stack, 1L);
stack.setCluster(cluster);
StackDeletionBasedExitCriteriaModel exitCriteriaModel = new StackDeletionBasedExitCriteriaModel(1L);
InMemoryStateStore.putStack(1L, PollGroup.POLLABLE);
assertFalse(underTest.isExitNeeded(exitCriteriaModel));
InMemoryStateStore.putStack(1L, PollGroup.CANCELLED);
assertTrue(underTest.isExitNeeded(exitCriteriaModel));
}
use of com.sequenceiq.cloudbreak.domain.Cluster in project cloudbreak by hortonworks.
the class AmbariClusterStatusUpdaterTest method createStack.
private Stack createStack(Status stackStatus, Status clusterStatus) {
Stack stack = createStack(stackStatus);
Cluster cluster = new Cluster();
cluster.setAmbariIp("10.0.0.1");
cluster.setId(TEST_CLUSTER_ID);
cluster.setStatus(clusterStatus);
Blueprint blueprint = new Blueprint();
blueprint.setAmbariName(TEST_BLUEPRINT);
cluster.setBlueprint(blueprint);
stack.setCluster(cluster);
return stack;
}
Aggregations