Search in sources :

Example 1 with InstanceGroupResponse

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"));
}
Also used : TypeDescriptor(org.springframework.core.convert.TypeDescriptor) InstanceGroupResponse(com.sequenceiq.cloudbreak.api.model.InstanceGroupResponse) Test(org.junit.Test)

Example 2 with InstanceGroupResponse

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.");
}
Also used : StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) CloudbreakClient(com.sequenceiq.cloudbreak.client.CloudbreakClient) ArrayList(java.util.ArrayList) InstanceGroupResponse(com.sequenceiq.cloudbreak.api.model.InstanceGroupResponse) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) File(java.io.File) HashSet(java.util.HashSet) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Example 3 with InstanceGroupResponse

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;
}
Also used : InstanceGroupResponse(com.sequenceiq.cloudbreak.api.model.InstanceGroupResponse) StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) StackEndpoint(com.sequenceiq.cloudbreak.api.endpoint.common.StackEndpoint)

Example 4 with InstanceGroupResponse

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;
}
Also used : InstanceGroupResponse(com.sequenceiq.cloudbreak.api.model.InstanceGroupResponse) StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) StackEndpoint(com.sequenceiq.cloudbreak.api.endpoint.common.StackEndpoint)

Example 5 with InstanceGroupResponse

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;
}
Also used : HashMap(java.util.HashMap) InstanceGroupResponse(com.sequenceiq.cloudbreak.api.model.InstanceGroupResponse)

Aggregations

InstanceGroupResponse (com.sequenceiq.cloudbreak.api.model.InstanceGroupResponse)11 StackV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint)5 ArrayList (java.util.ArrayList)4 StackEndpoint (com.sequenceiq.cloudbreak.api.endpoint.common.StackEndpoint)3 InstanceMetaDataJson (com.sequenceiq.cloudbreak.api.model.InstanceMetaDataJson)3 StackResponse (com.sequenceiq.cloudbreak.api.model.StackResponse)3 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)3 Parameters (org.testng.annotations.Parameters)3 Test (org.testng.annotations.Test)3 Map (java.util.Map)2 AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)1 DescribeSpotInstanceRequestsResult (com.amazonaws.services.ec2.model.DescribeSpotInstanceRequestsResult)1 SpotInstanceRequest (com.amazonaws.services.ec2.model.SpotInstanceRequest)1 EventEndpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.EventEndpoint)1 ClusterResponse (com.sequenceiq.cloudbreak.api.model.ClusterResponse)1 CredentialResponse (com.sequenceiq.cloudbreak.api.model.CredentialResponse)1 FailurePolicyResponse (com.sequenceiq.cloudbreak.api.model.FailurePolicyResponse)1 ImageJson (com.sequenceiq.cloudbreak.api.model.ImageJson)1 NetworkResponse (com.sequenceiq.cloudbreak.api.model.NetworkResponse)1 OrchestratorResponse (com.sequenceiq.cloudbreak.api.model.OrchestratorResponse)1