use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrServiceWithAccountIdTest method getNewEmrClusterCreateRequestWithAccountId.
/**
* This method fills-up the parameters required for the EMR cluster create request, with overridden AWS account Id.
*/
private EmrClusterCreateRequest getNewEmrClusterCreateRequestWithAccountId() throws Exception {
// Create the definition.
EmrClusterCreateRequest request = new EmrClusterCreateRequest();
// Fill in the parameters.
request.setNamespace(NAMESPACE);
request.setEmrClusterDefinitionName(EMR_CLUSTER_DEFINITION_NAME);
request.setEmrClusterName("UT_EMR_CLUSTER-" + Math.random());
EmrClusterDefinition emrClusterDefinitionOverride = new EmrClusterDefinition();
request.setEmrClusterDefinitionOverride(emrClusterDefinitionOverride);
emrClusterDefinitionOverride.setAccountId(AWS_ACCOUNT_ID);
return request;
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrServiceWithAccountIdTest method testCreateEmrClusterWithAccountIdAccountNoExists.
@Test
public void testCreateEmrClusterWithAccountIdAccountNoExists() throws Exception {
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
String definitionXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream());
EmrClusterDefinition expectedEmrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, definitionXml);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, definitionXml);
// Create a new EMR cluster create request and add an account id to the EMR cluster definition override.
EmrClusterCreateRequest emrClusterCreateRequest = getNewEmrClusterCreateRequestWithAccountId();
EmrClusterDefinition emrClusterDefinitionOverride = new EmrClusterDefinition();
emrClusterCreateRequest.setEmrClusterDefinitionOverride(emrClusterDefinitionOverride);
emrClusterDefinitionOverride.setAccountId(AWS_ACCOUNT_ID);
// Try to create an EMR cluster using a non-existing AWS account.
try {
emrService.createCluster(emrClusterCreateRequest);
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Trusting AWS account with id \"%s\" doesn't exist.", AWS_ACCOUNT_ID), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrHelperTest method testCreateEmrClusterBlankTags.
/**
* This method tests the blank EC2 tags
*/
@Test
public void testCreateEmrClusterBlankTags() throws Exception {
// Create the namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream());
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
// Add new node tags. First tag does not contain any tag value; but contains node tag name
NodeTag nodeTag1 = new NodeTag();
nodeTag1.setTagName("NO_TAG_VALUE");
// Second tag does not contain node tag name; but contains node tag value
NodeTag nodeTag2 = new NodeTag();
nodeTag2.setTagValue("NO_TAG_NAME");
// Create the list and add the tags
ArrayList<NodeTag> nodeTagList = new ArrayList<>();
nodeTagList.add(nodeTag1);
nodeTagList.add(nodeTag2);
// Set the tags
emrClusterDefinition.setNodeTags(nodeTagList);
emrDao.createEmrCluster(EMR_CLUSTER_DEFINITION_NAME, emrClusterDefinition, emrHelper.getAwsParamsDto());
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrClusterDefinitionHelperTest method testValidateEmrClusterDefinitionConfigurationMasterOnDemandThresholdSpecified.
/**
* Tests case where validation is run against the definition generated by createValidEmrClusterDefinition() The master instance on-demand threshold is
* specified. The definition is not valid. On-demand threshold is only allowed when max search price is specified.
*/
@Test
public void testValidateEmrClusterDefinitionConfigurationMasterOnDemandThresholdSpecified() {
EmrClusterDefinition emrClusterDefinition = createValidEmrClusterDefinition();
emrClusterDefinition.getInstanceDefinitions().getMasterInstances().setInstanceOnDemandThreshold(BigDecimal.ONE);
try {
emrClusterDefinitionHelper.validateEmrClusterDefinitionConfiguration(emrClusterDefinition);
fail("expected IllegalArgumentException, but no exception was thrown");
} catch (Exception e) {
assertEquals("thrown exception", IllegalArgumentException.class, e.getClass());
}
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrClusterDefinitionHelperTest method testValidateEmrClusterDefinitionConfigurationCoreInstancesNotSpecified.
@Test
public void testValidateEmrClusterDefinitionConfigurationCoreInstancesNotSpecified() {
EmrClusterDefinition emrClusterDefinition = createValidEmrClusterDefinition();
emrClusterDefinition.getInstanceDefinitions().setCoreInstances(null);
try {
emrClusterDefinitionHelper.validateEmrClusterDefinitionConfiguration(emrClusterDefinition);
} catch (Exception e) {
fail("expected no exception, but " + e.getClass() + " was thrown. " + e);
}
}
Aggregations