use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class EmrServiceTest method testCreateEmrClusterInstanceNotDefined.
/**
* This method tests the error cases for Illegal Arguments for Instances not defined properly
*/
@Test
public void testCreateEmrClusterInstanceNotDefined() throws Exception {
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
// Create the test EMR cluster definition entity with missing instance definitions.
String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH).getInputStream());
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
emrClusterDefinition.setInstanceDefinitions(null);
configXml = xmlHelper.objectToXml(emrClusterDefinition);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml);
// Try to create a new EMR cluster using EMR cluster definition with missing both instance definitions and instance fleets.
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
try {
emrService.createCluster(request);
fail();
} catch (IllegalArgumentException e) {
assertEquals("Instance group definitions or instance fleets must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class EmrServiceTest method testAddSecurityGroup.
/**
* This method tests the happy path scenario for adding security groups
*/
@Test
public void testAddSecurityGroup() throws Exception {
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
emrService.createCluster(request);
// Create the Add security group.
EmrMasterSecurityGroupAddRequest emrMasterSecurityGroupAddRequest = getNewEmrAddSecurityGroupMasterRequest(request.getEmrClusterName());
EmrMasterSecurityGroup emrMasterSecurityGroup = emrService.addSecurityGroupsToClusterMaster(emrMasterSecurityGroupAddRequest);
// Validate the returned object against the input.
assertNotNull(emrMasterSecurityGroup);
assertTrue(emrMasterSecurityGroup.getNamespace().equals(request.getNamespace()));
assertTrue(emrMasterSecurityGroup.getEmrClusterDefinitionName().equals(request.getEmrClusterDefinitionName()));
assertTrue(emrMasterSecurityGroup.getEmrClusterName().equals(request.getEmrClusterName()));
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class EmrServiceTest method testAddSecurityGroupClusterDoesNotExist.
/**
* This method tests the scenario where cluster does not exist
*/
@Test(expected = IllegalArgumentException.class)
public void testAddSecurityGroupClusterDoesNotExist() throws Exception {
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
// Create the Add security group.
EmrMasterSecurityGroupAddRequest emrMasterSecurityGroupAddRequest = getNewEmrAddSecurityGroupMasterRequest("DOES_NOT_EXIST");
emrService.addSecurityGroupsToClusterMaster(emrMasterSecurityGroupAddRequest);
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class EmrServiceTest method testCreateEmrClusterOverrideList.
@Test
public void testCreateEmrClusterOverrideList() 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();
emrClusterDefinitionOverride.setApplications(Collections.<EmrClusterDefinitionApplication>emptyList());
expectedEmrClusterDefinition.setApplications(emrClusterDefinitionOverride.getApplications());
emrClusterDefinitionOverride.setConfigurations(Collections.<EmrClusterDefinitionConfiguration>emptyList());
expectedEmrClusterDefinition.setConfigurations(emrClusterDefinitionOverride.getConfigurations());
emrClusterDefinitionOverride.setCustomBootstrapActionAll(Collections.<ScriptDefinition>emptyList());
expectedEmrClusterDefinition.setCustomBootstrapActionAll(emrClusterDefinitionOverride.getCustomBootstrapActionAll());
emrClusterDefinitionOverride.setCustomBootstrapActionMaster(Collections.<ScriptDefinition>emptyList());
expectedEmrClusterDefinition.setCustomBootstrapActionMaster(emrClusterDefinitionOverride.getCustomBootstrapActionMaster());
emrClusterDefinitionOverride.setDaemonConfigurations(Collections.<Parameter>emptyList());
expectedEmrClusterDefinition.setDaemonConfigurations(emrClusterDefinitionOverride.getDaemonConfigurations());
emrClusterDefinitionOverride.setHadoopConfigurations(Collections.<Serializable>emptyList());
expectedEmrClusterDefinition.setHadoopConfigurations(emrClusterDefinitionOverride.getHadoopConfigurations());
emrClusterDefinitionOverride.setHadoopJarSteps(Collections.<HadoopJarStep>emptyList());
expectedEmrClusterDefinition.setHadoopJarSteps(emrClusterDefinitionOverride.getHadoopJarSteps());
emrClusterDefinitionOverride.setAdditionalMasterSecurityGroups(Collections.emptyList());
expectedEmrClusterDefinition.setAdditionalMasterSecurityGroups(emrClusterDefinitionOverride.getAdditionalMasterSecurityGroups());
emrClusterDefinitionOverride.setAdditionalSlaveSecurityGroups(Collections.emptyList());
expectedEmrClusterDefinition.setAdditionalSlaveSecurityGroups(emrClusterDefinitionOverride.getAdditionalSlaveSecurityGroups());
List<NodeTag> nodeTags = expectedEmrClusterDefinition.getNodeTags();
nodeTags.add(new NodeTag("testTag", "test"));
emrClusterDefinitionOverride.setNodeTags(nodeTags);
expectedEmrClusterDefinition.setNodeTags(nodeTags);
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.jpa.NamespaceEntity in project herd by FINRAOS.
the class EmrServiceTest method testTerminateEmrCluster.
/**
* This method tests the happy path scenario by providing all the parameters
*/
@Test
public void testTerminateEmrCluster() throws Exception {
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
// 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 emrClusterTerminated = emrService.terminateCluster(emrClusterAlternateKeyDto, true, null, null);
// Validate the returned object against the input.
assertNotNull(emrCluster);
assertNotNull(emrClusterTerminated);
assertTrue(emrCluster.getNamespace().equals(emrClusterTerminated.getNamespace()));
assertTrue(emrCluster.getEmrClusterDefinitionName().equals(emrClusterTerminated.getEmrClusterDefinitionName()));
assertTrue(emrCluster.getEmrClusterName().equals(emrClusterTerminated.getEmrClusterName()));
}
Aggregations