Search in sources :

Example 16 with UpdateStackJson

use of com.sequenceiq.cloudbreak.api.model.UpdateStackJson 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)

Example 17 with UpdateStackJson

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

the class UpdateStackRequestValidatorTest method testInValidShouldReturnTrueWhenNodeCountIsLowerThanOneUpdatedAndWithClusterEvent.

@Test
public void testInValidShouldReturnTrueWhenNodeCountIsLowerThanOneUpdatedAndWithClusterEvent() {
    UpdateStackJson updateStackJson = new UpdateStackJson();
    updateStackJson.setWithClusterEvent(true);
    InstanceGroupAdjustmentJson instanceGroupAdjustmentJson = new InstanceGroupAdjustmentJson();
    instanceGroupAdjustmentJson.setScalingAdjustment(-1);
    instanceGroupAdjustmentJson.setInstanceGroup("slave_1");
    updateStackJson.setInstanceGroupAdjustment(instanceGroupAdjustmentJson);
    updateStackJson.setStatus(null);
    boolean valid = underTest.isValid(updateStackJson, constraintValidatorContext);
    assertFalse(valid);
}
Also used : UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) InstanceGroupAdjustmentJson(com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson) Test(org.junit.Test)

Example 18 with UpdateStackJson

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

the class UpdateStackRequestValidatorTest method testIsValidShouldReturnTrueWhenStatusIsUpdated.

@Test
public void testIsValidShouldReturnTrueWhenStatusIsUpdated() {
    UpdateStackJson updateStackJson = new UpdateStackJson();
    updateStackJson.setInstanceGroupAdjustment(null);
    updateStackJson.setStatus(StatusRequest.STARTED);
    boolean valid = underTest.isValid(updateStackJson, constraintValidatorContext);
    assertTrue(valid);
}
Also used : UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) Test(org.junit.Test)

Example 19 with UpdateStackJson

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

the class UpdateStackRequestValidatorTest method testIsValidShouldReturnTrueWhenNodeCountIsUpdated.

@Test
public void testIsValidShouldReturnTrueWhenNodeCountIsUpdated() {
    UpdateStackJson updateStackJson = new UpdateStackJson();
    InstanceGroupAdjustmentJson instanceGroupAdjustmentJson = new InstanceGroupAdjustmentJson();
    instanceGroupAdjustmentJson.setScalingAdjustment(12);
    instanceGroupAdjustmentJson.setInstanceGroup("slave_1");
    updateStackJson.setInstanceGroupAdjustment(instanceGroupAdjustmentJson);
    updateStackJson.setStatus(null);
    boolean valid = underTest.isValid(updateStackJson, constraintValidatorContext);
    assertTrue(valid);
}
Also used : UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) InstanceGroupAdjustmentJson(com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson) Test(org.junit.Test)

Aggregations

UpdateStackJson (com.sequenceiq.cloudbreak.api.model.UpdateStackJson)19 InstanceGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson)8 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)7 AbstractCloudbreakIntegrationTest (com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest)7 Test (org.testng.annotations.Test)7 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)5 Stack (com.sequenceiq.cloudbreak.domain.Stack)5 Test (org.junit.Test)5 Parameters (org.testng.annotations.Parameters)5 UpdateClusterJson (com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)4 StackV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint)2 CloudbreakClient (com.sequenceiq.cloudbreak.client.CloudbreakClient)2 AmbariAddressJson (com.sequenceiq.cloudbreak.api.model.AmbariAddressJson)1 HostGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson)1 StackResponse (com.sequenceiq.cloudbreak.api.model.StackResponse)1 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)1 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)1 ScalingMock (com.sequenceiq.it.cloudbreak.v2.mock.ScalingMock)1 History (com.sequenceiq.periscope.domain.History)1