Search in sources :

Example 1 with RunJobFlowRequest

use of com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest in project herd by FINRAOS.

the class EmrDaoTest method createEmrClusterAssertCallRunEmrJobFlowWithInstanceFleetAndMultipleSubnets.

@Test
public void createEmrClusterAssertCallRunEmrJobFlowWithInstanceFleetAndMultipleSubnets() throws Exception {
    // Create objects required for testing.
    final String clusterName = "clusterName";
    final String clusterId = "clusterId";
    final String name = STRING_VALUE;
    final String instanceFleetType = STRING_VALUE_2;
    final Integer targetOnDemandCapacity = INTEGER_VALUE;
    final Integer targetSpotCapacity = INTEGER_VALUE_2;
    final List<EmrClusterDefinitionInstanceTypeConfig> emrClusterDefinitionInstanceTypeConfigs = null;
    final EmrClusterDefinitionLaunchSpecifications emrClusterDefinitionLaunchSpecifications = null;
    final EmrClusterDefinitionInstanceFleet emrClusterDefinitionInstanceFleet = new EmrClusterDefinitionInstanceFleet(name, instanceFleetType, targetOnDemandCapacity, targetSpotCapacity, emrClusterDefinitionInstanceTypeConfigs, emrClusterDefinitionLaunchSpecifications);
    // Create an EMR cluster definition with instance fleet configuration and multiple EC2 subnet IDs.
    EmrClusterDefinition emrClusterDefinition = new EmrClusterDefinition();
    emrClusterDefinition.setInstanceFleets(Arrays.asList(emrClusterDefinitionInstanceFleet));
    emrClusterDefinition.setSubnetId(String.format("%s , %s  ", EC2_SUBNET, EC2_SUBNET_2));
    emrClusterDefinition.setNodeTags(Arrays.asList(new NodeTag("tagName", "tagValue")));
    when(mockEmrOperations.runEmrJobFlow(any(), any())).then(new Answer<String>() {

        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
            // Assert that the given EMR cluster definition produced the correct RunJobFlowRequest.
            RunJobFlowRequest runJobFlowRequest = invocation.getArgument(1);
            JobFlowInstancesConfig jobFlowInstancesConfig = runJobFlowRequest.getInstances();
            assertEquals(0, CollectionUtils.size(jobFlowInstancesConfig.getInstanceGroups()));
            final List<InstanceTypeConfig> expectedInstanceTypeConfigs = null;
            assertEquals(Arrays.asList(new InstanceFleetConfig().withName(name).withInstanceFleetType(instanceFleetType).withTargetOnDemandCapacity(targetOnDemandCapacity).withTargetSpotCapacity(targetSpotCapacity).withInstanceTypeConfigs(expectedInstanceTypeConfigs).withLaunchSpecifications(null)), jobFlowInstancesConfig.getInstanceFleets());
            assertNull(jobFlowInstancesConfig.getEc2SubnetId());
            assertEquals(2, CollectionUtils.size(jobFlowInstancesConfig.getEc2SubnetIds()));
            assertTrue(jobFlowInstancesConfig.getEc2SubnetIds().contains(EC2_SUBNET));
            assertTrue(jobFlowInstancesConfig.getEc2SubnetIds().contains(EC2_SUBNET_2));
            assertEquals(herdStringHelper.getRequiredConfigurationValue(ConfigurationValue.EMR_DEFAULT_EC2_NODE_IAM_PROFILE_NAME), runJobFlowRequest.getJobFlowRole());
            assertEquals(herdStringHelper.getRequiredConfigurationValue(ConfigurationValue.EMR_DEFAULT_SERVICE_IAM_ROLE_NAME), runJobFlowRequest.getServiceRole());
            List<StepConfig> stepConfigs = runJobFlowRequest.getSteps();
            assertEquals(0, stepConfigs.size());
            List<Tag> tags = runJobFlowRequest.getTags();
            assertEquals(1, tags.size());
            {
                Tag tag = tags.get(0);
                assertEquals("tagName", tag.getKey());
                assertEquals("tagValue", tag.getValue());
            }
            return clusterId;
        }
    });
    assertEquals(clusterId, emrDao.createEmrCluster(clusterName, emrClusterDefinition, new AwsParamsDto()));
}
Also used : EmrClusterDefinitionInstanceTypeConfig(org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceTypeConfig) AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) RunJobFlowRequest(com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest) JobFlowInstancesConfig(com.amazonaws.services.elasticmapreduce.model.JobFlowInstancesConfig) InstanceFleetConfig(com.amazonaws.services.elasticmapreduce.model.InstanceFleetConfig) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) InvocationOnMock(org.mockito.invocation.InvocationOnMock) NodeTag(org.finra.herd.model.api.xml.NodeTag) List(java.util.List) ArrayList(java.util.ArrayList) Tag(com.amazonaws.services.elasticmapreduce.model.Tag) NodeTag(org.finra.herd.model.api.xml.NodeTag) EmrClusterDefinitionInstanceFleet(org.finra.herd.model.api.xml.EmrClusterDefinitionInstanceFleet) EmrClusterDefinitionLaunchSpecifications(org.finra.herd.model.api.xml.EmrClusterDefinitionLaunchSpecifications) Test(org.junit.Test)

