Search in sources :

Example 1 with JobOwner

use of io.mantisrx.runtime.JobOwner in project mantis by Netflix.

the class JobClusterConfigTest method jobClusterDefnTest.

@Test
public void jobClusterDefnTest() {
    String name = "jobClusterDefnTest";
    JobClusterConfig clusterConfig = new JobClusterConfig.Builder().withArtifactName("myart").withSchedulingInfo(DEFAULT_SCHED_INFO).withVersion("0.0.1").build();
    try {
        // null cluster config is not allowed
        final JobClusterDefinitionImpl fakeJobCluster = new JobClusterDefinitionImpl.Builder().withJobClusterConfig(null).withName(name).withUser("nj").withParameters(Lists.newArrayList()).withIsReadyForJobMaster(true).withOwner(new JobOwner("Nick", "Mantis", "desc", "nma@netflix.com", "repo")).withMigrationConfig(WorkerMigrationConfig.DEFAULT).build();
        fail();
    } catch (Exception e) {
    }
    try {
        // cluster name is not specified
        final JobClusterDefinitionImpl fakeJobCluster = new JobClusterDefinitionImpl.Builder().withJobClusterConfig(clusterConfig).withUser("nj").withIsReadyForJobMaster(true).withOwner(new JobOwner("Nick", "Mantis", "desc", "nma@netflix.com", "repo")).withMigrationConfig(WorkerMigrationConfig.DEFAULT).build();
        fail();
    } catch (Exception e) {
    }
}
Also used : JobOwner(io.mantisrx.runtime.JobOwner) Test(org.junit.Test)

Example 2 with JobOwner

use of io.mantisrx.runtime.JobOwner in project mantis by Netflix.

the class JobClusterConfigTest method noArtifactNameFails.

@Test(expected = Exception.class)
public void noArtifactNameFails() {
    String name = "noArtifactNameFails";
    JobClusterConfig clusterConfig = new JobClusterConfig.Builder().withArtifactName(null).withSchedulingInfo(DEFAULT_SCHED_INFO).withVersion("0.0.1").build();
    final JobClusterDefinitionImpl fakeJobCluster = new JobClusterDefinitionImpl.Builder().withJobClusterConfig(clusterConfig).withName(name).withUser("nj").withParameters(Lists.newArrayList()).withIsReadyForJobMaster(true).withOwner(new JobOwner("Nick", "Mantis", "desc", "nma@netflix.com", "repo")).withMigrationConfig(WorkerMigrationConfig.DEFAULT).build();
}
Also used : JobOwner(io.mantisrx.runtime.JobOwner) Test(org.junit.Test)

Example 3 with JobOwner

use of io.mantisrx.runtime.JobOwner in project mantis by Netflix.

the class DataFormatAdapterTest method jobClusterMetadataConversionTest.

