Search in sources :

Example 61 with IntegrationTestContext

use of com.sequenceiq.it.IntegrationTestContext in project cloudbreak by hortonworks.

the class InstanceGroupV2PreparationTest method createTemplateRequest.

@BeforeMethod(dependsOnGroups = "igRequestCreation")
@Parameters({ "group", "instanceType", "volumeType", "volumeSize", "volumeCount" })
public void createTemplateRequest(String group, String instanceType, String volumeType, int volumeSize, int volumeCount) {
    TemplateV2Request templateV2Request = new TemplateV2Request();
    templateV2Request.setInstanceType(instanceType);
    templateV2Request.setVolumeType(volumeType);
    templateV2Request.setVolumeSize(volumeSize);
    templateV2Request.setVolumeCount(volumeCount);
    IntegrationTestContext itContext = getItContext();
    Map<String, InstanceGroupV2Request> igMap = itContext.getContextParam(CloudbreakV2Constants.INSTANCEGROUP_MAP, Map.class);
    InstanceGroupV2Request instanceGroupV2Request = igMap.get(group);
    instanceGroupV2Request.setTemplate(templateV2Request);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) InstanceGroupV2Request(com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request) TemplateV2Request(com.sequenceiq.cloudbreak.api.model.v2.TemplateV2Request) Parameters(org.testng.annotations.Parameters) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 62 with IntegrationTestContext

use of com.sequenceiq.it.IntegrationTestContext in project cloudbreak by hortonworks.

the class InstanceGroupV2PreparationTest method createSecurityRequest.

@BeforeMethod(dependsOnGroups = "igRequestCreation")
@Parameters({ "group", "securityRules" })
public void createSecurityRequest(String group, String securityRules) {
    IntegrationTestContext itContext = getItContext();
    Map<String, InstanceGroupV2Request> igMap = itContext.getContextParam(CloudbreakV2Constants.INSTANCEGROUP_MAP, Map.class);
    InstanceGroupV2Request instanceGroupV2Request = igMap.get(group);
    SecurityGroupV2Request securityGroupV2Request = new SecurityGroupV2Request();
    List<String[]> secRules = templateAdditionHelper.parseCommaSeparatedRows(securityRules);
    List<SecurityRuleRequest> secRulesRequests = Lists.newArrayList();
    for (String[] secRule : secRules) {
        SecurityRuleRequest securityRuleRequest = new SecurityRuleRequest();
        securityRuleRequest.setProtocol(secRule[0]);
        securityRuleRequest.setSubnet(secRule[1]);
        securityRuleRequest.setPorts(secRule[2]);
        secRulesRequests.add(securityRuleRequest);
    }
    securityGroupV2Request.setSecurityRules(secRulesRequests);
    instanceGroupV2Request.setSecurityGroup(securityGroupV2Request);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) InstanceGroupV2Request(com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request) SecurityGroupV2Request(com.sequenceiq.cloudbreak.api.model.v2.SecurityGroupV2Request) SecurityRuleRequest(com.sequenceiq.cloudbreak.api.model.SecurityRuleRequest) Parameters(org.testng.annotations.Parameters) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 63 with IntegrationTestContext

use of com.sequenceiq.it.IntegrationTestContext in project cloudbreak by hortonworks.

the class InstanceGroupV2PreparationTest method createInstanceGroupRequest.

@BeforeMethod(groups = "igRequestCreation")
@Parameters({ "group", "nodeCount", "groupType", "recoveryMode" })
public void createInstanceGroupRequest(String group, int nodeCount, String groupType, @Optional("MANUAL") String recoveryMode) {
    InstanceGroupV2Request instanceGroupV2Request = new InstanceGroupV2Request();
    instanceGroupV2Request.setGroup(group);
    instanceGroupV2Request.setNodeCount(nodeCount);
    instanceGroupV2Request.setType(InstanceGroupType.valueOf(groupType));
    IntegrationTestContext itContext = getItContext();
    Map<String, InstanceGroupV2Request> igMap;
    synchronized (itContext) {
        igMap = itContext.getContextParam(CloudbreakV2Constants.INSTANCEGROUP_MAP, Map.class);
        if (igMap == null) {
            igMap = Maps.newConcurrentMap();
            itContext.putContextParam(CloudbreakV2Constants.INSTANCEGROUP_MAP, igMap);
        }
    }
    igMap.put(group, instanceGroupV2Request);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) InstanceGroupV2Request(com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request) Map(java.util.Map) Parameters(org.testng.annotations.Parameters) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 64 with IntegrationTestContext

use of com.sequenceiq.it.IntegrationTestContext in project cloudbreak by hortonworks.

the class ClusterAndStackDownscaleTest method testClusterAndStackDownscale.