Example 2 with RunJobFlowRequest

use of com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest 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()));
}
Also used : MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) InstanceDefinition(org.finra.herd.model.api.xml.InstanceDefinition) AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) RunJobFlowRequest(com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest) InvocationOnMock(org.mockito.invocation.InvocationOnMock) NodeTag(org.finra.herd.model.api.xml.NodeTag) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) InstanceDefinitions(org.finra.herd.model.api.xml.InstanceDefinitions) Test(org.junit.Test)

Example 3 with RunJobFlowRequest

use of com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest in project herd by FINRAOS.

the class EmrDaoTest method createEmrClusterAssertEncryptionDisabled.

@Test
public void createEmrClusterAssertEncryptionDisabled() 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.setEncryptionEnabled(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);
            // No bootstrap action should be added
            assertEquals(0, runJobFlowRequest.getBootstrapActions().size());
            return clusterId;
        }
    });
    assertEquals(clusterId, emrDao.createEmrCluster(clusterName, emrClusterDefinition, new AwsParamsDto()));
}
Also used : MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) InstanceDefinition(org.finra.herd.model.api.xml.InstanceDefinition) AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) RunJobFlowRequest(com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest) InvocationOnMock(org.mockito.invocation.InvocationOnMock) NodeTag(org.finra.herd.model.api.xml.NodeTag) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) InstanceDefinitions(org.finra.herd.model.api.xml.InstanceDefinitions) Test(org.junit.Test)

Example 4 with RunJobFlowRequest

use of com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest in project herd by FINRAOS.

the class EmrDaoTest method createEmrClusterAssertCallRunEmrJobFlowRequiredParamsOnly.

