Search in sources :

Example 86 with InstanceGroup

use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.

the class StackRequestToStackConverterTest method testForNoRegionAndNoDefaultRegion.

@Test
public void testForNoRegionAndNoDefaultRegion() throws CloudbreakException {
    InstanceGroup instanceGroup = mock(InstanceGroup.class);
    when(instanceGroup.getInstanceGroupType()).thenReturn(InstanceGroupType.GATEWAY);
    // GIVEN
    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<>());
    thrown.expect(BadRequestException.class);
    thrown.expectMessage("No default region is specified. Region cannot be empty.");
    // WHEN
    StackRequest stackRequest = getRequest("stack/stack.json");
    OrchestratorRequest orchestratorRequest = new OrchestratorRequest();
    orchestratorRequest.setType("SALT");
    stackRequest.setOrchestrator(orchestratorRequest);
    stackRequest.setRegion(null);
    underTest.convert(stackRequest);
}
Also used : StackAuthenticationRequest(com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest) StackAuthentication(com.sequenceiq.cloudbreak.domain.StackAuthentication) InstanceGroupRequest(com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest) Matchers.anyString(org.mockito.Matchers.anyString) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) StackRequest(com.sequenceiq.cloudbreak.api.model.StackRequest) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) TypeDescriptor(org.springframework.core.convert.TypeDescriptor) OrchestratorRequest(com.sequenceiq.cloudbreak.api.model.OrchestratorRequest) FailurePolicyRequest(com.sequenceiq.cloudbreak.api.model.FailurePolicyRequest) FailurePolicy(com.sequenceiq.cloudbreak.domain.FailurePolicy) Test(org.junit.Test)

Example 87 with InstanceGroup

use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.

the class UsageService method openUsagesForStack.

public void openUsagesForStack(Stack stack) {
    LocalDateTime ldt = LocalDateTime.now();
    List<CloudbreakUsage> usages = Lists.newArrayList();
    for (InstanceGroup ig : stack.getInstanceGroups()) {
        Template template = ig.getTemplate();
        String instanceType = template == null ? "undefined" : template.getInstanceType();
        String groupName = ig.getGroupName();
        Integer instanceNum = ig.getNodeCount();
        usages.add(usageGeneratorService.openNewUsage(stack, instanceType, instanceNum, groupName, ldt));
    }
    usageRepository.save(usages);
}
Also used : LocalDateTime(java.time.LocalDateTime) CloudbreakUsage(com.sequenceiq.cloudbreak.domain.CloudbreakUsage) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Template(com.sequenceiq.cloudbreak.domain.Template)

Example 88 with InstanceGroup

use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.

the class InstanceGroupRequestToInstanceGroupConverterTest method testConvert.

@Test
public void testConvert() {
    // GIVEN
    given(templateService.get(anyLong())).willReturn(TestUtil.gcpTemplate(51L));
    given(securityGroupService.get(anyLong())).willReturn(TestUtil.securityGroup(1L));
    // WHEN
    InstanceGroup instanceGroup = underTest.convert(getRequest("stack/instance-group.json"));
    // THEN
    assertAllFieldsNotNull(instanceGroup, Collections.singletonList("stack"));
}
Also used : InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Test(org.junit.Test)

Example 89 with InstanceGroup

use of com.sequenceiq.cloudbreak.domain.InstanceGroup in project cloudbreak by hortonworks.

the class InstanceGroupToInstanceGroupResponseConverterTest method createSource.

@Override
public InstanceGroup createSource() {
    InstanceGroup instanceGroup = TestUtil.instanceGroup(1L, InstanceGroupType.CORE, TestUtil.gcpTemplate(1L));
    instanceGroup.setInstanceMetaData(getInstanceMetaData(instanceGroup));
    return instanceGroup;
}
Also used : InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Aggregations

InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)89 Test (org.junit.Test)32 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)27 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)27 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)24 HashSet (java.util.HashSet)16 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 Stack (com.sequenceiq.cloudbreak.domain.Stack)14 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)9 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)8 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)8 Constraint (com.sequenceiq.cloudbreak.domain.Constraint)8 Matchers.anyString (org.mockito.Matchers.anyString)8 Orchestrator (com.sequenceiq.cloudbreak.domain.Orchestrator)6 StackAuthentication (com.sequenceiq.cloudbreak.domain.StackAuthentication)6 Template (com.sequenceiq.cloudbreak.domain.Template)6 ArrayList (java.util.ArrayList)6 InstanceGroupRequest (com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest)5 StackAuthenticationRequest (com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest)5 FailurePolicy (com.sequenceiq.cloudbreak.domain.FailurePolicy)5