use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class MultiAzCalculatorServiceTest method calculateByRoundRobinTestWhenCloudInstanceAndForeignSubnetId.
@ParameterizedTest(name = "calculateByRoundRobinTestWhenCloudInstanceAndForeignSubnetId " + "with {0} platform when {1} subnets and {2} instances and {3} subnet counts should result in {5} subnet / AZ")
@MethodSource("calculateByRoundRobinTestWhenCloudInstanceData")
public void calculateByRoundRobinTestWhenCloudInstanceAndForeignSubnetId(CloudPlatform cloudPlatform, int subnetCount, int instanceCount, List<Integer> existingCounts, boolean supported, Set<Integer> expectedPermissibleSubnetIdIndexes) {
if (supported) {
when(multiAzValidator.supportedForInstanceMetadataGeneration(any(InstanceGroup.class))).thenReturn(true);
}
InstanceGroup instanceGroup = instanceGroup(cloudPlatform, instanceCount, subnetCount);
initSubnetIdAndAvailabilityZoneForInstances(existingCounts, instanceGroup);
InstanceMetaData instanceWithPrepopulatedForeignSubnetId = instanceMetaData(instanceCount, SUBNET_ID, AVAILABILITY_ZONE, InstanceStatus.REQUESTED);
instanceGroup.getAllInstanceMetaData().add(instanceWithPrepopulatedForeignSubnetId);
InstanceMetaData instanceMetaData = new InstanceMetaData();
underTest.calculateByRoundRobin(subnetAzPairs(subnetCount), instanceGroup, instanceMetaData, NetworkScaleDetails.getEmpty());
verifyCloudInstance(expectedPermissibleSubnetIdIndexes, instanceMetaData);
verifySubnetIdAndAvailabilityZoneForInstancesAreUnchanged(existingCounts, instanceGroup, Set.of(instanceWithPrepopulatedForeignSubnetId));
assertThat(instanceWithPrepopulatedForeignSubnetId.getSubnetId()).isEqualTo(SUBNET_ID);
assertThat(instanceWithPrepopulatedForeignSubnetId.getAvailabilityZone()).isEqualTo(AVAILABILITY_ZONE);
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class InstanceGroupMetadataCollectorTest method testCollectFqdnsWhenMetadataAvailable.
@Test
public void testCollectFqdnsWhenMetadataAvailable() {
Stack stack = TestUtil.stack();
for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
when(instanceMetaDataService.findAliveInstancesInInstanceGroup(instanceGroup.getId())).thenReturn(Lists.newArrayList(instanceGroup.getAllInstanceMetaData().iterator()));
}
Map<String, List<InstanceMetaData>> stringListMap = underTest.collectMetadata(stack);
Assert.assertEquals(3L, stringListMap.size());
Assert.assertTrue(stringListMap.keySet().containsAll(Sets.newHashSet("is1", "is2", "is3")));
verify(instanceMetaDataService, times(3)).findAliveInstancesInInstanceGroup(anyLong());
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class InstanceMetadataUpdaterTest method createInstanceGroup.
private InstanceGroup createInstanceGroup(String instanceId, InstanceGroupType instanceGroupType) throws JsonProcessingException {
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setInstanceGroupType(instanceGroupType);
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setInstanceStatus(InstanceStatus.SERVICES_RUNNING);
instanceMetaData.setInstanceMetadataType(InstanceMetadataType.GATEWAY_PRIMARY);
Image image = new Image("imagename", null, "os", "ostype", "catalogurl", "catalogname", "iamgeid", packageMap());
instanceMetaData.setImage(new Json(image));
instanceMetaData.setInstanceId(instanceId);
instanceMetaData.setDiscoveryFQDN(instanceId);
instanceGroup.setInstanceMetaData(Collections.singleton(instanceMetaData));
return instanceGroup;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class InstanceMetadataUpdaterTest method createStack.
private Stack createStack() throws JsonProcessingException {
Stack stack = new Stack();
stack.setId(1L);
stack.setCluster(new Cluster());
Orchestrator orchestrator = new Orchestrator();
orchestrator.setType("salt");
stack.setOrchestrator(orchestrator);
Set<InstanceGroup> instanceGroups = new HashSet<>();
instanceGroups.add(createInstanceGroup("instanceId", InstanceGroupType.GATEWAY));
instanceGroups.add(createInstanceGroup("hostByCmd", InstanceGroupType.CORE));
stack.setInstanceGroups(instanceGroups);
return stack;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup in project cloudbreak by hortonworks.
the class ClusterOperationServiceTest method getHost.
private InstanceMetaData getHost(String hostName, String groupName, InstanceStatus instanceStatus, InstanceGroupType instanceGroupType) {
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setInstanceGroupType(instanceGroupType);
instanceGroup.setGroupName(groupName);
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setDiscoveryFQDN(hostName);
instanceMetaData.setInstanceGroup(instanceGroup);
instanceMetaData.setInstanceStatus(instanceStatus);
instanceGroup.setInstanceMetaData(Collections.singleton(instanceMetaData));
return instanceMetaData;
}
Aggregations