@Test
public void createEmrClusterAssertCallRunEmrJobFlowRequiredParamsOnly() throws Exception {
    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")));
    String clusterId = "clusterId";
    when(mockEmrOperations.runEmrJobFlow(any(), any())).then(new Answer<String>() {

        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
            /*
                 * Assert that the given EMR cluster definition produced the correct RunJobFlowRequest
                 */
            RunJobFlowRequest runJobFlowRequest = invocation.getArgument(1);
            JobFlowInstancesConfig jobFlowInstancesConfig = runJobFlowRequest.getInstances();
            List<InstanceGroupConfig> instanceGroupConfigs = jobFlowInstancesConfig.getInstanceGroups();
            assertEquals(2, instanceGroupConfigs.size());
            {
                InstanceGroupConfig instanceGroupConfig = instanceGroupConfigs.get(0);
                assertEquals(10, instanceGroupConfig.getInstanceCount().intValue());
                assertEquals("masterInstanceType", instanceGroupConfig.getInstanceType());
            }
            {
                InstanceGroupConfig instanceGroupConfig = instanceGroupConfigs.get(1);
                assertEquals(20, instanceGroupConfig.getInstanceCount().intValue());
                assertEquals("coreInstanceType", instanceGroupConfig.getInstanceType());
            }
            assertEquals(herdStringHelper.getRequiredConfigurationValue(ConfigurationValue.EMR_DEFAULT_EC2_NODE_IAM_PROFILE_NAME), runJobFlowRequest.getJobFlowRole());
            assertEquals(herdStringHelper.getRequiredConfigurationValue(ConfigurationValue.EMR_DEFAULT_SERVICE_IAM_ROLE_NAME), runJobFlowRequest.getServiceRole());
            List<StepConfig> stepConfigs = runJobFlowRequest.getSteps();
            assertEquals(0, stepConfigs.size());
            List<Tag> tags = runJobFlowRequest.getTags();
            assertEquals(1, tags.size());
            {
                Tag tag = tags.get(0);
                assertEquals("tagName", tag.getKey());
                assertEquals("tagValue", tag.getValue());
            }
            return clusterId;
        }
    });
    assertEquals(clusterId, emrDao.createEmrCluster(clusterName, emrClusterDefinition, new AwsParamsDto()));
}
Also used : MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) InstanceDefinition(org.finra.herd.model.api.xml.InstanceDefinition) AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) RunJobFlowRequest(com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest) JobFlowInstancesConfig(com.amazonaws.services.elasticmapreduce.model.JobFlowInstancesConfig) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) InstanceDefinitions(org.finra.herd.model.api.xml.InstanceDefinitions) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) InvocationOnMock(org.mockito.invocation.InvocationOnMock) NodeTag(org.finra.herd.model.api.xml.NodeTag) List(java.util.List) ArrayList(java.util.ArrayList) Tag(com.amazonaws.services.elasticmapreduce.model.Tag) NodeTag(org.finra.herd.model.api.xml.NodeTag) InstanceGroupConfig(com.amazonaws.services.elasticmapreduce.model.InstanceGroupConfig) Test(org.junit.Test)

Example 5 with RunJobFlowRequest

use of com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest in project herd by FINRAOS.

the class EmrDaoTest method createEmrClusterAssertCallRunEmrJobFlowOptionalParams.

