Repository: aurora Updated Branches: refs/heads/master 8cf3e3b84 -> 787ccfed5
Support PARTITIONED state in SLA calculations. Also added a test to protect against this test failing in the future. Reviewed at https://reviews.apache.org/r/65281/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/787ccfed Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/787ccfed Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/787ccfed Branch: refs/heads/master Commit: 787ccfed58a365e519de3fe3b37f4d87dd073017 Parents: 8cf3e3b Author: David McLaughlin <[email protected]> Authored: Tue Jan 30 14:06:39 2018 -0800 Committer: David McLaughlin <[email protected]> Committed: Tue Jan 30 14:06:39 2018 -0800 ---------------------------------------------------------------------- .../org/apache/aurora/scheduler/sla/SlaAlgorithm.java | 1 + .../apache/aurora/scheduler/sla/SlaAlgorithmTest.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/787ccfed/src/main/java/org/apache/aurora/scheduler/sla/SlaAlgorithm.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/sla/SlaAlgorithm.java b/src/main/java/org/apache/aurora/scheduler/sla/SlaAlgorithm.java index 5d8d5bd..690d8ec 100644 --- a/src/main/java/org/apache/aurora/scheduler/sla/SlaAlgorithm.java +++ b/src/main/java/org/apache/aurora/scheduler/sla/SlaAlgorithm.java @@ -330,6 +330,7 @@ interface SlaAlgorithm { break; case RUNNING: + case PARTITIONED: current = updateIntervals(timestamp, SlaState.UP, current, intervals); break; http://git-wip-us.apache.org/repos/asf/aurora/blob/787ccfed/src/test/java/org/apache/aurora/scheduler/sla/SlaAlgorithmTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/aurora/scheduler/sla/SlaAlgorithmTest.java b/src/test/java/org/apache/aurora/scheduler/sla/SlaAlgorithmTest.java index 2e719ac..cb86958 100644 --- a/src/test/java/org/apache/aurora/scheduler/sla/SlaAlgorithmTest.java +++ b/src/test/java/org/apache/aurora/scheduler/sla/SlaAlgorithmTest.java @@ -31,6 +31,7 @@ import static org.apache.aurora.gen.ScheduleStatus.INIT; import static org.apache.aurora.gen.ScheduleStatus.KILLED; import static org.apache.aurora.gen.ScheduleStatus.KILLING; import static org.apache.aurora.gen.ScheduleStatus.LOST; +import static org.apache.aurora.gen.ScheduleStatus.PARTITIONED; import static org.apache.aurora.gen.ScheduleStatus.PENDING; import static org.apache.aurora.gen.ScheduleStatus.RESTARTING; import static org.apache.aurora.gen.ScheduleStatus.RUNNING; @@ -288,7 +289,8 @@ public class SlaAlgorithmTest { 100L, PENDING, 200L, ASSIGNED, 300L, STARTING, - 400L, RUNNING), 1), // 100% uptime. + 400L, RUNNING, + 500L, PARTITIONED), 1), // 100% uptime. makeTask(ImmutableMap.<Long, ScheduleStatus>builder() .put(5L, INIT) .put(10L, PENDING) @@ -331,6 +333,15 @@ public class SlaAlgorithmTest { assertEquals(100.0, actual); } + @Test + public void testSupportAllStatuses() { + for (ScheduleStatus status: ScheduleStatus.values()) { + AGGREGATE_PLATFORM_UPTIME.getAlgorithm().calculate( + ImmutableSet.of(makeTask(ImmutableMap.of(50L, status), 0)), + Range.closedOpen(100L, 500L)); + } + } + private static Set<IScheduledTask> makeUptimeTasks(int num, long now) { Set<IScheduledTask> instances = Sets.newHashSet(); for (int i = 0; i < num; i++) {
