use of com.google.cloud.talent.v4beta1.Job in project pravega by pravega.
the class RemoteSequential method newJob.
private Job newJob(String id, String className, String methodName) {
Map<String, String> labels = new HashMap<>(1);
labels.put("testMethodName", methodName);
// This can be used to set environment variables while executing the job on Metronome.
Map<String, String> env = new HashMap<>(2);
env.put("masterIP", System.getProperty("masterIP"));
env.put("env2", "value102");
Artifact art = new Artifact();
// It caches the artifacts, disabling it for now.
art.setCache(false);
// jar is not executable.
art.setExecutable(false);
art.setExtract(false);
art.setUri(System.getProperty("testArtifactUrl", "InvalidTestArtifactURL"));
Restart restart = new Restart();
// the tests are expected to finish in 2 mins, this can be changed to
restart.setActiveDeadlineSeconds(120);
// a higher value if required.
restart.setPolicy("NEVER");
Run run = new Run();
run.setArtifacts(Collections.singletonList(art));
run.setCmd("docker run --rm -v $(pwd):/data " + System.getProperty("dockerImageRegistry") + "/java:8 java" + " -DmasterIP=" + LoginClient.MESOS_MASTER + " -DskipServiceInstallation=" + Utils.isSkipServiceInstallationEnabled() + " -cp /data/pravega-test-system-" + System.getProperty("testVersion") + ".jar io.pravega.test.system.SingleJUnitTestRunner " + className + "#" + methodName + " > server.log 2>&1" + "; exit $?");
// CPU shares.
run.setCpus(0.5);
// amount of memory required for running test in MB.
run.setMem(512.0);
run.setDisk(50.0);
run.setEnv(env);
run.setMaxLaunchDelay(3600);
run.setRestart(restart);
run.setUser("root");
Job job = new Job();
job.setId(id);
job.setDescription(id);
job.setLabels(labels);
job.setRun(run);
return job;
}
use of com.google.cloud.talent.v4beta1.Job in project pentaho-platform by pentaho.
the class SolutionImportHandlerIT method testImportSchedules.
@Test
public void testImportSchedules() throws PlatformImportException, SchedulerException {
SolutionImportHandler importHandler = new SolutionImportHandler(Collections.emptyList());
importHandler = spy(importHandler);
List<JobScheduleRequest> requests = new ArrayList<>(4);
requests.add(createJobScheduleRequest("NORMAL", JobState.NORMAL));
requests.add(createJobScheduleRequest("PAUSED", JobState.PAUSED));
requests.add(createJobScheduleRequest("PAUSED", JobState.COMPLETE));
requests.add(createJobScheduleRequest("PAUSED", JobState.ERROR));
doReturn(new ArrayList<Job>()).when(importHandler).getAllJobs(any());
importHandler.importSchedules(requests);
List<Job> jobs = scheduler.getJobs(job -> true);
assertEquals(4, jobs.size());
for (Job job : jobs) {
assertEquals(job.getJobName(), job.getState().toString());
}
}
use of com.google.cloud.talent.v4beta1.Job in project pentaho-platform by pentaho.
the class PentahoPlatformExporter method exportSchedules.
protected void exportSchedules() {
log.debug("export schedules");
try {
List<Job> jobs = getScheduler().getJobs(null);
for (Job job : jobs) {
if (job.getJobName().equals(EmbeddedVersionCheckSystemListener.VERSION_CHECK_JOBNAME)) {
// if it doesn't exist and fails if you try to import it due to a null ActionClass
continue;
}
try {
JobScheduleRequest scheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
getExportManifest().addSchedule(scheduleRequest);
} catch (IllegalArgumentException e) {
log.warn(e.getMessage(), e);
}
}
} catch (SchedulerException e) {
log.error(Messages.getInstance().getString("PentahoPlatformExporter.ERROR_EXPORTING_JOBS"), e);
}
}
use of com.google.cloud.talent.v4beta1.Job in project pentaho-platform by pentaho.
the class ScheduleExportUtilTest method testCreateJobScheduleRequest_MultipleTypesJobParam.
@Test
public void testCreateJobScheduleRequest_MultipleTypesJobParam() throws Exception {
String jobName = "JOB";
Long l = Long.MAX_VALUE;
Date d = new Date();
Boolean b = true;
Map<String, Serializable> params = new HashMap<>();
params.put("NumberValue", l);
params.put("DateValue", d);
params.put("BooleanValue", b);
Job job = mock(Job.class);
CronJobTrigger trigger = mock(CronJobTrigger.class);
when(job.getJobTrigger()).thenReturn(trigger);
when(job.getJobName()).thenReturn(jobName);
when(job.getJobParams()).thenReturn(params);
JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
for (JobScheduleParam jobScheduleParam : jobScheduleRequest.getJobParameters()) {
assertTrue(jobScheduleParam.getValue().equals(l) || jobScheduleParam.getValue().equals(d) || jobScheduleParam.getValue().equals(b));
}
}
use of com.google.cloud.talent.v4beta1.Job in project pentaho-platform by pentaho.
the class ScheduleExportUtilTest method testCreateJobScheduleRequest_StringStreamProvider.
@Test
public void testCreateJobScheduleRequest_StringStreamProvider() throws Exception {
String jobName = "JOB";
Job job = mock(Job.class);
SimpleJobTrigger trigger = mock(SimpleJobTrigger.class);
when(job.getJobTrigger()).thenReturn(trigger);
when(job.getJobName()).thenReturn(jobName);
Map<String, Serializable> params = new HashMap<>();
params.put(QuartzScheduler.RESERVEDMAPKEY_STREAMPROVIDER, "import file = /home/admin/myJob.kjb:output file=/home/admin/myJob*");
when(job.getJobParams()).thenReturn(params);
JobScheduleRequest jobScheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
assertNotNull(jobScheduleRequest);
assertEquals(jobName, jobScheduleRequest.getJobName());
assertEquals(trigger, jobScheduleRequest.getSimpleJobTrigger());
assertEquals("/home/admin/myJob.kjb", jobScheduleRequest.getInputFile());
assertEquals("/home/admin/myJob*", jobScheduleRequest.getOutputFile());
}
Aggregations