summaryrefslogtreecommitdiffstats
path: root/jdisc_core/src/test/java/com/yahoo/jdisc/core
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@oath.com>2018-03-08 14:30:14 +0100
committerBjørn Christian Seime <bjorncs@oath.com>2018-03-08 15:01:03 +0100
commit59b79bdfd395dffd06ec46ef9b16ff1dfbe273a7 (patch)
treed50611f9fef5339e62721b149c27fe1ba9d6313d /jdisc_core/src/test/java/com/yahoo/jdisc/core
parent0d4f9c79a4a93f52c2071cb351a92dc2ca03b7a0 (diff)
Reduce logging of false positives in container watchdog
Introduce a lower grace period only used by the gc check to ensure that deactivated containers have a chance of being collected before being reported as stale in the log and the metrics api.
Diffstat (limited to 'jdisc_core/src/test/java/com/yahoo/jdisc/core')
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/core/ActiveContainerDeactivationWatchdogTest.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ActiveContainerDeactivationWatchdogTest.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ActiveContainerDeactivationWatchdogTest.java
index 280ecd51624..e2de08e760f 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ActiveContainerDeactivationWatchdogTest.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ActiveContainerDeactivationWatchdogTest.java
@@ -33,9 +33,7 @@ public class ActiveContainerDeactivationWatchdogTest {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ManualClock clock = new ManualClock(Instant.now());
ActiveContainerDeactivationWatchdog watchdog =
- new ActiveContainerDeactivationWatchdog(clock,
- Executors.newScheduledThreadPool(1),
- ActiveContainerDeactivationWatchdog.DEFAULT_DEACTIVATED_CONTAINERS_BEFORE_GC_THRESHOLD);
+ new ActiveContainerDeactivationWatchdog(clock, Executors.newScheduledThreadPool(1));
MockMetric metric = new MockMetric();
ActiveContainer containerWithoutRetainedResources = new ActiveContainer(driver.newContainerBuilder());
@@ -47,7 +45,7 @@ public class ActiveContainerDeactivationWatchdogTest {
watchdog.onContainerActivation(null);
containerWithoutRetainedResources.release();
- clock.advance(ActiveContainerDeactivationWatchdog.ACTIVE_CONTAINER_GRACE_PERIOD);
+ clock.advance(ActiveContainerDeactivationWatchdog.REPORTING_GRACE_PERIOD);
watchdog.emitMetrics(metric);
assertEquals(0, metric.totalCount);
assertEquals(0, metric.withRetainedReferencesCount);
@@ -62,7 +60,7 @@ public class ActiveContainerDeactivationWatchdogTest {
watchdog.onContainerActivation(containerWithRetainedResources);
containerWithRetainedResources.release();
watchdog.onContainerActivation(null);
- clock.advance(ActiveContainerDeactivationWatchdog.ACTIVE_CONTAINER_GRACE_PERIOD.plusSeconds(1));
+ clock.advance(ActiveContainerDeactivationWatchdog.REPORTING_GRACE_PERIOD.plusSeconds(1));
watchdog.emitMetrics(metric);
assertEquals(2, metric.totalCount);
assertEquals(1, metric.withRetainedReferencesCount);
@@ -76,8 +74,7 @@ public class ActiveContainerDeactivationWatchdogTest {
public void deactivated_container_destructed_if_its_reference_counter_is_nonzero() {
ExecutorMock executor = new ExecutorMock();
ManualClock clock = new ManualClock(Instant.now());
- ActiveContainerDeactivationWatchdog watchdog =
- new ActiveContainerDeactivationWatchdog(clock, executor, /*deactivatedContainersBeforeGcThreshold*/0);
+ ActiveContainerDeactivationWatchdog watchdog = new ActiveContainerDeactivationWatchdog(clock, executor);
ActiveContainer container =
new ActiveContainer(TestDriver.newSimpleApplicationInstanceWithoutOsgi().newContainerBuilder());
AtomicBoolean destructed = new AtomicBoolean(false);
@@ -90,7 +87,7 @@ public class ActiveContainerDeactivationWatchdogTest {
WeakReference<ActiveContainer> containerWeakReference = new WeakReference<>(container);
container = null; // make container instance collectable by GC
- clock.advance(ActiveContainerDeactivationWatchdog.ACTIVE_CONTAINER_GRACE_PERIOD.plusSeconds(1));
+ clock.advance(ActiveContainerDeactivationWatchdog.GC_GRACE_PERIOD.plusSeconds(1));
executor.triggerGcCommand.run();