Search in sources :

Example 76 with InstanceGroup

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

the class LoadBalancerConfigServiceTest method createYarnStack.

private Stack createYarnStack() {
    Cluster cluster = new Cluster();
    cluster.setBlueprint(blueprint);
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setGroupName("master");
    Stack stack = new Stack();
    stack.setType(StackType.DATALAKE);
    stack.setCluster(cluster);
    stack.setInstanceGroups(Set.of(instanceGroup));
    stack.setCloudPlatform(YARN);
    return stack;
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 77 with InstanceGroup

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

the class LoadBalancerConfigServiceTest method createStack.

private Stack createStack(StackType type, String subnetId, String cloudPlatform, boolean makePrivate) {
    Cluster cluster = new Cluster();
    cluster.setBlueprint(blueprint);
    Set<InstanceGroup> instanceGroups = new HashSet<>();
    InstanceGroup instanceGroup1 = new InstanceGroup();
    instanceGroup1.setGroupName("master");
    instanceGroup1.setAttributes(new Json(new HashMap<String, Object>()));
    InstanceGroup instanceGroup2 = new InstanceGroup();
    instanceGroup2.setGroupName("manager");
    instanceGroup2.setAttributes(new Json(new HashMap<String, Object>()));
    instanceGroups.add(instanceGroup1);
    instanceGroups.add(instanceGroup2);
    InstanceMetaData imd1 = new InstanceMetaData();
    InstanceMetaData imd2 = new InstanceMetaData();
    Set<InstanceMetaData> imdSet = Set.of(imd1, imd2);
    instanceGroup1.setInstanceMetaData(imdSet);
    instanceGroup2.setInstanceMetaData(imdSet);
    Stack stack = new Stack();
    stack.setType(type);
    stack.setCluster(cluster);
    stack.setInstanceGroups(instanceGroups);
    stack.setCloudPlatform(cloudPlatform);
    Network network = new Network();
    Map<String, Object> attributes = new HashMap<>();
    if (StringUtils.isNotEmpty(subnetId)) {
        attributes.put("subnetId", subnetId);
    }
    if (AZURE.equals(cloudPlatform)) {
        attributes.put("noPublicIp", makePrivate);
        InstanceGroup instanceGroup3 = new InstanceGroup();
        instanceGroup3.setGroupName("worker");
        instanceGroups.add(instanceGroup3);
    }
    network.setAttributes(new Json(attributes));
    stack.setNetwork(network);
    return stack;
}
Also used : HashMap(java.util.HashMap) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Json(com.sequenceiq.cloudbreak.common.json.Json) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Network(com.sequenceiq.cloudbreak.domain.Network) HashSet(java.util.HashSet)

Example 78 with InstanceGroup

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

the class ClusterCommonServiceTest method generateInstanceMetadata.

private Set<InstanceMetaData> generateInstanceMetadata() {
    // LinkedHashSet required to keep the order, and have a reliable test run
    Set<InstanceMetaData> instanceMetaData = new LinkedHashSet<>();
    InstanceGroup master = new InstanceGroup();
    master.setGroupName("master");
    InstanceGroup worker = new InstanceGroup();
    worker.setGroupName("worker");
    InstanceMetaData master1 = new InstanceMetaData();
    master1.setPublicIp("m1");
    master1.setInstanceGroup(master);
    master1.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
    instanceMetaData.add(master1);
    master.setInstanceMetaData(new HashSet<>(Arrays.asList(master1)));
    InstanceMetaData worker1 = new InstanceMetaData();
    worker1.setPrivateIp("worker-1");
    worker1.setInstanceGroup(worker);
    worker1.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
    instanceMetaData.add(worker1);
    InstanceMetaData worker2 = new InstanceMetaData();
    // If we have both then we need public ip
    worker2.setPublicIp("pub-worker-2");
    worker2.setPrivateIp("worker-2");
    worker2.setInstanceGroup(worker);
    worker2.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
    worker.setInstanceMetaData(new HashSet<>(Arrays.asList(worker1, worker2)));
    instanceMetaData.add(worker2);
    return instanceMetaData;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) LinkedHashSet(java.util.LinkedHashSet) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 79 with InstanceGroup

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

the class ClusterRepairServiceTest 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);
    instanceMetaData.setInstanceId(hostName);
    instanceGroup.setInstanceMetaData(Sets.newHashSet(instanceMetaData));
    return instanceMetaData;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 80 with InstanceGroup

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

the class ClusterRepairServiceTest method testValidateRepairWhenOneGWUnhealthyAndNotSelected.

@Test
public void testValidateRepairWhenOneGWUnhealthyAndNotSelected() {
    when(stackService.getByIdWithListsInTransaction(STACK_ID)).thenReturn(stack);
    when(freeipaService.checkFreeipaRunning(stack.getEnvironmentCrn())).thenReturn(true);
    when(environmentService.environmentStatusInDesiredState(stack, Set.of(EnvironmentStatus.AVAILABLE))).thenReturn(true);
    InstanceMetaData primaryGW = new InstanceMetaData();
    primaryGW.setInstanceStatus(InstanceStatus.DELETED_ON_PROVIDER_SIDE);
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setGroupName("gateway");
    primaryGW.setInstanceGroup(instanceGroup);
    InstanceMetaData secondaryGW = new InstanceMetaData();
    secondaryGW.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
    secondaryGW.setInstanceGroup(instanceGroup);
    ArrayList<InstanceMetaData> gatewayInstances = new ArrayList<>();
    gatewayInstances.add(primaryGW);
    gatewayInstances.add(secondaryGW);
    when(stack.getNotTerminatedGatewayInstanceMetadata()).thenReturn(gatewayInstances);
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
        Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> actual = underTest.validateRepair(ManualClusterRepairMode.HOST_GROUP, STACK_ID, Set.of("idbroker"), false);
        assertEquals(1, actual.getError().getValidationErrors().size());
        assertEquals("Gateway node is unhealthy, it must be repaired first.", actual.getError().getValidationErrors().get(0));
    });
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) RepairValidation(com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation) ArrayList(java.util.ArrayList) Map(java.util.Map) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Test(org.junit.jupiter.api.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