use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.
the class StackRequestToStackConverterTest method testConvert.
@Test
public void testConvert() throws CloudbreakException {
InstanceGroup instanceGroup = mock(InstanceGroup.class);
when(instanceGroup.getInstanceGroupType()).thenReturn(InstanceGroupType.GATEWAY);
// GIVEN
ReflectionTestUtils.setField(underTest, "defaultRegions", "AWS:eu-west-2");
given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new HashSet<>(Collections.singletonList(instanceGroup)));
given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new HashSet<>(Collections.singletonList(instanceGroup)));
given(conversionService.convert(any(StackAuthenticationRequest.class), eq(StackAuthentication.class))).willReturn(new StackAuthentication());
given(conversionService.convert(any(FailurePolicyRequest.class), eq(FailurePolicy.class))).willReturn(new FailurePolicy());
given(conversionService.convert(any(InstanceGroupRequest.class), eq(InstanceGroup.class))).willReturn(instanceGroup);
given(conversionService.convert(any(OrchestratorRequest.class), eq(Orchestrator.class))).willReturn(new Orchestrator());
given(orchestratorTypeResolver.resolveType(any(Orchestrator.class))).willReturn(OrchestratorType.HOST);
given(orchestratorTypeResolver.resolveType(any(String.class))).willReturn(OrchestratorType.HOST);
given(defaultCostTaggingService.prepareDefaultTags(any(String.class), any(String.class), anyMap(), anyString())).willReturn(new HashMap<>());
// WHEN
Stack stack = underTest.convert(getRequest("stack/stack.json"));
// THEN
assertAllFieldsNotNull(stack, Arrays.asList("description", "statusReason", "cluster", "credential", "gatewayPort", "template", "network", "securityConfig", "securityGroup", "version", "created", "platformVariant", "cloudPlatform", "saltPassword", "stackTemplate", "flexSubscription", "datalakeId", "customHostname", "customDomain", "clusterNameAsSubdomain", "hostgroupNameAsHostname", "loginUserName", "parameters"));
Assert.assertEquals("YARN", stack.getRegion());
}
use of com.sequenceiq.cloudbreak.domain.Stack 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.Stack in project cloudbreak by hortonworks.
the class ClusterBootstrapperErrorHandlerTest method clusterBootstrapErrorHandlerWhenNodeCountLessThanOneAfterTheRollbackThenClusterProvisionFailed.
@Test
public void clusterBootstrapErrorHandlerWhenNodeCountLessThanOneAfterTheRollbackThenClusterProvisionFailed() throws CloudbreakOrchestratorFailedException {
Stack stack = TestUtil.stack();
doNothing().when(eventService).fireCloudbreakEvent(anyLong(), anyString(), anyString());
when(orchestrator.getAvailableNodes(any(GatewayConfig.class), anySet())).thenReturn(new ArrayList<>());
when(instanceGroupRepository.save(any(InstanceGroup.class))).then(returnsFirstArg());
when(instanceMetaDataRepository.save(any(InstanceMetaData.class))).then(returnsFirstArg());
when(instanceMetaDataRepository.findNotTerminatedByPrivateAddress(anyLong(), anyString())).thenAnswer((Answer<InstanceMetaData>) invocation -> {
Object[] args = invocation.getArguments();
String ip = (String) args[1];
for (InstanceMetaData instanceMetaData : stack.getRunningInstanceMetaData()) {
if (instanceMetaData.getPrivateIp().equals(ip)) {
return instanceMetaData;
}
}
return null;
});
when(instanceGroupRepository.findOneByGroupNameInStack(anyLong(), anyString())).thenAnswer((Answer<InstanceGroup>) invocation -> {
Object[] args = invocation.getArguments();
String name = (String) args[1];
for (InstanceMetaData instanceMetaData : stack.getRunningInstanceMetaData()) {
if (instanceMetaData.getInstanceGroup().getGroupName().equals(name)) {
return instanceMetaData.getInstanceGroup();
}
}
return null;
});
when(cloudbreakMessagesService.getMessage(eq("bootstrapper.error.invalide.nodecount"), any())).thenReturn("invalide.nodecount");
thrown.expect(CloudbreakOrchestratorFailedException.class);
thrown.expectMessage("invalide.nodecount");
underTest.terminateFailedNodes(null, orchestrator, TestUtil.stack(), new GatewayConfig("10.0.0.1", "198.0.0.1", "10.0.0.1", 8443, false), prepareNodes(stack));
}
use of com.sequenceiq.cloudbreak.domain.Stack 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.Stack 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