Repository: aurora Updated Branches: refs/heads/master c20346c18 -> 4a1ed1f1d
Suppress no-op delete log noise during scheduler startup. Reviewed at https://reviews.apache.org/r/39691/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/4a1ed1f1 Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/4a1ed1f1 Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/4a1ed1f1 Branch: refs/heads/master Commit: 4a1ed1f1d800477c989a2726cebd818ef605c407 Parents: c20346c Author: Bill Farner <[email protected]> Authored: Tue Oct 27 20:12:16 2015 -0700 Committer: Bill Farner <[email protected]> Committed: Tue Oct 27 20:12:16 2015 -0700 ---------------------------------------------------------------------- .../scheduler/pruning/TaskHistoryPruner.java | 4 +- .../aurora/LifecycleShutdownListenerTest.java | 58 ++++++++++++++++++++ .../pruning/TaskHistoryPrunerTest.java | 19 ++++++- 3 files changed, 77 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/4a1ed1f1/src/main/java/org/apache/aurora/scheduler/pruning/TaskHistoryPruner.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/pruning/TaskHistoryPruner.java b/src/main/java/org/apache/aurora/scheduler/pruning/TaskHistoryPruner.java index 4e37070..bb1fc8b 100644 --- a/src/main/java/org/apache/aurora/scheduler/pruning/TaskHistoryPruner.java +++ b/src/main/java/org/apache/aurora/scheduler/pruning/TaskHistoryPruner.java @@ -165,7 +165,9 @@ public class TaskHistoryPruner implements EventSubscriber { .limit(tasksToPrune) .transform(Tasks::id) .toSet(); - deleteTasks(toPrune); + if (!toPrune.isEmpty()) { + deleteTasks(toPrune); + } } } }); http://git-wip-us.apache.org/repos/asf/aurora/blob/4a1ed1f1/src/test/java/org/apache/aurora/LifecycleShutdownListenerTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/aurora/LifecycleShutdownListenerTest.java b/src/test/java/org/apache/aurora/LifecycleShutdownListenerTest.java new file mode 100644 index 0000000..8d19c04 --- /dev/null +++ b/src/test/java/org/apache/aurora/LifecycleShutdownListenerTest.java @@ -0,0 +1,58 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.aurora; + +import com.google.common.util.concurrent.AbstractService; +import com.google.common.util.concurrent.Service; +import com.google.common.util.concurrent.ServiceManager; + +import org.apache.aurora.GuavaUtils.LifecycleShutdownListener; +import org.apache.aurora.common.application.Lifecycle; +import org.apache.aurora.common.base.Command; +import org.apache.aurora.common.testing.easymock.EasyMockTest; +import org.junit.Before; +import org.junit.Test; + +public class LifecycleShutdownListenerTest extends EasyMockTest { + + private static final Service NOOP_SERVICE = new AbstractService() { + @Override + protected void doStart() { + // Noop. + } + + @Override + protected void doStop() { + // Noop. + } + }; + + private Command shutdown; + private ServiceManager.Listener listener; + + @Before + public void setUp() { + shutdown = createMock(Command.class); + listener = new LifecycleShutdownListener(new Lifecycle(shutdown)); + } + + @Test + public void testShutdownOnFailure() { + shutdown.execute(); + + control.replay(); + + listener.failure(NOOP_SERVICE); + } +} http://git-wip-us.apache.org/repos/asf/aurora/blob/4a1ed1f1/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java b/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java index acd2cd1..373e8b1 100644 --- a/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java +++ b/src/test/java/org/apache/aurora/scheduler/pruning/TaskHistoryPrunerTest.java @@ -205,6 +205,19 @@ public class TaskHistoryPrunerTest extends EasyMockTest { } @Test + public void testSuppressEmptyDelete() { + IScheduledTask running = makeTask("a", RUNNING); + IScheduledTask killed = copy(running, KILLED); + expectImmediatePrune( + ImmutableSet.of(makeTask("b", KILLED), makeTask("c", KILLED), makeTask("d", KILLED))); + expectDefaultDelayedPrune(); + + control.replay(); + + changeState(running, killed); + } + + @Test public void testJobHistoryExceeded() { IScheduledTask a = makeTask("a", RUNNING); clock.advance(ONE_MS); @@ -337,11 +350,11 @@ public class TaskHistoryPrunerTest extends EasyMockTest { } private Capture<Runnable> expectDefaultDelayedPrune() { - return expectDelayedPrune(ONE_DAY.as(Time.MILLISECONDS), 1); + return expectDelayedPrune(ONE_DAY.as(Time.MILLISECONDS)); } private Capture<Runnable> expectOneDelayedPrune(long timestampMillis) { - return expectDelayedPrune(timestampMillis, 1); + return expectDelayedPrune(timestampMillis); } private void expectNoImmediatePrune(ImmutableSet<IScheduledTask> tasksInJob) { @@ -373,7 +386,7 @@ public class TaskHistoryPrunerTest extends EasyMockTest { } } - private Capture<Runnable> expectDelayedPrune(long timestampMillis, int count) { + private Capture<Runnable> expectDelayedPrune(long timestampMillis) { Capture<Runnable> capture = createCapture(); executor.execute( EasyMock.capture(capture),
