use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.
the class AddEmrStepsTest method testAddHadoopJarStep.
@Test
public void testAddHadoopJarStep() throws Exception {
List<FieldExtension> fieldExtensionList = new ArrayList<>();
FieldExtension exceptionField = new FieldExtension();
exceptionField.setFieldName("jarLocation");
exceptionField.setExpression("${jarLocation}");
fieldExtensionList.add(exceptionField);
exceptionField = new FieldExtension();
exceptionField.setFieldName("mainClass");
exceptionField.setExpression("${mainClass}");
fieldExtensionList.add(exceptionField);
exceptionField = new FieldExtension();
exceptionField.setFieldName("scriptArguments");
exceptionField.setExpression("${scriptArguments}");
fieldExtensionList.add(exceptionField);
List<Parameter> parameters = new ArrayList<>(getCommonParameters("Hadoop jar Step"));
Parameter parameter = new Parameter("jarLocation", "s3://test-bucket-managed/app-a/test/hadoop-mapreduce-examples-2.4.0.jar");
parameters.add(parameter);
parameter = new Parameter("mainClass", "wordcount");
parameters.add(parameter);
parameter = new Parameter("scriptArguments", "arg1|arg/|withpipe|arg2|arg3");
parameters.add(parameter);
testActivitiAddEmrStepSuccess(AddEmrHadoopJarStep.class.getCanonicalName(), fieldExtensionList, parameters);
}
use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.
the class ActivitiDelegateTest method testActivitiReportableError.
/**
* This method tests the scenario when an error that is not workflow related is throws while workflow is executing an Async type task like Timer. This error
* is logged as ERROR.
*/
@Test(expected = ActivitiException.class)
public void testActivitiReportableError() throws Exception {
BpmnModel bpmnModel = getBpmnModelForXmlResource(ACTIVITI_XML_HERD_TIMER_WITH_CLASSPATH);
ServiceTask serviceTask = (ServiceTask) bpmnModel.getProcesses().get(0).getFlowElement("servicetask1");
FieldExtension exceptionField = new FieldExtension();
exceptionField.setFieldName("exceptionToThrow");
exceptionField.setExpression("${exceptionToThrow}");
serviceTask.getFieldExtensions().add(exceptionField);
jobDefinitionServiceTestHelper.createJobDefinitionForActivitiXml(getActivitiXmlFromBpmnModel(bpmnModel));
List<Parameter> parameters = new ArrayList<>();
Parameter parameter = new Parameter("exceptionToThrow", MockJavaDelegate.EXCEPTION_BPMN_ERROR);
parameters.add(parameter);
Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME, parameters));
org.activiti.engine.runtime.Job timer = activitiManagementService.createJobQuery().processInstanceId(job.getId()).timers().singleResult();
if (timer != null) {
executeWithoutLogging(Arrays.asList(ActivitiRuntimeHelper.class, TimerExecuteNestedActivityJobHandler.class), () -> {
activitiManagementService.executeJob(timer.getId());
});
}
}
use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.
the class AddEmrMasterSecurityGroupTest method testAddEmrMasterSecurityGroup.
@Test
public void testAddEmrMasterSecurityGroup() throws Exception {
// Create a pipe-separated list of security group IDs.
final String securityGroupIds = EC2_SECURITY_GROUP_1 + "|" + EC2_SECURITY_GROUP_2;
// Create EC2 on-demand pricing entities required for testing.
ec2OnDemandPricingDaoTestHelper.createEc2OnDemandPricingEntities();
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
// Create a trusting AWS account.
trustingAccountDaoTestHelper.createTrustingAccountEntity(AWS_ACCOUNT_ID, AWS_ROLE_ARN);
// Create an EMR cluster definition.
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
// Create an EMR cluster definition override with an AWS account ID.
EmrClusterDefinition emrClusterDefinitionOverride = new EmrClusterDefinition();
emrClusterDefinitionOverride.setAccountId(AWS_ACCOUNT_ID);
// Create an EMR cluster.
emrService.createCluster(new EmrClusterCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, EMR_CLUSTER_NAME, NO_DRY_RUN, emrClusterDefinitionOverride));
List<FieldExtension> fieldExtensionList = new ArrayList<>();
fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
fieldExtensionList.add(buildFieldExtension("emrClusterDefinitionName", "${emrClusterDefinitionName}"));
fieldExtensionList.add(buildFieldExtension("emrClusterName", "${emrClusterName}"));
fieldExtensionList.add(buildFieldExtension("securityGroupIds", "${securityGroupIds}"));
fieldExtensionList.add(buildFieldExtension("accountId", "${accountId}"));
List<Parameter> parameters = new ArrayList<>();
parameters.add(buildParameter("namespace", NAMESPACE));
parameters.add(buildParameter("emrClusterDefinitionName", EMR_CLUSTER_DEFINITION_NAME));
parameters.add(buildParameter("emrClusterName", EMR_CLUSTER_NAME));
parameters.add(buildParameter("securityGroupIds", securityGroupIds));
parameters.add(buildParameter("accountId", AWS_ACCOUNT_ID));
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(AddEmrMasterSecurityGroup.VARIABLE_EMR_MASTER_SECURITY_GROUPS, securityGroupIds);
testActivitiServiceTaskSuccess(AddEmrMasterSecurityGroup.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.
the class SystemJobServiceTest method testRunSystemJobBusinessObjectDataFinalizeRestoreInvalidParameters.
@Test
public void testRunSystemJobBusinessObjectDataFinalizeRestoreInvalidParameters() throws Exception {
// Try to run a system job when too many parameters are specified.
try {
systemJobService.runSystemJob(new SystemJobRunRequest(BusinessObjectDataFinalizeRestoreJob.JOB_NAME, Arrays.asList(new Parameter(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1), new Parameter(ATTRIBUTE_NAME_2_MIXED_CASE, ATTRIBUTE_VALUE_2))));
fail("Should throw an IllegalArgumentException when too many parameters are specified.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Too many parameters are specified for \"%s\" system job.", BusinessObjectDataFinalizeRestoreJob.JOB_NAME), e.getMessage());
}
// Try to run a system job when invalid parameter name is specified.
try {
systemJobService.runSystemJob(new SystemJobRunRequest(BusinessObjectDataFinalizeRestoreJob.JOB_NAME, Arrays.asList(new Parameter(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1))));
fail("Should throw an IllegalArgumentException when invalid parameter name is specified.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Parameter \"%s\" is not supported by \"%s\" system job.", ATTRIBUTE_NAME_1_MIXED_CASE, BusinessObjectDataFinalizeRestoreJob.JOB_NAME), e.getMessage());
}
// Try to run a system job when invalid parameter value is specified.
try {
systemJobService.runSystemJob(new SystemJobRunRequest(BusinessObjectDataFinalizeRestoreJob.JOB_NAME, Arrays.asList(new Parameter(ConfigurationValue.BDATA_FINALIZE_RESTORE_JOB_MAX_BDATA_INSTANCES.getKey(), "NOT_AN_INTEGER"))));
fail("Should throw an IllegalArgumentException when invalid parameter value is specified.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Parameter \"%s\" specifies a non-integer value \"NOT_AN_INTEGER\".", ConfigurationValue.BDATA_FINALIZE_RESTORE_JOB_MAX_BDATA_INSTANCES.getKey()), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.Parameter in project herd by FINRAOS.
the class SystemJobServiceTest method testRunSystemJobFileUploadCleanup.
// File upload cleanup system job
@Test
public void testRunSystemJobFileUploadCleanup() throws Exception {
// Create the system job run request.
SystemJobRunRequest systemJobRunRequest = new SystemJobRunRequest(FileUploadCleanupJob.JOB_NAME, Arrays.asList(new Parameter(ConfigurationValue.FILE_UPLOAD_CLEANUP_JOB_THRESHOLD_MINUTES.getKey(), String.valueOf(INTEGER_VALUE))));
// Request to run the system job.
SystemJobRunResponse resultSystemJobRunResponse = systemJobService.runSystemJob(systemJobRunRequest);
// Validate the returned object.
assertEquals(new SystemJobRunResponse(FileUploadCleanupJob.JOB_NAME, Arrays.asList(new Parameter(ConfigurationValue.FILE_UPLOAD_CLEANUP_JOB_THRESHOLD_MINUTES.getKey(), String.valueOf(INTEGER_VALUE)))), resultSystemJobRunResponse);
}
Aggregations