use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrServiceTest method testCreateEmrClusterSecurityConfiguration.
/**
* This method tests security configuration.
*/
@Test
public void testCreateEmrClusterSecurityConfiguration() 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);
// Set the security configuration along with the EMR release label.
// This is needed since security configuration is not supported prior to EMR version 4.8.0.
emrClusterDefinition.setSecurityConfiguration("securityConfiguration");
emrClusterDefinition.setReleaseLabel("4.8.0");
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 testCreateEmrClusterAmazonObjectNotFound.
/**
* This method tests the error cases for AmazonExceptions for Illegal Argument
*/
@Test(expected = ObjectNotFoundException.class)
public void testCreateEmrClusterAmazonObjectNotFound() 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_NOT_FOUND);
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 testCreateEmrClusterSecurityConfigurationNoReleaseLabel.
@Test
public void testCreateEmrClusterSecurityConfigurationNoReleaseLabel() 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);
// Set the security configuration without an EMR release label.
emrClusterDefinition.setSecurityConfiguration("securityConfiguration");
emrClusterDefinition.setReleaseLabel(BLANK_TEXT);
configXml = xmlHelper.objectToXml(emrClusterDefinition);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml);
// Try to create a new EMR cluster.
try {
emrService.createCluster(getNewEmrClusterCreateRequest());
} catch (IllegalArgumentException e) {
assertEquals("EMR security configuration is not supported prior to EMR release 4.8.0.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrServiceTest method testGetEmrClusterByIdWithFleetInstance.
/**
* This method tests the happy path scenario by providing all the parameters
*/
@Test
public void testGetEmrClusterByIdWithFleetInstance() 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_CLUSTER_STATUS_WAITING);
configXml = xmlHelper.objectToXml(emrClusterDefinition);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml);
// Create a new EMR cluster create request
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
EmrCluster emrCluster = emrService.createCluster(request);
EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = EmrClusterAlternateKeyDto.builder().withNamespace(NAMESPACE).withEmrClusterDefinitionName(EMR_CLUSTER_DEFINITION_NAME).withEmrClusterName(request.getEmrClusterName()).build();
EmrCluster emrClusterGet = emrService.getCluster(emrClusterAlternateKeyDto, emrCluster.getId(), null, true, null, true);
// Validate the returned object against the input.
assertNotNull(emrCluster);
assertNotNull(emrClusterGet);
assertTrue(emrCluster.getId().equals(emrClusterGet.getId()));
assertTrue(emrCluster.getNamespace().equals(emrClusterGet.getNamespace()));
assertTrue(emrCluster.getEmrClusterDefinitionName().equals(emrClusterGet.getEmrClusterDefinitionName()));
assertTrue(emrCluster.getEmrClusterName().equals(emrClusterGet.getEmrClusterName()));
assertNotNull(emrClusterGet.getInstanceFleets());
assertTrue(emrClusterGet.getInstanceFleets().size() == 1);
}
use of org.finra.herd.model.api.xml.EmrClusterDefinition in project herd by FINRAOS.
the class EmrServiceTest method testCreateEmrClusterOverrideSecurityGroups.
@Test
public void testCreateEmrClusterOverrideSecurityGroups() 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);
expectedEmrClusterDefinition.setMasterSecurityGroup(EMR_MASTER_SECURITY_GROUP + "override");
expectedEmrClusterDefinition.setSlaveSecurityGroup(EMR_SLAVE_SECURITY_GROUP + "override");
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, definitionXml);
// Create a new EMR cluster create request
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
EmrClusterDefinition emrClusterDefinitionOverride = new EmrClusterDefinition();
emrClusterDefinitionOverride.setMasterSecurityGroup(EMR_MASTER_SECURITY_GROUP + "override");
emrClusterDefinitionOverride.setSlaveSecurityGroup(EMR_SLAVE_SECURITY_GROUP + "override");
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);
}
Aggregations