use of org.finra.herd.model.api.xml.InstanceDefinitions in project herd by FINRAOS.
the class EmrHelperTest method testIsInstanceDefinitionsEmpty.
@Test
public void testIsInstanceDefinitionsEmpty() {
assertTrue(emrHelper.isInstanceDefinitionsEmpty(null));
assertTrue(emrHelper.isInstanceDefinitionsEmpty(new InstanceDefinitions(null, null, null)));
assertFalse(emrHelper.isInstanceDefinitionsEmpty(new InstanceDefinitions(new MasterInstanceDefinition(), null, null)));
assertFalse(emrHelper.isInstanceDefinitionsEmpty(new InstanceDefinitions(null, new InstanceDefinition(), null)));
assertFalse(emrHelper.isInstanceDefinitionsEmpty(new InstanceDefinitions(null, null, new InstanceDefinition())));
}
use of org.finra.herd.model.api.xml.InstanceDefinitions in project herd by FINRAOS.
the class EmrDaoImplTest method testGetInstanceGroupConfigsMissingOptionalInstanceDefinitions.
@Test
public void testGetInstanceGroupConfigsMissingOptionalInstanceDefinitions() {
// Create objects required for testing.
final Integer instanceCount = 0;
final InstanceDefinitions instanceDefinitions = new InstanceDefinitions(new MasterInstanceDefinition(), null, null);
// Mock the external calls.
when(emrHelper.isInstanceDefinitionsEmpty(instanceDefinitions)).thenReturn(false);
// Call the method under test.
List<InstanceGroupConfig> result = emrDaoImpl.getInstanceGroupConfigs(instanceDefinitions);
// Verify the external calls.
verify(emrHelper).isInstanceDefinitionsEmpty(instanceDefinitions);
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(Arrays.asList(new InstanceGroupConfig(InstanceRoleType.MASTER, null, instanceCount)), result);
}
use of org.finra.herd.model.api.xml.InstanceDefinitions in project herd by FINRAOS.
the class EmrDaoImplTest method testGetInstanceGroupConfigsWhenInstanceDefinitionsObjectIsEmpty.
@Test
public void testGetInstanceGroupConfigsWhenInstanceDefinitionsObjectIsEmpty() {
// Create objects required for testing.
final InstanceDefinitions instanceDefinitions = new InstanceDefinitions();
// Mock the external calls.
when(emrHelper.isInstanceDefinitionsEmpty(instanceDefinitions)).thenReturn(true);
// Call the method under test.
List<InstanceGroupConfig> result = emrDaoImpl.getInstanceGroupConfigs(instanceDefinitions);
// Verify the external calls.
verify(emrHelper).isInstanceDefinitionsEmpty(instanceDefinitions);
verifyNoMoreInteractionsHelper();
// Validate the results.
assertNull(result);
}
use of org.finra.herd.model.api.xml.InstanceDefinitions in project herd by FINRAOS.
the class EmrDaoTest method createEmrClusterAssertInstallOozieDisabled.
@Test
public void createEmrClusterAssertInstallOozieDisabled() throws Exception {
/*
* Use only minimum required options
*/
String clusterName = "clusterName";
EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition();
InstanceDefinitions instanceDefinitions = new InstanceDefinitions();
instanceDefinitions.setMasterInstances(new MasterInstanceDefinition(10, "masterInstanceType", NO_EMR_CLUSTER_DEFINITION_EBS_CONFIGURATION, NO_INSTANCE_SPOT_PRICE, NO_INSTANCE_MAX_SEARCH_PRICE, NO_INSTANCE_ON_DEMAND_THRESHOLD));
instanceDefinitions.setCoreInstances(new InstanceDefinition(20, "coreInstanceType", NO_EMR_CLUSTER_DEFINITION_EBS_CONFIGURATION, NO_INSTANCE_SPOT_PRICE, NO_INSTANCE_MAX_SEARCH_PRICE, NO_INSTANCE_ON_DEMAND_THRESHOLD));
emrClusterDefinition.setInstanceDefinitions(instanceDefinitions);
emrClusterDefinition.setNodeTags(Arrays.asList(new NodeTag("tagName", "tagValue")));
emrClusterDefinition.setInstallOozie(false);
String clusterId = "clusterId";
when(mockEmrOperations.runEmrJobFlow(any(), any())).then(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
RunJobFlowRequest runJobFlowRequest = invocation.getArgument(1);
// The oozie step should be skipped.
assertEquals(0, runJobFlowRequest.getSteps().size());
return clusterId;
}
});
assertEquals(clusterId, emrDao.createEmrCluster(clusterName, emrClusterDefinition, new AwsParamsDto()));
}
use of org.finra.herd.model.api.xml.InstanceDefinitions in project herd by FINRAOS.
the class EmrServiceTest method testCreateEmrClusterOverrideInstanceFleetsWithInstanceDefinitions.
@Test
public void testCreateEmrClusterOverrideInstanceFleetsWithInstanceDefinitions() throws Exception {
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
// Create an EMR cluster definition that uses instance fleets instead of instance definitions.
String definitionXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream());
EmrClusterDefinition expectedEmrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, definitionXml);
InstanceDefinitions instanceDefinitions = expectedEmrClusterDefinition.getInstanceDefinitions();
expectedEmrClusterDefinition.setInstanceDefinitions(null);
expectedEmrClusterDefinition.setInstanceFleets(Arrays.asList(new EmrClusterDefinitionInstanceFleet()));
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, xmlHelper.objectToXml(expectedEmrClusterDefinition));
// Update the count of master instances in the instance definitions.
instanceDefinitions.getMasterInstances().setInstanceCount(instanceDefinitions.getMasterInstances().getInstanceCount() + 1);
// Create a new EMR cluster create request that replaces instance fleets with instance definitions.
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
EmrClusterDefinition emrClusterDefinitionOverride = new EmrClusterDefinition();
emrClusterDefinitionOverride.setInstanceDefinitions(instanceDefinitions);
emrClusterDefinitionOverride.setInstanceFleets(new ArrayList<>());
request.setEmrClusterDefinitionOverride(emrClusterDefinitionOverride);
// Update the expected EMR cluster definition.
expectedEmrClusterDefinition.setInstanceDefinitions(instanceDefinitions);
expectedEmrClusterDefinition.setInstanceFleets(new ArrayList<>());
// Create the cluster.
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