use of com.amazonaws.services.elasticmapreduce.model.ListStepsResult in project herd by FINRAOS.
the class EmrDaoTest method getClusterActiveStepAssertReturnNullWhenStepListIsEmpty.
@Test
public void getClusterActiveStepAssertReturnNullWhenStepListIsEmpty() throws Exception {
String clusterId = "clusterId";
when(mockEmrOperations.listStepsRequest(any(), any())).thenReturn(new ListStepsResult());
assertNull(emrDao.getClusterActiveStep(clusterId, new AwsParamsDto()));
}
use of com.amazonaws.services.elasticmapreduce.model.ListStepsResult in project herd by FINRAOS.
the class EmrDaoTest method getClusterActiveStepAssertReturnFirstWhenStepListSizeGt1.
@Test
public void getClusterActiveStepAssertReturnFirstWhenStepListSizeGt1() throws Exception {
String clusterId = "clusterId";
StepSummary expectedStepSummary = new StepSummary();
expectedStepSummary.setId("expected");
ListStepsResult listStepsResult = new ListStepsResult();
listStepsResult.setSteps(Arrays.asList(expectedStepSummary, new StepSummary()));
when(mockEmrOperations.listStepsRequest(any(), any())).thenReturn(listStepsResult);
assertEquals(expectedStepSummary, emrDao.getClusterActiveStep(clusterId, new AwsParamsDto()));
}
use of com.amazonaws.services.elasticmapreduce.model.ListStepsResult in project herd by FINRAOS.
the class EmrServiceTest method testCreateEmrClusterStartupSteps.
/**
* This method tests the cluster creation with the startup hadoop jar steps being added.
*/
@Test
public void testCreateEmrClusterStartupSteps() 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();
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());
assertNotNull(emrCluster.getEmrClusterDefinition());
assertTrue(emrCluster.isEmrClusterCreated());
assertEquals(expectedEmrClusterDefinition, emrCluster.getEmrClusterDefinition());
validateEmrClusterCreationLogUnique(emrCluster, expectedEmrClusterDefinition);
ListStepsRequest listStepsRequest = (new ListStepsRequest()).withClusterId(emrCluster.getId());
ListStepsResult listStepsResult = emrOperations.listStepsRequest(null, listStepsRequest);
List<StepSummary> addedSteps = listStepsResult.getSteps();
// Validate that the step was added.
for (HadoopJarStep hadoopJarStep : expectedEmrClusterDefinition.getHadoopJarSteps()) {
boolean stepFound = false;
for (StepSummary stepSummary : addedSteps) {
if (stepSummary.getName().equals(hadoopJarStep.getStepName())) {
// Step found
stepFound = true;
break;
}
}
assertTrue(stepFound);
}
}
use of com.amazonaws.services.elasticmapreduce.model.ListStepsResult in project herd by FINRAOS.
the class MockEmrOperationsImpl method listStepsRequest.
@Override
public ListStepsResult listStepsRequest(AmazonElasticMapReduceClient emrClient, ListStepsRequest listStepsRequest) {
MockEmrJobFlow cluster = getClusterById(listStepsRequest.getClusterId());
if (cluster == null) {
throw new AmazonServiceException("No cluster found with jobFlowId: " + listStepsRequest.getClusterId());
}
List<StepSummary> steps = new ArrayList<>();
// Add steps that are in these states
for (MockEmrJobFlow step : cluster.getSteps()) {
if ((listStepsRequest.getStepStates() == null || listStepsRequest.getStepStates().isEmpty()) || listStepsRequest.getStepStates().contains(step.getStatus())) {
StepSummary stepSummary = new StepSummary().withId(step.getJobFlowId()).withName(step.getJobFlowName()).withStatus(new StepStatus().withState(step.getStatus())).withConfig(new HadoopStepConfig().withJar(step.getJarLocation()));
steps.add(stepSummary);
}
}
return new ListStepsResult().withSteps(steps);
}
use of com.amazonaws.services.elasticmapreduce.model.ListStepsResult in project herd by FINRAOS.
the class EmrDaoTest method getClusterActiveStepAssertCallListStepsAndReturnStepSummary.
@Test
public void getClusterActiveStepAssertCallListStepsAndReturnStepSummary() throws Exception {
String clusterId = "clusterId";
StepSummary expectedStepSummary = new StepSummary();
when(mockEmrOperations.listStepsRequest(any(), any())).then(new Answer<ListStepsResult>() {
@Override
public ListStepsResult answer(InvocationOnMock invocation) throws Throwable {
ListStepsRequest listStepsRequest = invocation.getArgument(1);
assertEquals(clusterId, listStepsRequest.getClusterId());
assertEquals(1, listStepsRequest.getStepStates().size());
assertEquals(StepState.RUNNING.toString(), listStepsRequest.getStepStates().get(0));
ListStepsResult listStepsResult = new ListStepsResult();
listStepsResult.setSteps(new ArrayList<>());
listStepsResult.getSteps().add(expectedStepSummary);
return listStepsResult;
}
});
assertEquals(expectedStepSummary, emrDao.getClusterActiveStep(clusterId, new AwsParamsDto()));
}
Aggregations