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