Search in sources :

Example 16 with StackV1Endpoint

use of com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint in project cloudbreak by hortonworks.

the class ClusterAndStackDownscaleTest method testClusterAndStackDownscale.

@Test
@Parameters({ "instanceGroup", "scalingAdjustment" })
public void testClusterAndStackDownscale(@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 expectedNodeCountStack = ScalingUtil.getNodeCountStack(stackV1Endpoint, stackId) + scalingAdjustment;
    int expectedNodeCountCluster = ScalingUtil.getNodeCountAmbari(stackV1Endpoint, ambariPort, stackId, ambariUser, ambariPassword, itContext) + scalingAdjustment;
    // WHEN
    UpdateClusterJson updateClusterJson = new UpdateClusterJson();
    HostGroupAdjustmentJson hostGroupAdjustmentJson = new HostGroupAdjustmentJson();
    hostGroupAdjustmentJson.setHostGroup(instanceGroup);
    hostGroupAdjustmentJson.setWithStackUpdate(true);
    hostGroupAdjustmentJson.setScalingAdjustment(scalingAdjustment);
    updateClusterJson.setHostGroupAdjustment(hostGroupAdjustmentJson);
    CloudbreakUtil.checkResponse("DownscaleCluster", getCloudbreakClient().clusterEndpoint().put((long) stackIntId, updateClusterJson));
    CloudbreakUtil.waitAndCheckClusterStatus(getCloudbreakClient(), stackId, "AVAILABLE");
    CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackId, "AVAILABLE");
    // THEN
    ScalingUtil.checkStackScaled(stackV1Endpoint, stackId, expectedNodeCountStack);
    ScalingUtil.checkClusterScaled(stackV1Endpoint, ambariPort, stackId, ambariUser, ambariPassword, expectedNodeCountCluster, itContext);
    ScalingUtil.putInstanceCountToContext(itContext, stackId);
}
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)

Example 17 with StackV1Endpoint

use of com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint 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)

Example 18 with StackV1Endpoint

use of com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint in project cloudbreak by hortonworks.

the class StackAndClusterUpscaleTest method testStackAndClusterUpscale.

@Test
@Parameters({ "instanceGroup", "scalingAdjustment" })
public void testStackAndClusterUpscale(@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 expectedNodeCountStack = ScalingUtil.getNodeCountStack(stackV1Endpoint, stackId) + scalingAdjustment;
    int expectedNodeCountCluster = ScalingUtil.getNodeCountAmbari(stackV1Endpoint, ambariPort, stackId, ambariUser, ambariPassword, itContext) + scalingAdjustment;
    // WHEN
    UpdateStackJson updateStackJson = new UpdateStackJson();
    updateStackJson.setWithClusterEvent(true);
    InstanceGroupAdjustmentJson instanceGroupAdjustmentJson = new InstanceGroupAdjustmentJson();
    instanceGroupAdjustmentJson.setInstanceGroup(instanceGroup);
    instanceGroupAdjustmentJson.setScalingAdjustment(scalingAdjustment);
    updateStackJson.setInstanceGroupAdjustment(instanceGroupAdjustmentJson);
    CloudbreakUtil.checkResponse("UpscaleStack", getCloudbreakClient().stackV1Endpoint().put((long) stackIntId, updateStackJson));
    CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackId, "AVAILABLE");
    CloudbreakUtil.waitAndCheckClusterStatus(getCloudbreakClient(), stackId, "AVAILABLE");
    // THEN
    ScalingUtil.checkStackScaled(stackV1Endpoint, stackId, expectedNodeCountStack);
    ScalingUtil.checkClusterScaled(stackV1Endpoint, ambariPort, stackId, ambariUser, ambariPassword, expectedNodeCountCluster, itContext);
    ScalingUtil.putInstanceCountToContext(itContext, stackId);
}
Also used : StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) CloudbreakClient(com.sequenceiq.cloudbreak.client.CloudbreakClient) InstanceGroupAdjustmentJson(com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson) StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Example 19 with StackV1Endpoint

use of com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint in project cloudbreak by hortonworks.

the class StackScalingTest method testStackScaling.

@Test
@Parameters({ "instanceGroup", "scalingAdjustment" })
public void testStackScaling(@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();
    int expectedNodeCount = ScalingUtil.getNodeCountStack(stackV1Endpoint, stackId) + scalingAdjustment;
    // WHEN
    UpdateStackJson updateStackJson = new UpdateStackJson();
    updateStackJson.setWithClusterEvent(false);
    InstanceGroupAdjustmentJson instanceGroupAdjustmentJson = new InstanceGroupAdjustmentJson();
    instanceGroupAdjustmentJson.setInstanceGroup(instanceGroup);
    instanceGroupAdjustmentJson.setScalingAdjustment(scalingAdjustment);
    updateStackJson.setInstanceGroupAdjustment(instanceGroupAdjustmentJson);
    CloudbreakUtil.checkResponse("ScalingStack", getCloudbreakClient().stackV1Endpoint().put((long) stackIntId, updateStackJson));
    CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackId, "AVAILABLE");
    // THEN
    ScalingUtil.checkStackScaled(stackV1Endpoint, stackId, expectedNodeCount);
    StackResponse stackResponse = stackV1Endpoint.get(Long.valueOf(stackId), new HashSet<>());
    itContext.putContextParam(CloudbreakITContextConstants.INSTANCE_COUNT, ScalingUtil.getNodeCountByHostgroup(stackResponse));
}
Also used : StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) CloudbreakClient(com.sequenceiq.cloudbreak.client.CloudbreakClient) InstanceGroupAdjustmentJson(com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson) StackResponse(com.sequenceiq.cloudbreak.api.model.StackResponse) StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

StackV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint)16 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)14 Parameters (org.testng.annotations.Parameters)14 Test (org.testng.annotations.Test)14 CloudbreakClient (com.sequenceiq.cloudbreak.client.CloudbreakClient)11 AbstractCloudbreakIntegrationTest (com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest)11 StackResponse (com.sequenceiq.cloudbreak.api.model.StackResponse)8 HashMap (java.util.HashMap)4 StackEndpoint (com.sequenceiq.cloudbreak.api.endpoint.common.StackEndpoint)3 ClusterV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.ClusterV1Endpoint)3 EventEndpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.EventEndpoint)3 ClusterRequest (com.sequenceiq.cloudbreak.api.model.ClusterRequest)3 HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)3 InstanceGroupResponse (com.sequenceiq.cloudbreak.api.model.InstanceGroupResponse)3 KerberosRequest (com.sequenceiq.cloudbreak.api.model.KerberosRequest)3 HistoryEndpoint (com.sequenceiq.periscope.api.endpoint.v1.HistoryEndpoint)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 HostGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson)2