Search in sources :

Example 6 with SLA

use of io.mantisrx.server.master.domain.SLA in project mantis by Netflix.

the class SLAEnforcerTest method slaMaxTest2.

@Test
public void slaMaxTest2() {
    Instant now = Instant.now();
    int min = 0;
    int max = 2;
    SLA sla = new SLA(min, max, null, null);
    SLAEnforcer slaEnf = new SLAEnforcer(sla);
    List<JobInfo> jobList = Lists.newArrayList(new JobInfo(new JobId("cname", 1), null, now.getMillis(), null, JobState.Accepted, null), new JobInfo(new JobId("cname", 2), null, now.getMillis(), null, JobState.Launched, null), new JobInfo(new JobId("cname", 3), null, now.getMillis(), null, JobState.Launched, null), new JobInfo(new JobId("cname", 4), null, now.getMillis(), null, JobState.Launched, null));
    // 3 active and 1 accepted jobs, terminate job 2
    List<JobId> jobsToDelete = slaEnf.enforceSLAMax(jobList);
    assertEquals(2, jobsToDelete.size());
    boolean job1Found = false;
    boolean job2Found = false;
    for (JobId jId : jobsToDelete) {
        if (jId.getId().equals("cname-1")) {
            job1Found = true;
        } else if (jId.getId().equals("cname-2")) {
            job2Found = true;
        }
    }
    assertTrue(job1Found && job2Found);
}
Also used : JobInfo(io.mantisrx.master.jobcluster.JobClusterActor.JobInfo) Instant(org.joda.time.Instant) SLA(io.mantisrx.server.master.domain.SLA) JobId(io.mantisrx.server.master.domain.JobId) Test(org.junit.Test)

Example 7 with SLA

use of io.mantisrx.server.master.domain.SLA in project mantis by Netflix.

the class SLAEnforcerTest method slaMaxTest3.

@Test
public void slaMaxTest3() {
    Instant now = Instant.now();
    int min = 0;
    int max = 2;
    SLA sla = new SLA(min, max, null, null);
    SLAEnforcer slaEnf = new SLAEnforcer(sla);
    List<JobInfo> jobList = Lists.newArrayList(new JobInfo(new JobId("cname", 5), null, now.getMillis(), null, JobState.Accepted, null), new JobInfo(new JobId("cname", 1), null, now.getMillis(), null, JobState.Accepted, null), new JobInfo(new JobId("cname", 4), null, now.getMillis(), null, JobState.Launched, null), new JobInfo(new JobId("cname", 2), null, now.getMillis(), null, JobState.Accepted, null), new JobInfo(new JobId("cname", 3), null, now.getMillis(), null, JobState.Accepted, null), new JobInfo(new JobId("cname", 6), null, now.getMillis(), null, JobState.Launched, null));
    // 2 active and 4 accepted jobs, terminate jobs 3,2,1
    List<JobId> jobsToDelete = slaEnf.enforceSLAMax(jobList);
    assertEquals(3, jobsToDelete.size());
    assertTrue(jobsToDelete.contains(new JobId("cname", 1)));
    assertTrue(jobsToDelete.contains(new JobId("cname", 2)));
    assertTrue(jobsToDelete.contains(new JobId("cname", 3)));
}
Also used : JobInfo(io.mantisrx.master.jobcluster.JobClusterActor.JobInfo) Instant(org.joda.time.Instant) SLA(io.mantisrx.server.master.domain.SLA) JobId(io.mantisrx.server.master.domain.JobId) Test(org.junit.Test)

Example 8 with SLA

use of io.mantisrx.server.master.domain.SLA in project mantis by Netflix.

the class SLAEnforcerTest method slaMinInvalidArgTest.

@Test
public void slaMinInvalidArgTest() {
    int min = 2;
    int max = 0;
    try {
        SLA sla = new SLA(min, max, null, null);
        SLAEnforcer slaEnf = new SLAEnforcer(sla);
        slaEnf.enforceSLAMin(-1, 0);
        fail();
    } catch (Exception e) {
    }
}
Also used : SLA(io.mantisrx.server.master.domain.SLA) Test(org.junit.Test)

Example 9 with SLA

use of io.mantisrx.server.master.domain.SLA in project mantis by Netflix.

the class SLAEnforcerTest method slaValidationTest.

@Test
public void slaValidationTest() {
    int min = 5;
    int max = 2;
    try {
        SLA sla = new SLA(5, 2, null, null);
        fail();
    } catch (Exception e) {
    }
}
Also used : SLA(io.mantisrx.server.master.domain.SLA) Test(org.junit.Test)

Example 10 with SLA

use of io.mantisrx.server.master.domain.SLA in project mantis by Netflix.

the class SLAEnforcerTest method slaMinDefaultsTest.

@Test
public void slaMinDefaultsTest() {
    SLA sla = new SLA(0, 0, null, null);
    SLAEnforcer slaEnf = new SLAEnforcer(sla);
    assertEquals(0, slaEnf.enforceSLAMin(2, 0));
    try {
        slaEnf = new SLAEnforcer(null);
        assertEquals(0, slaEnf.enforceSLAMin(2, 0));
    } catch (Exception e) {
        fail();
    }
}
Also used : SLA(io.mantisrx.server.master.domain.SLA) Test(org.junit.Test)

Aggregations

SLA (io.mantisrx.server.master.domain.SLA)13 Test (org.junit.Test)10 JobId (io.mantisrx.server.master.domain.JobId)7 JobInfo (io.mantisrx.master.jobcluster.JobClusterActor.JobInfo)6 Instant (org.joda.time.Instant)6 SchedulerException (com.netflix.fenzo.triggers.exceptions.SchedulerException)3 TriggerNotFoundException (com.netflix.fenzo.triggers.exceptions.TriggerNotFoundException)3 JobClusterAlreadyExistsException (io.mantisrx.server.master.persistence.exceptions.JobClusterAlreadyExistsException)3 ActorRef (akka.actor.ActorRef)2 LifecycleEventsProto (io.mantisrx.master.events.LifecycleEventsProto)2 IMantisJobMetadata (io.mantisrx.master.jobcluster.job.IMantisJobMetadata)2 UpdateJobClusterSLAResponse (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterSLAResponse)2 JobClusterDefinitionImpl (io.mantisrx.server.master.domain.JobClusterDefinitionImpl)2 AbstractActorWithTimers (akka.actor.AbstractActorWithTimers)1 Props (akka.actor.Props)1 SupervisorStrategy (akka.actor.SupervisorStrategy)1 Terminated (akka.actor.Terminated)1 PatternsCS.ask (akka.pattern.PatternsCS.ask)1 LabelUtils (com.mantisrx.common.utils.LabelUtils)1 CronTrigger (com.netflix.fenzo.triggers.CronTrigger)1