Search in sources :

Example 26 with Job

use of com.google.cloud.scheduler.v1.Job in project jkube by eclipse.

the class KubernetesHelper method extractPodLabelSelector.

public static LabelSelector extractPodLabelSelector(HasMetadata entity) {
    LabelSelector selector = null;
    if (entity instanceof Deployment) {
        Deployment resource = (Deployment) entity;
        DeploymentSpec spec = resource.getSpec();
        if (spec != null) {
            selector = spec.getSelector();
        }
    } else if (entity instanceof ReplicaSet) {
        ReplicaSet resource = (ReplicaSet) entity;
        ReplicaSetSpec spec = resource.getSpec();
        if (spec != null) {
            selector = spec.getSelector();
        }
    } else if (entity instanceof DeploymentConfig) {
        DeploymentConfig resource = (DeploymentConfig) entity;
        DeploymentConfigSpec spec = resource.getSpec();
        if (spec != null) {
            selector = toLabelSelector(spec.getSelector());
        }
    } else if (entity instanceof ReplicationController) {
        ReplicationController resource = (ReplicationController) entity;
        ReplicationControllerSpec spec = resource.getSpec();
        if (spec != null) {
            selector = toLabelSelector(spec.getSelector());
        }
    } else if (entity instanceof DaemonSet) {
        DaemonSet resource = (DaemonSet) entity;
        DaemonSetSpec spec = resource.getSpec();
        if (spec != null) {
            selector = spec.getSelector();
        }
    } else if (entity instanceof StatefulSet) {
        StatefulSet resource = (StatefulSet) entity;
        StatefulSetSpec spec = resource.getSpec();
        if (spec != null) {
            selector = spec.getSelector();
        }
    } else if (entity instanceof Job) {
        selector = toLabelSelector((Job) entity);
    }
    return selector;
}
Also used : StatefulSetSpec(io.fabric8.kubernetes.api.model.apps.StatefulSetSpec) ReplicaSetSpec(io.fabric8.kubernetes.api.model.apps.ReplicaSetSpec) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) DaemonSetSpec(io.fabric8.kubernetes.api.model.apps.DaemonSetSpec) DeploymentSpec(io.fabric8.kubernetes.api.model.apps.DeploymentSpec) ReplicationController(io.fabric8.kubernetes.api.model.ReplicationController) DaemonSet(io.fabric8.kubernetes.api.model.apps.DaemonSet) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) DeploymentConfigSpec(io.fabric8.openshift.api.model.DeploymentConfigSpec) StatefulSet(io.fabric8.kubernetes.api.model.apps.StatefulSet) Job(io.fabric8.kubernetes.api.model.batch.v1.Job) ReplicaSet(io.fabric8.kubernetes.api.model.apps.ReplicaSet) ReplicationControllerSpec(io.fabric8.kubernetes.api.model.ReplicationControllerSpec)

Example 27 with Job

use of com.google.cloud.scheduler.v1.Job in project jkube by eclipse.

the class TriggersAnnotationEnricherTest method testNoEnrichment.

@Test
public void testNoEnrichment() {
    KubernetesListBuilder builder = new KubernetesListBuilder().addToItems(new JobBuilder().withNewMetadata().addToAnnotations("dummy", "annotation").endMetadata().withNewSpec().withNewTemplate().withNewSpec().withContainers(createContainers("c1", "is1:latest", "c2", "is2:latest")).endSpec().endTemplate().endSpec().build());
    TriggersAnnotationEnricher enricher = new TriggersAnnotationEnricher(context);
    enricher.enrich(PlatformMode.kubernetes, builder);
    Job res = (Job) builder.build().getItems().get(0);
    String triggers = res.getMetadata().getAnnotations().get("image.openshift.io/triggers");
    assertNull(triggers);
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) JobBuilder(io.fabric8.kubernetes.api.model.batch.v1.JobBuilder) Job(io.fabric8.kubernetes.api.model.batch.v1.Job) Test(org.junit.Test)

Example 28 with Job

use of com.google.cloud.scheduler.v1.Job in project jkube by eclipse.

the class JobHandlerTest method overrideReplicas.

@Test
public void overrideReplicas() {
    // Given
    final KubernetesListBuilder klb = new KubernetesListBuilder().addToItems(new Job());
    // When
    jobHandler.overrideReplicas(klb, 1337);
    // Then
    assertThat(klb.buildItems()).hasSize(1).first().isEqualTo(new Job());
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Job(io.fabric8.kubernetes.api.model.batch.v1.Job) Test(org.junit.Test)

Example 29 with Job

use of com.google.cloud.scheduler.v1.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());
}
Also used : ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Job(io.fabric8.kubernetes.api.model.batch.v1.Job) Test(org.junit.Test)

Example 30 with Job

use of com.google.cloud.scheduler.v1.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();
}
Also used : JobBuilder(io.fabric8.kubernetes.api.model.batch.v1.JobBuilder) KubernetesResources(com.bakdata.quick.manager.k8s.KubernetesResources) Job(io.fabric8.kubernetes.api.model.batch.v1.Job) Test(org.junit.jupiter.api.Test) KubernetesTest(com.bakdata.quick.manager.k8s.KubernetesTest)

Aggregations

Job (org.pentaho.platform.api.scheduler2.Job)94 Test (org.junit.Test)89 Job (io.fabric8.kubernetes.api.model.batch.v1.Job)38 Serializable (java.io.Serializable)25 ArrayList (java.util.ArrayList)24 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)21 Job (com.google.cloud.talent.v4beta1.Job)20 HashMap (java.util.HashMap)20 JobScheduleRequest (org.pentaho.platform.web.http.api.resources.JobScheduleRequest)19 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)18 SchedulerException (org.pentaho.platform.api.scheduler2.SchedulerException)17 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)16 Date (java.util.Date)14 IJobFilter (org.pentaho.platform.api.scheduler2.IJobFilter)14 Job (com.google.cloud.video.transcoder.v1.Job)13 TranscoderServiceClient (com.google.cloud.video.transcoder.v1.TranscoderServiceClient)13 JobBuilder (io.fabric8.kubernetes.api.model.batch.v1.JobBuilder)13 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)12 Map (java.util.Map)11 Test (org.junit.jupiter.api.Test)10