use of com.sequenceiq.cloudbreak.api.model.InstanceGroupResponse in project cloudbreak by hortonworks.
the class InstanceGroupToInstanceGroupResponseConverterTest method testConvert.
@Test
public void testConvert() {
// GIVEN
given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(getInstanceMetaData(getSource()));
// WHEN
InstanceGroupResponse result = underTest.convert(getSource());
// THEN
assertEquals(1, result.getNodeCount());
assertEquals(InstanceGroupType.CORE, result.getType());
assertAllFieldsNotNull(result, Lists.newArrayList("template", "securityGroup"));
}
use of com.sequenceiq.cloudbreak.api.model.InstanceGroupResponse in project cloudbreak by hortonworks.
the class CountRecipeResultsTest method testFetchRecipeResult.
@Test
@Parameters({ "searchRecipesOnHosts", "lookingFor", "require" })
public void testFetchRecipeResult(String searchRecipesOnHosts, String lookingFor, Integer require) throws Exception {
// GIVEN
Assert.assertEquals(new File(defaultPrivateKeyFile).exists(), true, "Private cert file not found: " + defaultPrivateKeyFile);
Assert.assertFalse(lookingFor.isEmpty());
IntegrationTestContext itContext = getItContext();
String stackId = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
StackV1Endpoint stackV1Endpoint = itContext.getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class).stackV1Endpoint();
List<InstanceGroupResponse> instanceGroups = stackV1Endpoint.get(Long.valueOf(stackId), new HashSet<>()).getInstanceGroups();
String[] files = lookingFor.split(",");
List<String> publicIps = getPublicIps(instanceGroups, Arrays.asList(searchRecipesOnHosts.split(",")));
Collection<Future<Boolean>> futures = new ArrayList<>(publicIps.size() * files.length);
ExecutorService executorService = Executors.newFixedThreadPool(publicIps.size());
AtomicInteger count = new AtomicInteger(0);
// WHEN
try {
for (String file : files) {
for (String ip : publicIps) {
futures.add((Future<Boolean>) executorService.submit(() -> {
if (findFile(ip, file)) {
count.incrementAndGet();
}
}));
}
}
for (Future<Boolean> future : futures) {
future.get();
}
} finally {
executorService.shutdown();
}
// THEN
Assert.assertEquals(count.get(), require.intValue(), "The number of existing files is different than required.");
}
use of com.sequenceiq.cloudbreak.api.model.InstanceGroupResponse in project cloudbreak by hortonworks.
the class ScalingUtil method getNodeCount.
private static int getNodeCount(StackResponse stackResponse, String instanceGroup) {
List<InstanceGroupResponse> instanceGroups = stackResponse.getInstanceGroups();
int nodeCount = 0;
for (InstanceGroupResponse ig : instanceGroups) {
if (ig.getGroup().equals(instanceGroup)) {
nodeCount = ig.getNodeCount();
break;
}
}
return nodeCount;
}
use of com.sequenceiq.cloudbreak.api.model.InstanceGroupResponse in project cloudbreak by hortonworks.
the class ScalingUtil method getNodeCount.
private static int getNodeCount(StackResponse stackResponse) {
List<InstanceGroupResponse> instanceGroups = stackResponse.getInstanceGroups();
int nodeCount = 0;
for (InstanceGroupResponse instanceGroup : instanceGroups) {
if (!"cbgateway".equals(instanceGroup.getGroup())) {
nodeCount += instanceGroup.getNodeCount();
}
}
return nodeCount;
}
use of com.sequenceiq.cloudbreak.api.model.InstanceGroupResponse in project cloudbreak by hortonworks.
the class ScalingUtil method getNodeCountByHostgroup.
public static Map<String, Integer> getNodeCountByHostgroup(StackResponse stackResponse) {
Map<String, Integer> instanceCount = new HashMap<>();
List<InstanceGroupResponse> instanceGroups = stackResponse.getInstanceGroups();
for (InstanceGroupResponse instanceGroup : instanceGroups) {
if (!"cbgateway".equals(instanceGroup.getGroup())) {
instanceCount.put(instanceGroup.getGroup(), instanceGroup.getNodeCount());
}
}
return instanceCount;
}
Aggregations