use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrServiceTest method testCreateEmrClusterDuplicate.
@Test
public void testCreateEmrClusterDuplicate() 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
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
emrService.createCluster(request);
EmrCluster emrCluster = emrService.createCluster(request);
// Validate the returned object against the input.
assertNotNull(emrCluster);
assertTrue(emrCluster.getNamespace().equals(request.getNamespace()));
assertTrue(emrCluster.getEmrClusterDefinitionName().equals(request.getEmrClusterDefinitionName()));
assertTrue(emrCluster.getEmrClusterName().equals(request.getEmrClusterName()));
assertNotNull(emrCluster.getId());
assertNull(emrCluster.isDryRun());
assertFalse(emrCluster.isEmrClusterCreated());
assertNull(emrCluster.getEmrClusterDefinition());
// should throw if not unique
validateEmrClusterCreationLogUnique(emrCluster, expectedEmrClusterDefinition);
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrServiceTest method testCreateEmrClusterAmazonOtherException.
/**
* This method tests the error cases for AmazonExceptions for AmazonServiceException
*/
@Test(expected = AmazonServiceException.class)
public void testCreateEmrClusterAmazonOtherException() throws Exception {
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH).getInputStream());
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
emrClusterDefinition.setAmiVersion(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION);
configXml = xmlHelper.objectToXml(emrClusterDefinition);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml);
// Create a new EMR cluster create request.
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
emrService.createCluster(request);
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrServiceTest method testCreateEmrClusterServiceRole.
/**
* This method tests the service IAM role
*/
@Test
public void testCreateEmrClusterServiceRole() throws Exception {
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream());
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
emrClusterDefinition.setServiceIamRole(emrClusterDefinition.getEc2NodeIamProfileName());
configXml = xmlHelper.objectToXml(emrClusterDefinition);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml);
// Create a new EMR cluster create request.
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
emrService.createCluster(request);
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrServiceTest method testCreateEmrClusterOverrideAllNull.
@Test
public void testCreateEmrClusterOverrideAllNull() 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
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
EmrClusterDefinition emrClusterDefinitionOverride = new EmrClusterDefinition();
request.setEmrClusterDefinitionOverride(emrClusterDefinitionOverride);
EmrCluster emrCluster = emrService.createCluster(request);
// Validate the returned object against the input.
assertNotNull(emrCluster);
assertTrue(emrCluster.getNamespace().equals(request.getNamespace()));
assertTrue(emrCluster.getEmrClusterDefinitionName().equals(request.getEmrClusterDefinitionName()));
assertTrue(emrCluster.getEmrClusterName().equals(request.getEmrClusterName()));
assertNotNull(emrCluster.getId());
assertNull(emrCluster.isDryRun());
assertTrue(emrCluster.isEmrClusterCreated());
assertNotNull(emrCluster.getEmrClusterDefinition());
assertEquals(expectedEmrClusterDefinition, emrCluster.getEmrClusterDefinition());
validateEmrClusterCreationLogUnique(emrCluster, expectedEmrClusterDefinition);
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrServiceTest method testCreateEmrClusterAmazonBadRequest.
/**
* This method tests the error cases for AmazonExceptions for Illegal Argument
*/
@Test(expected = IllegalArgumentException.class)
public void testCreateEmrClusterAmazonBadRequest() throws Exception {
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH).getInputStream());
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
emrClusterDefinition.setAmiVersion(MockAwsOperationsHelper.AMAZON_BAD_REQUEST);
configXml = xmlHelper.objectToXml(emrClusterDefinition);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml);
// Create a new EMR cluster create request.
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
emrService.createCluster(request);
}
Aggregations