@Test
public void createEmrClusterAssertCallRunEmrJobFlowOptionalParams() throws Exception {
    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, BigDecimal.ONE, NO_INSTANCE_MAX_SEARCH_PRICE, NO_INSTANCE_ON_DEMAND_THRESHOLD));
    instanceDefinitions.setTaskInstances(new InstanceDefinition(30, "taskInstanceType", 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"), new NodeTag("", "tagValue"), new NodeTag("tagName", "")));
    emrClusterDefinition.setSshKeyPairName("sshKeyPairName");
    emrClusterDefinition.setSubnetId("subnetId");
    emrClusterDefinition.setKeepAlive(true);
    emrClusterDefinition.setTerminationProtection(true);
    emrClusterDefinition.setHadoopVersion("hadoopVersion");
    emrClusterDefinition.setReleaseLabel("releaseLabel");
    emrClusterDefinition.setApplications(new ArrayList<>());
    {
        EmrClusterDefinitionApplication emrClusterDefinitionApplication = new EmrClusterDefinitionApplication();
        emrClusterDefinitionApplication.setName("applicationName1");
        emrClusterDefinitionApplication.setVersion("applicationVersion1");
        emrClusterDefinitionApplication.setArgs(Arrays.asList("applicationArg1"));
        emrClusterDefinition.getApplications().add(emrClusterDefinitionApplication);
    }
    {
        EmrClusterDefinitionApplication emrClusterDefinitionApplication = new EmrClusterDefinitionApplication();
        emrClusterDefinitionApplication.setName("applicationName2");
        emrClusterDefinitionApplication.setVersion("applicationVersion2");
        emrClusterDefinitionApplication.setArgs(Arrays.asList("applicationArg2"));
        emrClusterDefinitionApplication.setAdditionalInfoList(Arrays.asList(new Parameter("applicationAdditionalInfoName2", "applicationAdditionalInfoValue2")));
        emrClusterDefinition.getApplications().add(emrClusterDefinitionApplication);
    }
    emrClusterDefinition.setConfigurations(new ArrayList<>());
    {
        EmrClusterDefinitionConfiguration emrClusterDefinitionConfiguration = new EmrClusterDefinitionConfiguration();
        emrClusterDefinitionConfiguration.setClassification("classification");
        EmrClusterDefinitionConfiguration emrClusterDefinitionConfigurationInner = new EmrClusterDefinitionConfiguration();
        emrClusterDefinitionConfigurationInner.setClassification("classificationInner");
        emrClusterDefinitionConfiguration.setConfigurations(Arrays.asList(emrClusterDefinitionConfigurationInner));
        emrClusterDefinitionConfiguration.setProperties(Arrays.asList(new Parameter("propertyKey", "propertyValue")));
        emrClusterDefinition.getConfigurations().add(emrClusterDefinitionConfiguration);
    }
    emrClusterDefinition.setLogBucket("logBucket");
    emrClusterDefinition.setVisibleToAll(true);
    emrClusterDefinition.setEc2NodeIamProfileName("ec2NodeIamProfileName");
    emrClusterDefinition.setServiceIamRole("serviceIamRole");
    emrClusterDefinition.setAmiVersion("amiVersion");
    emrClusterDefinition.setAdditionalInfo("additionalInfo");
    emrClusterDefinition.setEncryptionEnabled(true);
    emrClusterDefinition.setDaemonConfigurations(Arrays.asList(new Parameter("daemonConfigurationsKey", "daemonConfigurationsValue")));
    ConfigurationFiles configurationFiles = new ConfigurationFiles();
    configurationFiles.getConfigurationFiles().add(new ConfigurationFile("fileNameShortcut", "configFileLocation"));
    KeyValuePairConfigurations keyValuePairConfigurations = new KeyValuePairConfigurations();
    keyValuePairConfigurations.getKeyValuePairConfigurations().add(new KeyValuePairConfiguration("keyValueShortcut", "attribKey", "attribVal"));
    emrClusterDefinition.setHadoopConfigurations(Arrays.asList(configurationFiles, keyValuePairConfigurations));
    emrClusterDefinition.setCustomBootstrapActionAll(new ArrayList<>());
    {
        ScriptDefinition scriptDefinitionAll = new ScriptDefinition();
        scriptDefinitionAll.setScriptName("scriptDefinitionAllName1");
        scriptDefinitionAll.setScriptLocation("scriptDefinitionAllLocation1");
        scriptDefinitionAll.setScriptArguments(Arrays.asList("scriptDefinitionAllArg1"));
        emrClusterDefinition.getCustomBootstrapActionAll().add(scriptDefinitionAll);
    }
    {
        ScriptDefinition scriptDefinitionAll = new ScriptDefinition();
        scriptDefinitionAll.setScriptName("scriptDefinitionAllName2");
        scriptDefinitionAll.setScriptLocation("scriptDefinitionAllLocation2");
        emrClusterDefinition.getCustomBootstrapActionAll().add(scriptDefinitionAll);
    }
    emrClusterDefinition.setCustomBootstrapActionMaster(new ArrayList<>());
    {
        ScriptDefinition scriptDefinitionMaster = new ScriptDefinition();
        scriptDefinitionMaster.setScriptName("scriptDefinitionMasterName1");
        scriptDefinitionMaster.setScriptLocation("scriptDefinitionMasterLocation1");
        scriptDefinitionMaster.setScriptArguments(Arrays.asList("scriptDefinitionMasterArg1"));
        emrClusterDefinition.getCustomBootstrapActionMaster().add(scriptDefinitionMaster);
    }
    {
        ScriptDefinition scriptDefinitionMaster = new ScriptDefinition();
        scriptDefinitionMaster.setScriptName("scriptDefinitionMasterName2");
        scriptDefinitionMaster.setScriptLocation("scriptDefinitionMasterLocation2");
        emrClusterDefinition.getCustomBootstrapActionMaster().add(scriptDefinitionMaster);
    }
    emrClusterDefinition.setHiveVersion("hiveVersion");
    emrClusterDefinition.setPigVersion("pigVersion");
    emrClusterDefinition.setInstallOozie(true);
    emrClusterDefinition.setHadoopJarSteps(Arrays.asList(new HadoopJarStep("stepName", "jarLocation", "mainClass", null, true)));
    emrClusterDefinition.setSupportedProduct("supportedProduct");
    emrClusterDefinition.setSecurityConfiguration("securityConfiguration");
    emrClusterDefinition.setScaleDownBehavior("scaleDownBehavior");
    emrClusterDefinition.setMasterSecurityGroup(EMR_MASTER_SECURITY_GROUP);
    emrClusterDefinition.setSlaveSecurityGroup(EMR_SLAVE_SECURITY_GROUP);
    String clusterId = "clusterId";
    when(mockEmrOperations.runEmrJobFlow(any(), any())).then(new Answer<String>() {

        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
            /*
                 * Assert that the given EMR cluster definition produced the correct RunJobFlowRequest
                 */
            RunJobFlowRequest runJobFlowRequest = invocation.getArgument(1);
            assertEquals(3, runJobFlowRequest.getInstances().getInstanceGroups().size());
            {
                InstanceGroupConfig instanceGroupConfig = runJobFlowRequest.getInstances().getInstanceGroups().get(1);
                assertEquals("1", instanceGroupConfig.getBidPrice());
            }
            {
                InstanceGroupConfig instanceGroupConfig = runJobFlowRequest.getInstances().getInstanceGroups().get(2);
                assertEquals("taskInstanceType", instanceGroupConfig.getInstanceType());
                assertEquals(30, instanceGroupConfig.getInstanceCount().intValue());
            }
            assertEquals("sshKeyPairName", runJobFlowRequest.getInstances().getEc2KeyName());
            assertEquals("subnetId", runJobFlowRequest.getInstances().getEc2SubnetId());
            assertEquals(true, runJobFlowRequest.getInstances().getKeepJobFlowAliveWhenNoSteps());
            assertEquals(true, runJobFlowRequest.getInstances().getTerminationProtected());
            assertEquals("hadoopVersion", runJobFlowRequest.getInstances().getHadoopVersion());
            assertEquals("releaseLabel", runJobFlowRequest.getReleaseLabel());
            assertEquals(2, runJobFlowRequest.getApplications().size());
            {
                Application application = runJobFlowRequest.getApplications().get(0);
                assertEquals("applicationName1", application.getName());
                assertEquals("applicationVersion1", application.getVersion());
                assertEquals(Arrays.asList("applicationArg1"), application.getArgs());
            }
            {
                Application application = runJobFlowRequest.getApplications().get(1);
                Map<String, String> additionalInfo = application.getAdditionalInfo();
                assertEquals(1, additionalInfo.size());
                assertEquals("applicationAdditionalInfoValue2", additionalInfo.get("applicationAdditionalInfoName2"));
            }
            assertEquals(1, runJobFlowRequest.getConfigurations().size());
            {
                Configuration configuration = runJobFlowRequest.getConfigurations().get(0);
                assertEquals("classification", configuration.getClassification());
                assertEquals(1, configuration.getConfigurations().size());
                {
                    Configuration configurationInner = configuration.getConfigurations().get(0);
                    assertEquals("classificationInner", configurationInner.getClassification());
                }
                assertEquals(1, configuration.getProperties().size());
                assertEquals("propertyValue", configuration.getProperties().get("propertyKey"));
            }
            assertEquals("logBucket", runJobFlowRequest.getLogUri());
            assertEquals(true, runJobFlowRequest.getVisibleToAllUsers());
            assertEquals("ec2NodeIamProfileName", runJobFlowRequest.getJobFlowRole());
            assertEquals("serviceIamRole", runJobFlowRequest.getServiceRole());
            assertEquals("amiVersion", runJobFlowRequest.getAmiVersion());
            assertEquals("additionalInfo", runJobFlowRequest.getAdditionalInfo());
            assertEquals(7, runJobFlowRequest.getBootstrapActions().size());
            {
                BootstrapActionConfig bootstrapActionConfig = runJobFlowRequest.getBootstrapActions().get(0);
                assertEquals("emr.encryption.script", bootstrapActionConfig.getName());
                ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionConfig.getScriptBootstrapAction();
                assertEquals("s3:////herd_SCRIPTS/encrypt_disks.sh", scriptBootstrapAction.getPath());
                assertEquals(0, scriptBootstrapAction.getArgs().size());
            }
            {
                BootstrapActionConfig bootstrapActionConfig = runJobFlowRequest.getBootstrapActions().get(1);
                assertEquals("emr.aws.configure.daemon", bootstrapActionConfig.getName());
                ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionConfig.getScriptBootstrapAction();
                assertEquals("s3://elasticmapreduce/bootstrap-actions/configure-daemons", scriptBootstrapAction.getPath());
                assertEquals(Arrays.asList("daemonConfigurationsKey=daemonConfigurationsValue"), scriptBootstrapAction.getArgs());
            }
            {
                BootstrapActionConfig bootstrapActionConfig = runJobFlowRequest.getBootstrapActions().get(2);
                assertEquals("emr.aws.configure.hadoop", bootstrapActionConfig.getName());
                ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionConfig.getScriptBootstrapAction();
                assertEquals("s3://us-east-1.elasticmapreduce/bootstrap-actions/configure-hadoop", scriptBootstrapAction.getPath());
                assertEquals(Arrays.asList("fileNameShortcut", "configFileLocation", "keyValueShortcut", "attribKey=attribVal"), scriptBootstrapAction.getArgs());
            }
            {
                BootstrapActionConfig bootstrapActionConfig = runJobFlowRequest.getBootstrapActions().get(3);
                assertEquals("scriptDefinitionAllName1", bootstrapActionConfig.getName());
                ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionConfig.getScriptBootstrapAction();
                assertEquals("scriptDefinitionAllLocation1", scriptBootstrapAction.getPath());
                assertEquals(Arrays.asList("scriptDefinitionAllArg1"), scriptBootstrapAction.getArgs());
            }
            {
                BootstrapActionConfig bootstrapActionConfig = runJobFlowRequest.getBootstrapActions().get(4);
                ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionConfig.getScriptBootstrapAction();
                assertEquals(0, scriptBootstrapAction.getArgs().size());
            }
            {
                BootstrapActionConfig bootstrapActionConfig = runJobFlowRequest.getBootstrapActions().get(5);
                assertEquals("scriptDefinitionMasterName1", bootstrapActionConfig.getName());
                ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionConfig.getScriptBootstrapAction();
                assertEquals("s3://elasticmapreduce/bootstrap-actions/run-if", scriptBootstrapAction.getPath());
                assertEquals(Arrays.asList("instance.isMaster=true", "scriptDefinitionMasterLocation1", "scriptDefinitionMasterArg1"), scriptBootstrapAction.getArgs());
            }
            {
                BootstrapActionConfig bootstrapActionConfig = runJobFlowRequest.getBootstrapActions().get(6);
                ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionConfig.getScriptBootstrapAction();
                assertEquals(Arrays.asList("instance.isMaster=true", "scriptDefinitionMasterLocation2"), scriptBootstrapAction.getArgs());
            }
            assertEquals(Arrays.asList("supportedProduct"), runJobFlowRequest.getSupportedProducts());
            assertEquals("securityConfiguration", runJobFlowRequest.getSecurityConfiguration());
            assertEquals("scaleDownBehavior", runJobFlowRequest.getScaleDownBehavior());
            assertEquals(EMR_MASTER_SECURITY_GROUP, runJobFlowRequest.getInstances().getEmrManagedMasterSecurityGroup());
            assertEquals(EMR_SLAVE_SECURITY_GROUP, runJobFlowRequest.getInstances().getEmrManagedSlaveSecurityGroup());
            return clusterId;
        }
    });
    assertEquals(clusterId, emrDao.createEmrCluster(clusterName, emrClusterDefinition, new AwsParamsDto()));
}
Also used : MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) InstanceDefinition(org.finra.herd.model.api.xml.InstanceDefinition) AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) ScriptDefinition(org.finra.herd.model.api.xml.ScriptDefinition) EmrClusterDefinitionConfiguration(org.finra.herd.model.api.xml.EmrClusterDefinitionConfiguration) Configuration(com.amazonaws.services.elasticmapreduce.model.Configuration) KeyValuePairConfiguration(org.finra.herd.model.api.xml.KeyValuePairConfiguration) ClientConfiguration(com.amazonaws.ClientConfiguration) KeyValuePairConfigurations(org.finra.herd.model.api.xml.KeyValuePairConfigurations) HadoopJarStep(org.finra.herd.model.api.xml.HadoopJarStep) EmrClusterDefinition(org.finra.herd.model.api.xml.EmrClusterDefinition) KeyValuePairConfiguration(org.finra.herd.model.api.xml.KeyValuePairConfiguration) ScriptBootstrapActionConfig(com.amazonaws.services.elasticmapreduce.model.ScriptBootstrapActionConfig) NodeTag(org.finra.herd.model.api.xml.NodeTag) EmrClusterDefinitionConfiguration(org.finra.herd.model.api.xml.EmrClusterDefinitionConfiguration) EmrClusterDefinitionApplication(org.finra.herd.model.api.xml.EmrClusterDefinitionApplication) InstanceGroupConfig(com.amazonaws.services.elasticmapreduce.model.InstanceGroupConfig) RunJobFlowRequest(com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest) MasterInstanceDefinition(org.finra.herd.model.api.xml.MasterInstanceDefinition) ConfigurationFiles(org.finra.herd.model.api.xml.ConfigurationFiles) InstanceDefinitions(org.finra.herd.model.api.xml.InstanceDefinitions) BootstrapActionConfig(com.amazonaws.services.elasticmapreduce.model.BootstrapActionConfig) ScriptBootstrapActionConfig(com.amazonaws.services.elasticmapreduce.model.ScriptBootstrapActionConfig) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Parameter(org.finra.herd.model.api.xml.Parameter) ConfigurationFile(org.finra.herd.model.api.xml.ConfigurationFile) Application(com.amazonaws.services.elasticmapreduce.model.Application) EmrClusterDefinitionApplication(org.finra.herd.model.api.xml.EmrClusterDefinitionApplication) Test(org.junit.Test)