@Test
@Parameters({ "instanceGroup", "scalingAdjustment" })
public void testClusterAndStackDownscale(@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();
    String ambariUser = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_USER_ID);
    String ambariPassword = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID);
    String ambariPort = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PORT_ID);
    int expectedNodeCountStack = ScalingUtil.getNodeCountStack(stackV1Endpoint, stackId) + scalingAdjustment;
    int expectedNodeCountCluster = ScalingUtil.getNodeCountAmbari(stackV1Endpoint, ambariPort, stackId, ambariUser, ambariPassword, itContext) + scalingAdjustment;
    // WHEN
    UpdateClusterJson updateClusterJson = new UpdateClusterJson();
    HostGroupAdjustmentJson hostGroupAdjustmentJson = new HostGroupAdjustmentJson();
    hostGroupAdjustmentJson.setHostGroup(instanceGroup);
    hostGroupAdjustmentJson.setWithStackUpdate(true);
    hostGroupAdjustmentJson.setScalingAdjustment(scalingAdjustment);
    updateClusterJson.setHostGroupAdjustment(hostGroupAdjustmentJson);
    CloudbreakUtil.checkResponse("DownscaleCluster", getCloudbreakClient().clusterEndpoint().put((long) stackIntId, updateClusterJson));
    CloudbreakUtil.waitAndCheckClusterStatus(getCloudbreakClient(), stackId, "AVAILABLE");
    CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackId, "AVAILABLE");
    // THEN
    ScalingUtil.checkStackScaled(stackV1Endpoint, stackId, expectedNodeCountStack);
    ScalingUtil.checkClusterScaled(stackV1Endpoint, ambariPort, stackId, ambariUser, ambariPassword, expectedNodeCountCluster, itContext);
    ScalingUtil.putInstanceCountToContext(itContext, stackId);
}
Also used : StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) CloudbreakClient(com.sequenceiq.cloudbreak.client.CloudbreakClient) HostGroupAdjustmentJson(com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson) StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) UpdateClusterJson(com.sequenceiq.cloudbreak.api.model.UpdateClusterJson) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Example 65 with IntegrationTestContext

use of com.sequenceiq.it.IntegrationTestContext in project cloudbreak by hortonworks.

the class ClusterScalingTest method testClusterScaling.

@Test
@Parameters({ "instanceGroup", "scalingAdjustment" })
public void testClusterScaling(@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();
    String ambariUser = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_USER_ID);
    String ambariPassword = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID);
    String ambariPort = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PORT_ID);
    int expectedNodeCount = ScalingUtil.getNodeCountAmbari(stackV1Endpoint, ambariPort, stackId, ambariUser, ambariPassword, itContext) + scalingAdjustment;
    // WHEN
    UpdateClusterJson updateClusterJson = new UpdateClusterJson();
    HostGroupAdjustmentJson hostGroupAdjustmentJson = new HostGroupAdjustmentJson();
    hostGroupAdjustmentJson.setHostGroup(instanceGroup);
    hostGroupAdjustmentJson.setWithStackUpdate(false);
    hostGroupAdjustmentJson.setScalingAdjustment(scalingAdjustment);
    updateClusterJson.setHostGroupAdjustment(hostGroupAdjustmentJson);
    CloudbreakUtil.checkResponse("ScalingCluster", getCloudbreakClient().clusterEndpoint().put((long) stackIntId, updateClusterJson));
    CloudbreakUtil.waitAndCheckClusterStatus(getCloudbreakClient(), stackId, "AVAILABLE");
    // THEN
    ScalingUtil.checkClusterScaled(stackV1Endpoint, ambariPort, stackId, ambariUser, ambariPassword, expectedNodeCount, itContext);
}
Also used : StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) CloudbreakClient(com.sequenceiq.cloudbreak.client.CloudbreakClient) HostGroupAdjustmentJson(com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson) StackV1Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint) UpdateClusterJson(com.sequenceiq.cloudbreak.api.model.UpdateClusterJson) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)71 Parameters (org.testng.annotations.Parameters)39 Test (org.testng.annotations.Test)32 AbstractCloudbreakIntegrationTest (com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest)26 BeforeMethod (org.testng.annotations.BeforeMethod)26 StackV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint)10 InstanceGroupV2Request (com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request)9 BeforeClass (org.testng.annotations.BeforeClass)9 HashMap (java.util.HashMap)8 UpdateClusterJson (com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)7 UpdateStackJson (com.sequenceiq.cloudbreak.api.model.UpdateStackJson)7 CloudbreakClient (com.sequenceiq.cloudbreak.client.CloudbreakClient)7 StackResponse (com.sequenceiq.cloudbreak.api.model.StackResponse)6 ArrayList (java.util.ArrayList)6 StackV2Request (com.sequenceiq.cloudbreak.api.model.v2.StackV2Request)5 KerberosRequest (com.sequenceiq.cloudbreak.api.model.KerberosRequest)4 ClusterV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.ClusterV1Endpoint)3 ClusterRequest (com.sequenceiq.cloudbreak.api.model.ClusterRequest)3 HostGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson)3 HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)3