Search in sources :

Example 96 with InstanceGroup

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

the class OrchestratorRecipeExecutorTest method testGetSingleRecipeExecutionFailureMessageWithoutInstanceMetaData.

@Test
public void testGetSingleRecipeExecutionFailureMessageWithoutInstanceMetaData() {
    final InstanceMetaData instanceMetaData = new InstanceMetaData();
    instanceMetaData.setDiscoveryFQDN("other-fqdn");
    final InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setGroupName("instance-group");
    instanceMetaData.setInstanceGroup(instanceGroup);
    when(recipeExecutionFailureCollector.getInstanceMetadataByHost(anySet(), anyString())).thenReturn(Optional.empty());
    final RecipeExecutionFailureCollector.RecipeFailure recipeFailure = new RecipeExecutionFailureCollector.RecipeFailure("fqdn", "phase", "recipe");
    final String message = underTest.getSingleRecipeExecutionFailureMessage(Set.of(instanceMetaData), recipeFailure);
    Assert.assertEquals("[Recipe: 'recipe' - \nInstance: 'fqdn' (missing metadata)]", message);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Test(org.junit.Test)

Example 97 with InstanceGroup

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

the class StopStartDownscaleActionsTest method mockStackEtc.

private void mockStackEtc(List<InstanceMetaData> instancesActionableStarted, List<InstanceMetaData> instancesActionableNotStarted, List<InstanceMetaData> instancesRandomStarted, List<InstanceMetaData> instancesRandomNotStarted) {
    mockStackEtc();
    List<InstanceMetaData> combined = Stream.of(instancesActionableStarted, instancesActionableNotStarted, instancesRandomStarted, instancesRandomNotStarted).flatMap(Collection::stream).collect(Collectors.toList());
    lenient().when(stack.getNotDeletedAndNotZombieInstanceMetaDataList()).thenReturn(combined);
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setGroupName(INSTANCE_GROUP_NAME_ACTIONABLE);
    instanceGroup.setInstanceMetaData(new HashSet<>(combined));
    lenient().when(stack.getInstanceGroupByInstanceGroupName(eq(INSTANCE_GROUP_NAME_ACTIONABLE))).thenReturn(instanceGroup);
    lenient().when(stackService.getPrivateIdsForHostNames(any(), any())).thenCallRealMethod();
    lenient().when(cloudInstanceIdToInstanceMetaDataConverter.getNotDeletedAndNotZombieInstances(any(), anyString(), any())).thenCallRealMethod();
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 98 with InstanceGroup

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

the class StopStartUpscaleActionsTest method generateInstances.

private List<InstanceMetaData> generateInstances(int count, int startIndex, com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus instanceStatus, String instanceGroupName) {
    List<InstanceMetaData> instances = new ArrayList<>(count);
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setGroupName(instanceGroupName);
    for (int i = 0; i < count; i++) {
        InstanceMetaData instanceMetaData = new InstanceMetaData();
        instanceMetaData.setInstanceId(INSTANCE_ID_PREFIX + (startIndex + i));
        instanceMetaData.setInstanceStatus(instanceStatus);
        instanceMetaData.setInstanceGroup(instanceGroup);
        instanceMetaData.setDiscoveryFQDN(INSTANCE_ID_PREFIX + (startIndex + i));
        instances.add(instanceMetaData);
    }
    return instances;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ArrayList(java.util.ArrayList) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 99 with InstanceGroup

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

the class StopStartUpscaleActionsTest method mockStackEtc.

private void mockStackEtc(List<InstanceMetaData> instancesActionableNotStopped, List<InstanceMetaData> instancesActionableStopped, List<InstanceMetaData> instancesRandomNotStopped, List<InstanceMetaData> instancesRandomStopped) {
    List<InstanceMetaData> combined = Stream.of(instancesActionableNotStopped, instancesActionableStopped, instancesRandomNotStopped, instancesRandomStopped).flatMap(Collection::stream).collect(Collectors.toList());
    lenient().when(stack.getNotDeletedAndNotZombieInstanceMetaDataList()).thenReturn(combined);
    lenient().when(stack.getEnvironmentCrn()).thenReturn(ENV_CRN);
    lenient().when(stack.getStackAuthentication()).thenReturn(stackAuthentication);
    lenient().when(stack.getId()).thenReturn(STACK_ID);
    lenient().when(stackView.getId()).thenReturn(STACK_ID);
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setGroupName(INSTANCE_GROUP_NAME_ACTIONABLE);
    instanceGroup.setInstanceMetaData(new HashSet<>(combined));
    lenient().when(stack.getInstanceGroupByInstanceGroupName(eq(INSTANCE_GROUP_NAME_ACTIONABLE))).thenReturn(instanceGroup);
    List<InstanceMetaData> instancesHg = Stream.of(instancesActionableNotStopped, instancesActionableStopped).flatMap(Collection::stream).collect(Collectors.toList());
    List<CloudInstance> cloudInstancesActionableStopped = convertToCloudInstance(instancesActionableStopped);
    List<CloudInstance> cloudInstancesActionableAll = convertToCloudInstance(instancesHg);
    lenient().when(instanceMetaDataToCloudInstanceConverter.convert(any(), anyString(), any(StackAuthentication.class))).thenReturn(cloudInstancesActionableStopped, cloudInstancesActionableAll);
    lenient().when(cloudInstanceIdToInstanceMetaDataConverter.getNotDeletedAndNotZombieInstances(any(), any(), any())).thenCallRealMethod();
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) StackAuthentication(com.sequenceiq.cloudbreak.domain.StackAuthentication) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 100 with InstanceGroup

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

the class CmTemplateValidatorTest method validWithZeroComputeNodesWhenCardinalityUnspecified.

@Test
public void validWithZeroComputeNodesWhenCardinalityUnspecified() {
    Blueprint blueprint = readBlueprint("input/cdp-data-mart-no-cardinality.bp");
    Set<HostGroup> hostGroups = Set.of(hostGroup("master", 1), hostGroup("worker", 3), hostGroup("compute", 0));
    Collection<InstanceGroup> instanceGroups = hostGroups.stream().map(HostGroup::getInstanceGroup).collect(toSet());
    subject.validate(blueprint, hostGroups, instanceGroups, true);
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Test(org.junit.Test)

Aggregations

InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)288 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)132 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)93 Test (org.junit.jupiter.api.Test)91 HashSet (java.util.HashSet)68 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)57 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)47 Template (com.sequenceiq.cloudbreak.domain.Template)45 Test (org.junit.Test)44 Json (com.sequenceiq.cloudbreak.common.json.Json)38 Set (java.util.Set)37 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)34 ArrayList (java.util.ArrayList)31 LinkedHashSet (java.util.LinkedHashSet)31 Map (java.util.Map)28 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)27 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)27 List (java.util.List)26 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)25 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)22