use of com.sequenceiq.it.cloudbreak.v2.mock.ScalingMock in project cloudbreak by hortonworks.
the class MockClusterScalingTest method configMockServer.
@BeforeClass
@Parameters({ "mockPort", "sshPort", "scalingAdjustment", "instanceGroup" })
public void configMockServer(@Optional("9443") int mockPort, @Optional("2020") int sshPort, @Optional("1") int scalingAdjustment, String instanceGroup) {
IntegrationTestContext itContext = getItContext();
Map<String, CloudVmMetaDataStatus> instanceMap = itContext.getContextParam(CloudbreakITContextConstants.MOCK_INSTANCE_MAP, Map.class);
ScalingMock scalingMock = (ScalingMock) applicationContext.getBean(ScalingMock.NAME, mockPort, sshPort, instanceMap);
scalingMock.addSPIEndpoints();
scalingMock.addMockEndpoints();
scalingMock.addAmbariMappings(CLUSTER_NAME);
if (scalingAdjustment > 0) {
scalingMock.addInstance(scalingAdjustment);
}
itContext.putContextParam(CloudbreakV2Constants.MOCK_SERVER, scalingMock);
}
use of com.sequenceiq.it.cloudbreak.v2.mock.ScalingMock in project cloudbreak by hortonworks.
the class MockClusterScalingTest method testScaling.
@SuppressWarnings("Duplicates")
@Test
@Parameters({ "instanceGroup", "scalingAdjustment", "mockPort" })
public void testScaling(@Optional("slave_1") String instanceGroup, @Optional("1") int scalingAdjustment, @Optional("9443") int mockPort) {
// GIVEN
IntegrationTestContext itContext = getItContext();
String stackId = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
int stackIntId = Integer.parseInt(stackId);
// WHEN
if (scalingAdjustment < 0) {
UpdateClusterJson updateClusterJson = new UpdateClusterJson();
HostGroupAdjustmentJson hostGroupAdjustmentJson = new HostGroupAdjustmentJson();
hostGroupAdjustmentJson.setHostGroup(instanceGroup);
hostGroupAdjustmentJson.setWithStackUpdate(false);
hostGroupAdjustmentJson.setScalingAdjustment(scalingAdjustment);
updateClusterJson.setHostGroupAdjustment(hostGroupAdjustmentJson);
CloudbreakUtil.checkResponse("DownscaleCluster", getCloudbreakClient().clusterEndpoint().put((long) stackIntId, updateClusterJson));
CloudbreakUtil.waitAndCheckClusterStatus(getCloudbreakClient(), stackId, "AVAILABLE");
UpdateStackJson updateStackJson = new UpdateStackJson();
updateStackJson.setWithClusterEvent(false);
InstanceGroupAdjustmentJson instanceGroupAdjustmentJson = new InstanceGroupAdjustmentJson();
instanceGroupAdjustmentJson.setInstanceGroup(instanceGroup);
instanceGroupAdjustmentJson.setScalingAdjustment(scalingAdjustment);
updateStackJson.setInstanceGroupAdjustment(instanceGroupAdjustmentJson);
CloudbreakUtil.checkResponse("DownscaleStack", getCloudbreakClient().stackV1Endpoint().put((long) stackIntId, updateStackJson));
CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackId, "AVAILABLE");
} else {
UpdateStackJson updateStackJson = new UpdateStackJson();
updateStackJson.setWithClusterEvent(false);
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");
UpdateClusterJson updateClusterJson = new UpdateClusterJson();
HostGroupAdjustmentJson hostGroupAdjustmentJson = new HostGroupAdjustmentJson();
hostGroupAdjustmentJson.setHostGroup(instanceGroup);
hostGroupAdjustmentJson.setWithStackUpdate(false);
hostGroupAdjustmentJson.setScalingAdjustment(scalingAdjustment);
updateClusterJson.setHostGroupAdjustment(hostGroupAdjustmentJson);
CloudbreakUtil.checkResponse("UpscaleCluster", getCloudbreakClient().clusterEndpoint().put((long) stackIntId, updateClusterJson));
CloudbreakUtil.waitAndCheckClusterStatus(getCloudbreakClient(), stackId, "AVAILABLE");
}
// THEN
CloudbreakUtil.checkClusterAvailability(itContext.getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class).stackV1Endpoint(), "8080", stackId, itContext.getContextParam(CloudbreakITContextConstants.AMBARI_USER_ID), itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID), false);
ScalingMock scalingMock = getItContext().getContextParam(CloudbreakV2Constants.MOCK_SERVER, ScalingMock.class);
scalingMock.verifyV1Calls(CLUSTER_NAME, scalingAdjustment, false);
}
use of com.sequenceiq.it.cloudbreak.v2.mock.ScalingMock in project cloudbreak by hortonworks.
the class MockClusterScalingTest method breakDown.
@AfterClass
public void breakDown() {
ScalingMock scalingMock = getItContext().getContextParam(CloudbreakV2Constants.MOCK_SERVER, ScalingMock.class);
scalingMock.stop();
}
use of com.sequenceiq.it.cloudbreak.v2.mock.ScalingMock in project cloudbreak by hortonworks.
the class MockScalingTest method testStackScaling.
@Test
@Parameters({ "hostGroup", "desiredCount", "checkAmbari" })
public void testStackScaling(String hostGroup, int desiredCount, @Optional("false") boolean checkAmbari) throws Exception {
// GIVEN
// WHEN
super.testStackScaling(hostGroup, desiredCount, checkAmbari);
// THEN
ScalingMock scalingMock = getItContext().getContextParam(CloudbreakV2Constants.MOCK_SERVER, ScalingMock.class);
String clusterName = getItContext().getContextParam(CloudbreakV2Constants.STACK_NAME);
String stackId = getItContext().getContextParam(CloudbreakITContextConstants.STACK_ID);
StackV2Request stackV2Request = getItContext().getContextParam(CloudbreakV2Constants.STACK_CREATION_REQUEST, StackV2Request.class);
boolean securityEnabled = stackV2Request.getCluster().getAmbari().getEnableSecurity();
scalingMock.verifyV2Calls(clusterName, ScalingUtil.getNodeCountStack(getCloudbreakClient().stackV2Endpoint(), stackId), securityEnabled);
}
use of com.sequenceiq.it.cloudbreak.v2.mock.ScalingMock in project cloudbreak by hortonworks.
the class MockScalingTest method configMockServer.
@BeforeClass
@Parameters({ "mockPort", "sshPort", "desiredCount", "hostGroup" })
public void configMockServer(@Optional("9443") int mockPort, @Optional("2020") int sshPort, int desiredCount, String hostGroup) {
IntegrationTestContext itContext = getItContext();
String clusterName = itContext.getContextParam(CloudbreakV2Constants.STACK_NAME);
StackResponse response = getCloudbreakClient().stackV2Endpoint().getPrivate(clusterName, null);
java.util.Optional<InstanceGroupResponse> igg = response.getInstanceGroups().stream().filter(ig -> ig.getGroup().equals(hostGroup)).findFirst();
Map<String, CloudVmInstanceStatus> instanceMap = itContext.getContextParam(CloudbreakITContextConstants.MOCK_INSTANCE_MAP, Map.class);
ScalingMock scalingMock = (ScalingMock) applicationContext.getBean(ScalingMock.NAME, mockPort, sshPort, instanceMap);
scalingMock.addSPIEndpoints();
scalingMock.addMockEndpoints();
scalingMock.addAmbariMappings(clusterName);
itContext.putContextParam(CloudbreakV2Constants.MOCK_SERVER, scalingMock);
igg.ifPresent(ig -> {
int scalingAdjustment = desiredCount - ig.getNodeCount();
if (scalingAdjustment > 0) {
scalingMock.addInstance(scalingAdjustment);
}
});
}
Aggregations