diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-01-08 10:59:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-08 10:59:04 +0100 |
commit | acde14de1286c4ef663ee5b26be768c46dbdcbbf (patch) | |
tree | ac51923810812a1237d103a376d278280c93a020 /vespajlib/src/test/java/com/yahoo/concurrent/maintenance/MaintainerTest.java | |
parent | 55599006c8693209cfb7109329cbaacc56f2fbf1 (diff) |
Revert "Revert "Count lock timeout as unsuccessful run""
Diffstat (limited to 'vespajlib/src/test/java/com/yahoo/concurrent/maintenance/MaintainerTest.java')
-rw-r--r-- | vespajlib/src/test/java/com/yahoo/concurrent/maintenance/MaintainerTest.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/concurrent/maintenance/MaintainerTest.java b/vespajlib/src/test/java/com/yahoo/concurrent/maintenance/MaintainerTest.java index 2bfaad894a5..e881d4b3ff6 100644 --- a/vespajlib/src/test/java/com/yahoo/concurrent/maintenance/MaintainerTest.java +++ b/vespajlib/src/test/java/com/yahoo/concurrent/maintenance/MaintainerTest.java @@ -1,6 +1,7 @@ // Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.concurrent.maintenance; +import com.google.common.util.concurrent.UncheckedTimeoutException; import org.junit.Test; import java.time.Duration; @@ -15,6 +16,8 @@ import static org.junit.Assert.assertEquals; */ public class MaintainerTest { + private final JobControl jobControl = new JobControl(new JobControlStateMock()); + @Test public void staggering() { List<String> cluster = List.of("cfg1", "cfg2", "cfg3"); @@ -41,7 +44,7 @@ public class MaintainerTest { public void success_metric() { AtomicLong consecutiveFailures = new AtomicLong(); JobMetrics jobMetrics = new JobMetrics((job, count) -> consecutiveFailures.set(count)); - TestMaintainer maintainer = new TestMaintainer(jobMetrics); + TestMaintainer maintainer = new TestMaintainer(null, jobControl, jobMetrics); // Maintainer fails twice in a row maintainer.successOnNextRun(false).run(); @@ -58,12 +61,16 @@ public class MaintainerTest { assertEquals(0, consecutiveFailures.get()); // Maintainer throws - maintainer.throwOnNextRun(true).run(); + maintainer.throwOnNextRun(new RuntimeException()).run(); assertEquals(1, consecutiveFailures.get()); // Maintainer recovers - maintainer.throwOnNextRun(false).run(); + maintainer.throwOnNextRun(null).run(); assertEquals(0, consecutiveFailures.get()); + + // Lock exception is treated as a failure + maintainer.throwOnNextRun(new UncheckedTimeoutException()).run(); + assertEquals(1, consecutiveFailures.get()); } } |