Search in sources :

Example 1 with AutoscaleClient

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);
}
Also used : StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) AutoscaleClient(com.sequenceiq.periscope.client.AutoscaleClient) CloudbreakClient(com.sequenceiq.cloudbreak.client.CloudbreakClient) StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest)

Example 2 with AutoscaleClient

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);
}
Also used : AutoscaleClient(com.sequenceiq.periscope.client.AutoscaleClient) AutoscaleClientBuilder(com.sequenceiq.periscope.client.AutoscaleClient.AutoscaleClientBuilder) Parameters(org.testng.annotations.Parameters) BeforeSuite(org.testng.annotations.BeforeSuite)

Aggregations

AutoscaleClient (com.sequenceiq.periscope.client.AutoscaleClient)2 Parameters (org.testng.annotations.Parameters)2 StackV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint)1 CloudbreakClient (com.sequenceiq.cloudbreak.client.CloudbreakClient)1 AbstractCloudbreakIntegrationTest (com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest)1 AutoscaleClientBuilder (com.sequenceiq.periscope.client.AutoscaleClient.AutoscaleClientBuilder)1 AfterTest (org.testng.annotations.AfterTest)1 BeforeSuite (org.testng.annotations.BeforeSuite)1 Test (org.testng.annotations.Test)1