Search in sources :

Example 16 with HostGroupAdjustmentJson

use of com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson in project cloudbreak by hortonworks.

the class ClusterScalingTest method testClusterScaling.

@Test
@Parameters({ "instanceGroup", "scalingAdjustment" })
public void testClusterScaling(@Optional("slave_1") String instanceGroup, int scalingAdjustment) {
    // GIVEN
    IntegrationTestContext itContext = getItContext();
    String stackId = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
    int stackIntId = Integer.parseInt(stackId);
    StackV1Endpoint stackV1Endpoint = itContext.getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class).stackV1Endpoint();
    String ambariUser = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_USER_ID);
    String ambariPassword = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID);
    String ambariPort = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PORT_ID);
    int expectedNodeCount = ScalingUtil.getNodeCountAmbari(stackV1Endpoint, ambariPort, stackId, ambariUser, ambariPassword, itContext) + scalingAdjustment;
    // WHEN
    UpdateClusterJson updateClusterJson = new UpdateClusterJson();
    HostGroupAdjustmentJson hostGroupAdjustmentJson = new HostGroupAdjustmentJson();
    hostGroupAdjustmentJson.setHostGroup(instanceGroup);
    hostGroupAdjustmentJson.setWithStackUpdate(false);
    hostGroupAdjustmentJson.setScalingAdjustment(scalingAdjustment);
    updateClusterJson.setHostGroupAdjustment(hostGroupAdjustmentJson);
    CloudbreakUtil.checkResponse("ScalingCluster", getCloudbreakClient().clusterEndpoint().put((long) stackIntId, updateClusterJson));
    CloudbreakUtil.waitAndCheckClusterStatus(getCloudbreakClient(), stackId, "AVAILABLE");
    // THEN
    ScalingUtil.checkClusterScaled(stackV1Endpoint, ambariPort, stackId, ambariUser, ambariPassword, expectedNodeCount, itContext);
}
Also used : StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) CloudbreakClient(com.sequenceiq.cloudbreak.client.CloudbreakClient) HostGroupAdjustmentJson(com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson) StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) UpdateClusterJson(com.sequenceiq.cloudbreak.api.model.UpdateClusterJson) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

HostGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson)16 Test (org.junit.Test)11 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)9 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)9 HashSet (java.util.HashSet)8 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)6 Status (com.sequenceiq.cloudbreak.api.model.Status)6 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)6 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)6 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)6 UpdateClusterJson (com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)5 Collections.singletonMap (java.util.Collections.singletonMap)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Matchers.anyString (org.mockito.Matchers.anyString)4 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)3 AbstractCloudbreakIntegrationTest (com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest)3 Parameters (org.testng.annotations.Parameters)3 Test (org.testng.annotations.Test)3 StackV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint)2