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);
}
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();
}
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;
}
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();
}
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);
}
Aggregations