Aggregations

RunJobFlowRequest (com.amazonaws.services.elasticmapreduce.model.RunJobFlowRequest)7 EmrClusterDefinition (org.finra.herd.model.api.xml.EmrClusterDefinition)5 NodeTag (org.finra.herd.model.api.xml.NodeTag)5 AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)5 Test (org.junit.Test)5 InvocationOnMock (org.mockito.invocation.InvocationOnMock)5 InstanceDefinition (org.finra.herd.model.api.xml.InstanceDefinition)4 InstanceDefinitions (org.finra.herd.model.api.xml.InstanceDefinitions)4 MasterInstanceDefinition (org.finra.herd.model.api.xml.MasterInstanceDefinition)4 ArrayList (java.util.ArrayList)3 InstanceGroupConfig (com.amazonaws.services.elasticmapreduce.model.InstanceGroupConfig)2 JobFlowInstancesConfig (com.amazonaws.services.elasticmapreduce.model.JobFlowInstancesConfig)2 Tag (com.amazonaws.services.elasticmapreduce.model.Tag)2 List (java.util.List)2 EmrClusterDefinitionApplication (org.finra.herd.model.api.xml.EmrClusterDefinitionApplication)2 EmrClusterDefinitionConfiguration (org.finra.herd.model.api.xml.EmrClusterDefinitionConfiguration)2 ClientConfiguration (com.amazonaws.ClientConfiguration)1 Application (com.amazonaws.services.elasticmapreduce.model.Application)1 BootstrapActionConfig (com.amazonaws.services.elasticmapreduce.model.BootstrapActionConfig)1 Configuration (com.amazonaws.services.elasticmapreduce.model.Configuration)1