use of com.google.cloud.talent.v4.Job in project jkube by eclipse.
the class JobHandlerTest method jobHandlerTest.
@Test
public void jobHandlerTest() {
ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("testing").serviceAccount("test-account").restartPolicy("OnFailure").volumes(volumes1).build();
Job job = jobHandler.get(config, images);
// Assertion
assertNotNull(job.getSpec());
assertNotNull(job.getMetadata());
assertNotNull(job.getSpec().getTemplate());
assertEquals("testing", job.getMetadata().getName());
assertEquals("test-account", job.getSpec().getTemplate().getSpec().getServiceAccountName());
assertFalse(job.getSpec().getTemplate().getSpec().getVolumes().isEmpty());
assertEquals("OnFailure", job.getSpec().getTemplate().getSpec().getRestartPolicy());
assertEquals("test", job.getSpec().getTemplate().getSpec().getVolumes().get(0).getName());
assertEquals("/test/path", job.getSpec().getTemplate().getSpec().getVolumes().get(0).getHostPath().getPath());
assertNotNull(job.getSpec().getTemplate().getSpec().getContainers());
}
use of com.google.cloud.talent.v4.Job in project quick by bakdata.
the class JobCleanerTest method shouldDeleteSucceededJobs.
@Test
void shouldDeleteSucceededJobs() {
final JobCleaner jobCleaner = new JobCleaner(this.client);
final KubernetesResources resources = new KubernetesResources();
final Job deletionJob = resources.createDeletionJob("test", "image", List.of("--key", "value"));
final Job finalJob = new JobBuilder(deletionJob).withNewStatus().withActive(0).withSucceeded(1).endStatus().build();
this.kubernetesServer.getClient().batch().v1().jobs().create(finalJob);
List<Job> jobList = this.kubernetesServer.getClient().batch().v1().jobs().list().getItems();
assertThat(jobList).hasSize(1);
assertThatNoException().isThrownBy(jobCleaner::deleteJobs);
jobList = this.kubernetesServer.getClient().batch().v1().jobs().list().getItems();
assertThat(jobList).isEmpty();
}
use of com.google.cloud.talent.v4.Job in project quick by bakdata.
the class JobCleanerTest method shouldRunWithoutErrorForJobsWithoutStatus.
@Test
void shouldRunWithoutErrorForJobsWithoutStatus() {
final JobCleaner jobCleaner = new JobCleaner(this.client);
final KubernetesResources resources = new KubernetesResources();
final Job deletionJob = resources.createDeletionJob("test", "image", List.of("--key", "value"));
this.kubernetesServer.getClient().batch().v1().jobs().create(deletionJob);
assertThatNoException().isThrownBy(jobCleaner::deleteJobs);
}
use of com.google.cloud.talent.v4.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.v4.Job in project pentaho-platform by pentaho.
the class EmbeddedVersionCheckSystemListener method deleteJobIfNecessary.
protected void deleteJobIfNecessary() throws SchedulerException {
// $NON-NLS-1$
IScheduler scheduler = PentahoSystem.get(IScheduler.class, "IScheduler2", null);
IJobFilter filter = new IJobFilter() {
public boolean accept(Job job) {
return job.getJobName().contains(EmbeddedVersionCheckSystemListener.VERSION_CHECK_JOBNAME);
}
};
// Like old code - remove the existing job and replace it
List<Job> matchingJobs = scheduler.getJobs(filter);
if ((matchingJobs != null) && (matchingJobs.size() > 0)) {
for (Job verCkJob : matchingJobs) {
scheduler.removeJob(verCkJob.getJobId());
}
}
}
Aggregations