Search in sources :

Example 16 with InstanceGroupV2Request

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

the class MockInstanceTerminationUnknownTest method configMockServer.

@BeforeClass
@Parameters({ "mockPort", "sshPort" })
public void configMockServer(@Optional("9443") int mockPort, @Optional("2020") int sshPort) {
    IntegrationTestContext itContext = getItContext();
    Map<String, InstanceGroupV2Request> instanceGroupV2RequestMap = itContext.getContextParam(CloudbreakV2Constants.INSTANCEGROUP_MAP, Map.class);
    String stackName = itContext.getContextParam(CloudbreakV2Constants.STACK_NAME);
    int numberOfServers = 0;
    for (InstanceGroupV2Request igr : instanceGroupV2RequestMap.values()) {
        numberOfServers += igr.getNodeCount();
    }
    InstanceTerminationUnknownMock instanceTerminationMock = (InstanceTerminationUnknownMock) applicationContext.getBean(InstanceTerminationUnknownMock.NAME, mockPort, sshPort, numberOfServers);
    instanceTerminationMock.addAmbariMappings(stackName);
    instanceTerminationMock.addMockEndpoints();
    itContext.putContextParam(CloudbreakV2Constants.MOCK_SERVER, instanceTerminationMock);
    itContext.putContextParam(CloudbreakITContextConstants.MOCK_INSTANCE_MAP, instanceTerminationMock.getInstanceMap());
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) InstanceGroupV2Request(com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request) BeforeClass(org.testng.annotations.BeforeClass) Parameters(org.testng.annotations.Parameters)

Example 17 with InstanceGroupV2Request

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

the class AbstractStackCreationV2Test method createStackRequest.

@BeforeMethod(groups = "V2StackCreationInit")
@Parameters({ "stackName", "credentialName", "region", "availabilityZone", "imageCatalog", "imageId" })
public void createStackRequest(String stackName, @Optional("") String credentialName, @Optional("") String region, @Optional("") String availabilityZone, @Optional("") String imageCatalog, @Optional("") String imageId) {
    IntegrationTestContext itContext = getItContext();
    credentialName = StringUtils.hasText(credentialName) ? credentialName : itContext.getContextParam(CloudbreakV2Constants.CREDENTIAL_NAME);
    region = StringUtils.hasText(region) ? region : itContext.getContextParam(CloudbreakV2Constants.REGION);
    availabilityZone = StringUtils.hasText(availabilityZone) ? availabilityZone : itContext.getContextParam(CloudbreakV2Constants.AVAILABILTYZONE);
    imageCatalog = StringUtils.hasText(imageCatalog) ? imageCatalog : itContext.getContextParam(CloudbreakV2Constants.IMAGECATALOG);
    imageId = StringUtils.hasText(imageId) ? imageId : itContext.getContextParam(CloudbreakV2Constants.IMAGEID);
    Map<String, InstanceGroupV2Request> instanceGroupV2RequestMap = itContext.getContextParam(CloudbreakV2Constants.INSTANCEGROUP_MAP, Map.class);
    Assert.assertTrue(StringUtils.hasText(credentialName), "Credential name is mandatory.");
    Assert.assertTrue(StringUtils.hasText(region), "Region is mandatory.");
    Assert.assertTrue(StringUtils.hasText(availabilityZone), "AvailabilityZone is mandatory.");
    Assert.assertNotNull(instanceGroupV2RequestMap, "InstanceGroup map is mandatory");
    StackV2Request stackV2Request = new StackV2Request();
    GeneralSettings gs = new GeneralSettings();
    stackV2Request.setGeneral(gs);
    gs.setName(stackName);
    gs.setCredentialName(credentialName);
    PlacementSettings ps = new PlacementSettings();
    stackV2Request.setPlacement(ps);
    ps.setRegion(region);
    ps.setAvailabilityZone(availabilityZone);
    if (StringUtils.hasText(imageCatalog) || StringUtils.hasText(imageId)) {
        ImageSettings is = new ImageSettings();
        is.setImageCatalog(imageCatalog);
        is.setImageId(imageId);
        stackV2Request.setImageSettings(is);
    }
    stackV2Request.setInstanceGroups(Lists.newArrayList(instanceGroupV2RequestMap.values()));
    itContext.putContextParam(CloudbreakV2Constants.STACK_CREATION_REQUEST, stackV2Request);
}
Also used : IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) StackV2Request(com.sequenceiq.cloudbreak.api.model.v2.StackV2Request) InstanceGroupV2Request(com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request) PlacementSettings(com.sequenceiq.cloudbreak.api.model.v2.PlacementSettings) GeneralSettings(com.sequenceiq.cloudbreak.api.model.v2.GeneralSettings) ImageSettings(com.sequenceiq.cloudbreak.api.model.v2.ImageSettings) Parameters(org.testng.annotations.Parameters) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 18 with InstanceGroupV2Request

use of com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request 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 19 with InstanceGroupV2Request

use of com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request 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 20 with InstanceGroupV2Request

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

Aggregations

InstanceGroupV2Request (com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request)22 SecurityGroupV2Request (com.sequenceiq.cloudbreak.api.model.v2.SecurityGroupV2Request)9 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)9 Parameters (org.testng.annotations.Parameters)9 BeforeClass (org.testng.annotations.BeforeClass)5 BeforeMethod (org.testng.annotations.BeforeMethod)4 TemplateV2Request (com.sequenceiq.cloudbreak.api.model.v2.TemplateV2Request)3 HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)2 StackV2Request (com.sequenceiq.cloudbreak.api.model.v2.StackV2Request)2 ClusterRequest (com.sequenceiq.cloudbreak.api.model.ClusterRequest)1 ConstraintJson (com.sequenceiq.cloudbreak.api.model.ConstraintJson)1 InstanceGroupRequest (com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest)1 NetworkRequest (com.sequenceiq.cloudbreak.api.model.NetworkRequest)1 OrchestratorRequest (com.sequenceiq.cloudbreak.api.model.OrchestratorRequest)1 SecurityRuleRequest (com.sequenceiq.cloudbreak.api.model.SecurityRuleRequest)1 StackAuthenticationRequest (com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest)1 StackRequest (com.sequenceiq.cloudbreak.api.model.StackRequest)1 UpdateClusterJson (com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)1 ClusterV2Request (com.sequenceiq.cloudbreak.api.model.v2.ClusterV2Request)1 GeneralSettings (com.sequenceiq.cloudbreak.api.model.v2.GeneralSettings)1