Search in sources :

Example 91 with InstanceGroup

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);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 92 with InstanceGroup

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());
}
Also used : List(java.util.List) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Test(org.junit.Test)

Example 93 with InstanceGroup

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;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.Image) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 94 with 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;
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) HashSet(java.util.HashSet)

Example 95 with InstanceGroup

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;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

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