use of com.sequenceiq.periscope.client.AutoscaleClient in project cloudbreak by hortonworks.
the class AutoScalingPrometheusTest method testAutoscaling.
@Test
@Parameters({ "cooldown", "clusterMinSize", "clusterMaxSize", "policyName", "operator", "alertRuleName", "period", "threshold", "hostGroup", "scalingAdjustment" })
public void testAutoscaling(int cooldown, int clusterMinSize, int clusterMaxSize, String policyName, String operator, String alertRuleName, int period, Double threshold, String hostGroup, int scalingAdjustment) {
// GIVEN
itContext = getItContext();
String stackId = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
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);
autoscaleClient = itContext.getContextParam(CloudbreakITContextConstants.AUTOSCALE_CLIENT, AutoscaleClient.class);
Long clusterId = AutoscalingUtil.getPeriscopeClusterId(autoscaleClient, stackId);
long currentTime = RecoveryUtil.getCurentTimeStamp();
int expectedNodeCountStack = ScalingUtil.getNodeCountStack(stackV1Endpoint, stackId) + scalingAdjustment;
int expectedNodeCountCluster = ScalingUtil.getNodeCountAmbari(stackV1Endpoint, ambariPort, stackId, ambariUser, ambariPassword, itContext) + scalingAdjustment;
// WHEN
AutoscalingUtil.configureAutoScaling(autoscaleClient, clusterId, cooldown, clusterMinSize, clusterMaxSize);
AutoscalingUtil.switchAutoscaling(autoscaleClient, clusterId, true);
AutoscalingUtil.createPrometheusAlert(autoscaleClient, clusterId, policyName, operator, alertRuleName, period, threshold);
Long alertId = AutoscalingUtil.getAlertId(autoscaleClient, clusterId, policyName);
AutoscalingUtil.setAlertsToContext(itContext, clusterId, alertId);
AutoscalingUtil.createPolicy(autoscaleClient, policyName, clusterId, alertId, hostGroup, scalingAdjustment);
// THEN
AutoscalingUtil.checkHistory(autoscaleClient, clusterId, currentTime);
AutoscalingUtil.checkScaling(itContext, getCloudbreakClient(), scalingAdjustment, stackId, expectedNodeCountStack, expectedNodeCountCluster);
}
use of com.sequenceiq.periscope.client.AutoscaleClient in project cloudbreak by hortonworks.
the class AutoscaleTestSuiteInitializer method initCloudbreakSuite.
@BeforeSuite(dependsOnMethods = "initContext")
@Parameters("periscopeServer")
public void initCloudbreakSuite(@Optional("") String periscopeServer) {
periscopeServer = StringUtils.hasLength(periscopeServer) ? periscopeServer : defaultPeriscopeServer;
String identity = itContext.getContextParam(IntegrationTestContext.IDENTITY_URL);
String user = itContext.getContextParam(IntegrationTestContext.AUTH_USER);
String password = itContext.getContextParam(IntegrationTestContext.AUTH_PASSWORD);
AutoscaleClient autoscaleClient = new AutoscaleClientBuilder(periscopeServer + autoscaleRootContextPath, identity, "cloudbreak_shell").withCertificateValidation(false).withDebug(true).withCredential(user, password).withIgnorePreValidation(false).build();
itContext.putContextParam(CloudbreakITContextConstants.AUTOSCALE_CLIENT, autoscaleClient);
}
Aggregations