use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrDaoTest method getEmrMasterInstanceReturnsInstance.
@Test
public void getEmrMasterInstanceReturnsInstance() throws Exception {
String clusterId = "clusterId";
Instance expectedInstance = new Instance();
/*
* Stub EmrOperations.listClusterInstancesRequest() and assert correct parameters are being passed into the method when the call is made.
*/
when(mockEmrOperations.listClusterInstancesRequest(any(), any())).thenAnswer(new Answer<ListInstancesResult>() {
@Override
public ListInstancesResult answer(InvocationOnMock invocation) throws Throwable {
/*
* Assert correct parameters are used when calling this method.
*/
ListInstancesRequest listInstancesRequest = invocation.getArgument(1);
assertEquals(clusterId, listInstancesRequest.getClusterId());
List<String> instanceGroupTypes = listInstancesRequest.getInstanceGroupTypes();
assertEquals(1, instanceGroupTypes.size());
assertEquals("MASTER", instanceGroupTypes.get(0));
ListInstancesResult listInstancesResult = new ListInstancesResult();
listInstancesResult.setInstances(Arrays.asList(expectedInstance));
return listInstancesResult;
}
});
Instance actualInstance = emrDao.getEmrMasterInstance(clusterId, new AwsParamsDto());
assertEquals(expectedInstance, actualInstance);
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrDaoTest method getEmrClientAssertClientConfigurationNotSetWhenProxyHostIsBlank.
@Test
public void getEmrClientAssertClientConfigurationNotSetWhenProxyHostIsBlank() throws Exception {
String httpProxyHost = "";
Integer httpProxyPort = 1234;
AwsParamsDto awsParamsDto = new AwsParamsDto();
awsParamsDto.setHttpProxyHost(httpProxyHost);
awsParamsDto.setHttpProxyPort(httpProxyPort);
AmazonElasticMapReduceClient amazonElasticMapReduceClient = emrDao.getEmrClient(awsParamsDto);
ClientConfiguration clientConfiguration = (ClientConfiguration) ReflectionTestUtils.getField(amazonElasticMapReduceClient, "clientConfiguration");
assertNotNull(clientConfiguration);
assertNull(clientConfiguration.getProxyHost());
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrDaoTest method addEmrMasterSecurityGroupsCallsEc2AddSecurityGroup.
@Test
public void addEmrMasterSecurityGroupsCallsEc2AddSecurityGroup() throws Exception {
String clusterName = "clusterName";
List<String> securityGroups = Arrays.asList("securityGroup");
AwsParamsDto awsParams = new AwsParamsDto();
String ec2InstanceId = "ec2InstanceId";
ListClustersResult listClustersResult = new ListClustersResult();
listClustersResult.setClusters(new ArrayList<>());
ClusterSummary clusterSummary = new ClusterSummary();
clusterSummary.setId("clusterId");
clusterSummary.setName(clusterName);
listClustersResult.getClusters().add(clusterSummary);
when(mockEmrOperations.listEmrClusters(any(), any())).thenReturn(listClustersResult);
ListInstancesResult listInstancesResult = new ListInstancesResult();
listInstancesResult.setInstances(new ArrayList<>());
Instance instance = new Instance();
instance.setEc2InstanceId(ec2InstanceId);
listInstancesResult.getInstances().add(instance);
when(mockEmrOperations.listClusterInstancesRequest(any(), any())).thenReturn(listInstancesResult);
emrDao.addEmrMasterSecurityGroups(clusterName, securityGroups, awsParams);
verify(mockEc2Dao).addSecurityGroupsToEc2Instance(eq(ec2InstanceId), eq(securityGroups), any());
verifyNoMoreInteractions(mockEc2Dao);
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrDaoTest method getActiveEmrClusterByNameAssertReturnNullWhenClusterNameIsBlank.
@Test
public void getActiveEmrClusterByNameAssertReturnNullWhenClusterNameIsBlank() throws Exception {
String clusterName = "";
when(mockEmrOperations.listEmrClusters(any(), any())).thenReturn(new ListClustersResult());
assertNull(emrDao.getActiveEmrClusterByName(clusterName, new AwsParamsDto()));
}
use of org.finra.herd.model.dto.AwsParamsDto 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