@Test
public void jobClusterMetadataConversionTest() {
    String artifactName = "artifact1";
    String version = "0.0.1";
    List<Parameter> parameterList = new ArrayList<>();
    Parameter parameter = new Parameter("param1", "value1");
    parameterList.add(parameter);
    List<Label> labels = new ArrayList<>();
    Label label = new Label("label1", "labelvalue1");
    labels.add(label);
    long uAt = 1234l;
    JobClusterConfig jobClusterConfig = new JobClusterConfig.Builder().withArtifactName(artifactName).withSchedulingInfo(DEFAULT_SCHED_INFO).withVersion(version).withUploadedAt(uAt).build();
    String clusterName = "clusterName1";
    JobOwner owner = new JobOwner("Neeraj", "Mantis", "desc", "nma@netflix.com", "repo");
    boolean isReadyForMaster = true;
    SLA sla = new SLA(1, 10, null, null);
    JobClusterDefinitionImpl clusterDefn = new JobClusterDefinitionImpl.Builder().withJobClusterConfig(jobClusterConfig).withName(clusterName).withUser("user1").withIsReadyForJobMaster(isReadyForMaster).withOwner(owner).withMigrationConfig(WorkerMigrationConfig.DEFAULT).withSla(sla).withParameters(parameterList).withLabels(labels).build();
    int lastJobCnt = 10;
    boolean disabled = false;
    IJobClusterMetadata clusterMeta = new JobClusterMetadataImpl.Builder().withJobClusterDefinition(clusterDefn).withLastJobCount(lastJobCnt).withIsDisabled(disabled).build();
    NamedJob namedJob = DataFormatAdapter.convertJobClusterMetadataToNamedJob(clusterMeta);
    assertEquals(disabled, namedJob.getDisabled());
    assertEquals(clusterName, namedJob.getName());
    assertEquals(lastJobCnt, namedJob.getLastJobCount());
    assertEquals(1, namedJob.getLabels().size());
    assertEquals(label, namedJob.getLabels().get(0));
    assertEquals(owner, namedJob.getOwner());
    assertEquals(isReadyForMaster, namedJob.getIsReadyForJobMaster());
    assertEquals(WorkerMigrationConfig.DEFAULT, namedJob.getMigrationConfig());
    // assert parameters
    assertEquals(parameterList.size(), namedJob.getParameters().size());
    assertEquals(parameter, namedJob.getParameters().get(0));
    // assert sla
    assertEquals(sla.getMin(), namedJob.getSla().getMin());
    assertEquals(sla.getMax(), namedJob.getSla().getMax());
    // assert jar info
    assertEquals(1, namedJob.getJars().size());
    // jar info
    NamedJob.Jar jar = namedJob.getJars().get(0);
    assertEquals(uAt, jar.getUploadedAt());
    assertEquals(DEFAULT_SCHED_INFO, jar.getSchedulingInfo());
    assertEquals(version, jar.getVersion());
    assertEquals(artifactName, DataFormatAdapter.extractArtifactName(jar.getUrl()).orElse(""));
    IJobClusterMetadata reconvertedJobCluster = DataFormatAdapter.convertNamedJobToJobClusterMetadata(namedJob);
    assertEquals(disabled, reconvertedJobCluster.isDisabled());
    assertEquals(clusterName, reconvertedJobCluster.getJobClusterDefinition().getName());
    assertEquals(lastJobCnt, reconvertedJobCluster.getLastJobCount());
    assertEquals(1, reconvertedJobCluster.getJobClusterDefinition().getLabels().size());
    assertEquals(label, reconvertedJobCluster.getJobClusterDefinition().getLabels().get(0));
    assertEquals(owner, reconvertedJobCluster.getJobClusterDefinition().getOwner());
    assertEquals(isReadyForMaster, reconvertedJobCluster.getJobClusterDefinition().getIsReadyForJobMaster());
    assertEquals(WorkerMigrationConfig.DEFAULT, reconvertedJobCluster.getJobClusterDefinition().getWorkerMigrationConfig());
    assertEquals(parameterList.size(), reconvertedJobCluster.getJobClusterDefinition().getParameters().size());
    assertEquals(parameter, reconvertedJobCluster.getJobClusterDefinition().getParameters().get(0));
    assertEquals(sla.getMin(), reconvertedJobCluster.getJobClusterDefinition().getSLA().getMin());
    assertEquals(sla.getMax(), reconvertedJobCluster.getJobClusterDefinition().getSLA().getMax());
    JobClusterConfig clusterConfig1 = reconvertedJobCluster.getJobClusterDefinition().getJobClusterConfig();
    assertEquals(uAt, clusterConfig1.getUploadedAt());
    assertEquals(DEFAULT_SCHED_INFO, clusterConfig1.getSchedulingInfo());
    assertEquals(version, clusterConfig1.getVersion());
    assertEquals(artifactName, clusterConfig1.getArtifactName());
}
Also used : JobOwner(io.mantisrx.runtime.JobOwner) ArrayList(java.util.ArrayList) Label(io.mantisrx.common.Label) NamedJob(io.mantisrx.server.master.store.NamedJob) Parameter(io.mantisrx.runtime.parameter.Parameter) IJobClusterMetadata(io.mantisrx.master.jobcluster.IJobClusterMetadata) Test(org.junit.Test)

Example 4 with JobOwner

use of io.mantisrx.runtime.JobOwner in project mantis by Netflix.

the class JobClusterConfigTest method noSchedInfoFails.

@Test(expected = Exception.class)
public void noSchedInfoFails() {
    String name = "noSchedInfoFails";
    JobClusterConfig clusterConfig = new JobClusterConfig.Builder().withArtifactName("myart").withSchedulingInfo(null).withVersion("0.0.1").build();
    final JobClusterDefinitionImpl fakeJobCluster = new JobClusterDefinitionImpl.Builder().withJobClusterConfig(clusterConfig).withName(name).withParameters(Lists.newArrayList()).withUser("nj").withIsReadyForJobMaster(true).withOwner(new JobOwner("Nick", "Mantis", "desc", "nma@netflix.com", "repo")).withMigrationConfig(WorkerMigrationConfig.DEFAULT).build();
}
Also used : JobOwner(io.mantisrx.runtime.JobOwner) Test(org.junit.Test)

Example 5 with JobOwner

use of io.mantisrx.runtime.JobOwner in project mantis by Netflix.

the class JobClusterConfigTest method happyTest.

@Test
public void happyTest() {
    String name = "happyTest";
    JobClusterConfig clusterConfig = new JobClusterConfig.Builder().withArtifactName("myart").withSchedulingInfo(DEFAULT_SCHED_INFO).withVersion("0.0.1").build();
    try {
        final JobClusterDefinitionImpl fakeJobCluster = new JobClusterDefinitionImpl.Builder().withJobClusterConfig(clusterConfig).withName(name).withUser("nj").withParameters(Lists.newArrayList()).withIsReadyForJobMaster(true).withOwner(new JobOwner("Nick", "Mantis", "desc", "nma@netflix.com", "repo")).withMigrationConfig(WorkerMigrationConfig.DEFAULT).build();
    } catch (Exception e) {
        fail();
    }
}
Also used : JobOwner(io.mantisrx.runtime.JobOwner) Test(org.junit.Test)

Aggregations

JobOwner (io.mantisrx.runtime.JobOwner)6 Test (org.junit.Test)6 Label (io.mantisrx.common.Label)1 IJobClusterMetadata (io.mantisrx.master.jobcluster.IJobClusterMetadata)1 Parameter (io.mantisrx.runtime.parameter.Parameter)1 NamedJob (io.mantisrx.server.master.store.NamedJob)1 ArrayList (java.util.ArrayList)1