Search in sources :

Example 1 with StackScaleRequestV2

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

the class StackScalingV2Test method testStackScaling.

@Test
@Parameters({ "hostGroup", "desiredCount", "checkAmbari" })
public void testStackScaling(String hostGroup, int desiredCount, @Optional("true") boolean checkAmbari) throws Exception {
    // GIVEN
    IntegrationTestContext itContext = getItContext();
    String stackName = itContext.getContextParam(CloudbreakV2Constants.STACK_NAME);
    String stackId = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
    String ambariUser = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_USER_ID);
    String ambariPassword = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID);
    String ambariPort = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PORT_ID);
    StackScaleRequestV2 stackScaleRequestV2 = new StackScaleRequestV2();
    stackScaleRequestV2.setGroup(hostGroup);
    stackScaleRequestV2.setDesiredCount(desiredCount);
    // WHEN
    Response response = getCloudbreakClient().stackV2Endpoint().putScaling(stackName, stackScaleRequestV2);
    // THEN
    CloudbreakUtil.checkResponse("ScalingStackV2", response);
    Map<String, String> desiredStatuses = new HashMap<>();
    desiredStatuses.put("status", "AVAILABLE");
    desiredStatuses.put("clusterStatus", "AVAILABLE");
    CloudbreakUtil.waitAndCheckStatuses(getCloudbreakClient(), stackId, desiredStatuses);
    ScalingUtil.checkStackScaled(getCloudbreakClient().stackV2Endpoint(), stackId, hostGroup, desiredCount);
    if (checkAmbari) {
        int nodeCount = ScalingUtil.getNodeCountStack(getCloudbreakClient().stackV2Endpoint(), stackId);
        ScalingUtil.checkClusterScaled(getCloudbreakClient().stackV2Endpoint(), ambariPort, stackId, ambariUser, ambariPassword, nodeCount, itContext);
    }
}
Also used : Response(javax.ws.rs.core.Response) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) StackScaleRequestV2(com.sequenceiq.cloudbreak.api.model.StackScaleRequestV2) HashMap(java.util.HashMap) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

StackScaleRequestV2 (com.sequenceiq.cloudbreak.api.model.StackScaleRequestV2)1 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)1 AbstractCloudbreakIntegrationTest (com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest)1 HashMap (java.util.HashMap)1 Response (javax.ws.rs.core.Response)1 Parameters (org.testng.annotations.Parameters)1 Test (org.testng.annotations.Test)1