lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject lucene-solr:master: SOLR-13068: Update many cloud/autoscaling tests to use TimeSource.NANO_TIME (instead of CURRENT_TIME) for comparisons
Date Thu, 13 Dec 2018 18:02:33 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master 4272c631c -> 46516b707


SOLR-13068: Update many cloud/autoscaling tests to use TimeSource.NANO_TIME (instead of CURRENT_TIME)
for comparisons

as much as possible, the tests actual use the time source directly from the cluster, so that
even if the cluster is changed to use an alternate time source, the tests will be consistent


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/46516b70
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/46516b70
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/46516b70

Branch: refs/heads/master
Commit: 46516b7077a52b4df9fbf640c17e30d8d8d012fe
Parents: 4272c63
Author: Chris Hostetter <hossman@apache.org>
Authored: Thu Dec 13 11:02:24 2018 -0700
Committer: Chris Hostetter <hossman@apache.org>
Committed: Thu Dec 13 11:02:24 2018 -0700

----------------------------------------------------------------------
 .../org/apache/solr/cloud/HttpPartitionTest.java  |  2 +-
 .../apache/solr/cloud/TestCloudConsistency.java   |  4 ++--
 .../cloud/autoscaling/ExecutePlanActionTest.java  |  9 +++++----
 .../autoscaling/MetricTriggerIntegrationTest.java | 10 ++++++++--
 .../NodeAddedTriggerIntegrationTest.java          |  2 +-
 .../cloud/autoscaling/NodeAddedTriggerTest.java   | 18 +++++++++---------
 .../NodeLostTriggerIntegrationTest.java           |  2 +-
 .../cloud/autoscaling/NodeLostTriggerTest.java    | 18 +++++++++---------
 .../autoscaling/RestoreTriggerStateTest.java      |  3 +--
 .../SearchRateTriggerIntegrationTest.java         |  3 ++-
 .../TriggerCooldownIntegrationTest.java           |  9 ++++++---
 .../cloud/autoscaling/TriggerIntegrationTest.java | 10 +++++-----
 .../TriggerSetPropertiesIntegrationTest.java      |  3 +--
 .../autoscaling/sim/TestSimExecutePlanAction.java |  5 +++--
 14 files changed, 54 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/46516b70/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
index 012bc23..b8a6048 100644
--- a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
@@ -319,7 +319,7 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
   }
 
   protected void waitForState(String collection, String replicaName, Replica.State state,
long ms) throws KeeperException, InterruptedException {
-    TimeOut timeOut = new TimeOut(ms, TimeUnit.MILLISECONDS, TimeSource.CURRENT_TIME);
+    TimeOut timeOut = new TimeOut(ms, TimeUnit.MILLISECONDS, TimeSource.NANO_TIME);
     Replica.State replicaState = Replica.State.ACTIVE;
     while (!timeOut.hasTimedOut()) {
       ZkStateReader zkr = cloudClient.getZkStateReader();

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/46516b70/solr/core/src/test/org/apache/solr/cloud/TestCloudConsistency.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestCloudConsistency.java b/solr/core/src/test/org/apache/solr/cloud/TestCloudConsistency.java
index 9b27522..66ebb2c 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestCloudConsistency.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudConsistency.java
@@ -171,7 +171,7 @@ public class TestCloudConsistency extends SolrCloudTestCase {
     cluster.waitForNode(j1, 30);
     cluster.waitForNode(j2, 30);
     
-    TimeOut timeOut = new TimeOut(10, TimeUnit.SECONDS, TimeSource.CURRENT_TIME);
+    TimeOut timeOut = new TimeOut(10, TimeUnit.SECONDS, TimeSource.NANO_TIME);
     while (!timeOut.hasTimedOut()) {
       Replica newLeader = getCollectionState(collection).getSlice("shard1").getLeader();
       if (newLeader != null && !newLeader.getName().equals(leader.getName()) &&
newLeader.getState() == Replica.State.ACTIVE) {
@@ -213,7 +213,7 @@ public class TestCloudConsistency extends SolrCloudTestCase {
     waitForState("Timeout waiting for leader goes DOWN", collection, (liveNodes, collectionState)
         -> collectionState.getReplica(leader.getName()).getState() == Replica.State.DOWN);
 
-    TimeOut timeOut = new TimeOut(10, TimeUnit.SECONDS, TimeSource.CURRENT_TIME);
+    TimeOut timeOut = new TimeOut(10, TimeUnit.SECONDS, TimeSource.NANO_TIME);
     while (!timeOut.hasTimedOut()) {
       Replica newLeader = getCollectionState(collection).getLeader("shard1");
       if (newLeader != null && !newLeader.getName().equals(leader.getName()) &&
newLeader.getState() == Replica.State.ACTIVE) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/46516b70/solr/core/src/test/org/apache/solr/cloud/autoscaling/ExecutePlanActionTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/ExecutePlanActionTest.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/ExecutePlanActionTest.java
index cbd0bac..9ca38fd 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/ExecutePlanActionTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/ExecutePlanActionTest.java
@@ -43,7 +43,6 @@ import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.Utils;
 import org.apache.solr.core.SolrResourceLoader;
 import org.apache.solr.util.LogLevel;
-import org.apache.solr.common.util.TimeSource;
 import org.apache.zookeeper.data.Stat;
 import org.junit.After;
 import org.junit.Before;
@@ -151,9 +150,11 @@ public class ExecutePlanActionTest extends SolrCloudTestCase {
         }
       };
       List<CollectionAdminRequest.AsyncCollectionAdminRequest> operations = Lists.asList(moveReplica,
new CollectionAdminRequest.AsyncCollectionAdminRequest[]{mockRequest});
-      NodeLostTrigger.NodeLostEvent nodeLostEvent = new NodeLostTrigger.NodeLostEvent(TriggerEventType.NODELOST,
-          "mock_trigger_name", Collections.singletonList(TimeSource.CURRENT_TIME.getTimeNs()),
-          Collections.singletonList(sourceNodeName), CollectionParams.CollectionAction.MOVEREPLICA.toLower());
+      NodeLostTrigger.NodeLostEvent nodeLostEvent = new NodeLostTrigger.NodeLostEvent
+        (TriggerEventType.NODELOST, "mock_trigger_name",
+         Collections.singletonList(cloudManager.getTimeSource().getTimeNs()),
+         Collections.singletonList(sourceNodeName),
+         CollectionParams.CollectionAction.MOVEREPLICA.toLower());
       ActionContext actionContext = new ActionContext(survivor.getCoreContainer().getZkController().getSolrCloudManager(),
null,
           new HashMap<>(Collections.singletonMap("operations", operations)));
       action.process(nodeLostEvent, actionContext);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/46516b70/solr/core/src/test/org/apache/solr/cloud/autoscaling/MetricTriggerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/MetricTriggerIntegrationTest.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/MetricTriggerIntegrationTest.java
index a562633..418a626 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/MetricTriggerIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/MetricTriggerIntegrationTest.java
@@ -39,6 +39,7 @@ import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.cloud.DocCollection;
 import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.TimeSource;
 import org.apache.solr.common.util.Utils;
 import org.apache.solr.core.SolrResourceLoader;
 import org.apache.solr.metrics.SolrCoreMetricManager;
@@ -50,7 +51,6 @@ import org.slf4j.LoggerFactory;
 
 import static org.apache.solr.cloud.autoscaling.AutoScalingHandlerTest.createAutoScalingRequest;
 import static org.apache.solr.cloud.autoscaling.TriggerIntegrationTest.WAIT_FOR_DELTA_NANOS;
-import static org.apache.solr.cloud.autoscaling.TriggerIntegrationTest.timeSource;
 
 /**
  * Integration test for {@link MetricTrigger}
@@ -58,6 +58,9 @@ import static org.apache.solr.cloud.autoscaling.TriggerIntegrationTest.timeSourc
 @LogLevel("org.apache.solr.cloud.autoscaling=DEBUG;org.apache.solr.client.solrj.cloud.autoscaling=DEBUG")
 public class MetricTriggerIntegrationTest extends SolrCloudTestCase {
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+  private static final TimeSource timeSource = TimeSource.NANO_TIME;
+  
   static Map<String, List<CapturedEvent>> listenerEvents = new HashMap<>();
   static CountDownLatch listenerCreated = new CountDownLatch(1);
   private static CountDownLatch triggerFiredLatch;
@@ -212,7 +215,7 @@ public class MetricTriggerIntegrationTest extends SolrCloudTestCase {
     public void process(TriggerEvent event, ActionContext context) throws Exception {
       try {
         events.add(event);
-        long currentTimeNanos = timeSource.getTimeNs();
+        long currentTimeNanos = context.getCloudManager().getTimeSource().getTimeNs();
         long eventTimeNanos = event.getEventTime();
         long waitForNanos = TimeUnit.NANOSECONDS.convert(waitForSeconds, TimeUnit.SECONDS)
- WAIT_FOR_DELTA_NANOS;
         if (currentTimeNanos - eventTimeNanos <= waitForNanos) {
@@ -227,10 +230,12 @@ public class MetricTriggerIntegrationTest extends SolrCloudTestCase
{
   }
 
   public static class TestTriggerListener extends TriggerListenerBase {
+    private TimeSource timeSource;
     @Override
     public void configure(SolrResourceLoader loader, SolrCloudManager cloudManager, AutoScalingConfig.TriggerListenerConfig
config) throws TriggerValidationException {
       super.configure(loader, cloudManager, config);
       listenerCreated.countDown();
+      timeSource = cloudManager.getTimeSource();
     }
 
     @Override
@@ -238,6 +243,7 @@ public class MetricTriggerIntegrationTest extends SolrCloudTestCase {
                                      ActionContext context, Throwable error, String message)
{
       List<CapturedEvent> lst = listenerEvents.computeIfAbsent(config.name, s ->
new ArrayList<>());
       lst.add(new CapturedEvent(timeSource.getTimeNs(), context, config, stage, actionName,
event, message));
+                                
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/46516b70/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeAddedTriggerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeAddedTriggerIntegrationTest.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeAddedTriggerIntegrationTest.java
index 795c530..bce3ea1 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeAddedTriggerIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeAddedTriggerIntegrationTest.java
@@ -258,7 +258,7 @@ public class NodeAddedTriggerIntegrationTest extends SolrCloudTestCase
{
       try {
         if (triggerFired.compareAndSet(false, true)) {
           events.add(event);
-          long currentTimeNanos = TriggerIntegrationTest.timeSource.getTimeNs();
+          long currentTimeNanos = actionContext.getCloudManager().getTimeSource().getTimeNs();
           long eventTimeNanos = event.getEventTime();
           long waitForNanos = TimeUnit.NANOSECONDS.convert(waitForSeconds, TimeUnit.SECONDS)
- WAIT_FOR_DELTA_NANOS;
           if (currentTimeNanos - eventTimeNanos <= waitForNanos) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/46516b70/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeAddedTriggerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeAddedTriggerTest.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeAddedTriggerTest.java
index 8a78520..de4af4b 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeAddedTriggerTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeAddedTriggerTest.java
@@ -31,7 +31,6 @@ import org.apache.solr.client.solrj.cloud.SolrCloudManager;
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
 import org.apache.solr.cloud.SolrCloudTestCase;
 import org.apache.solr.core.CoreContainer;
-import org.apache.solr.common.util.TimeSource;
 import org.apache.solr.core.SolrResourceLoader;
 import org.junit.After;
 import org.junit.Before;
@@ -51,8 +50,6 @@ public class NodeAddedTriggerTest extends SolrCloudTestCase {
     return true;
   };
 
-  private static final TimeSource timeSource = TimeSource.CURRENT_TIME;
-  // currentTimeMillis is not as precise so to avoid false positives while comparing time
of fire, we add some delta
   private static final long WAIT_FOR_DELTA_NANOS = TimeUnit.MILLISECONDS.toNanos(2);
 
   @BeforeClass
@@ -82,7 +79,8 @@ public class NodeAddedTriggerTest extends SolrCloudTestCase {
     Map<String, Object> props = createTriggerProps(waitForSeconds);
 
     try (NodeAddedTrigger trigger = new NodeAddedTrigger("node_added_trigger")) {
-      trigger.configure(container.getResourceLoader(), container.getZkController().getSolrCloudManager(),
props);
+      final SolrCloudManager cloudManager = container.getZkController().getSolrCloudManager();
+      trigger.configure(container.getResourceLoader(), cloudManager, props);
       trigger.init();
       trigger.setProcessor(noFirstRunProcessor);
       trigger.run();
@@ -97,7 +95,7 @@ public class NodeAddedTriggerTest extends SolrCloudTestCase {
       trigger.setProcessor(event -> {
         if (fired.compareAndSet(false, true)) {
           eventRef.set(event);
-          long currentTimeNanos = timeSource.getTimeNs();
+          long currentTimeNanos = cloudManager.getTimeSource().getTimeNs();
           long eventTimeNanos = event.getEventTime();
           long waitForNanos = TimeUnit.NANOSECONDS.convert(waitForSeconds, TimeUnit.SECONDS)
- WAIT_FOR_DELTA_NANOS;
           if (currentTimeNanos - eventTimeNanos <= waitForNanos) {
@@ -127,7 +125,8 @@ public class NodeAddedTriggerTest extends SolrCloudTestCase {
     // add a new node but remove it before the waitFor period expires
     // and assert that the trigger doesn't fire at all
     try (NodeAddedTrigger trigger = new NodeAddedTrigger("node_added_trigger")) {
-      trigger.configure(container.getResourceLoader(), container.getZkController().getSolrCloudManager(),
props);
+      final SolrCloudManager cloudManager = container.getZkController().getSolrCloudManager();
+      trigger.configure(container.getResourceLoader(), cloudManager, props);
       trigger.init();
       final long waitTime = 2;
       props.put("waitFor", waitTime);
@@ -138,7 +137,7 @@ public class NodeAddedTriggerTest extends SolrCloudTestCase {
       AtomicBoolean fired = new AtomicBoolean(false);
       trigger.setProcessor(event -> {
         if (fired.compareAndSet(false, true)) {
-          long currentTimeNanos = timeSource.getTimeNs();
+          long currentTimeNanos = cloudManager.getTimeSource().getTimeNs();
           long eventTimeNanos = event.getEventTime();
           long waitForNanos = TimeUnit.NANOSECONDS.convert(waitForSeconds, TimeUnit.SECONDS)
- WAIT_FOR_DELTA_NANOS;
           if (currentTimeNanos - eventTimeNanos <= waitForNanos) {
@@ -281,13 +280,14 @@ public class NodeAddedTriggerTest extends SolrCloudTestCase {
     }
 
     try (NodeAddedTrigger newTrigger = new NodeAddedTrigger("node_added_trigger"))  {
-      newTrigger.configure(container.getResourceLoader(), container.getZkController().getSolrCloudManager(),
props);
+      final SolrCloudManager cloudManager = container.getZkController().getSolrCloudManager();
+      newTrigger.configure(container.getResourceLoader(), cloudManager, props);
       newTrigger.init();
       AtomicBoolean stop = new AtomicBoolean(false);
       AtomicReference<TriggerEvent> eventRef = new AtomicReference<>();
       newTrigger.setProcessor(event -> {
         //the processor may get called 2 times, for newly added node and initial nodes
-        long currentTimeNanos = timeSource.getTimeNs();
+        long currentTimeNanos = cloudManager.getTimeSource().getTimeNs();
         long eventTimeNanos = event.getEventTime();
         long waitForNanos = TimeUnit.NANOSECONDS.convert(waitForSeconds, TimeUnit.SECONDS)
- WAIT_FOR_DELTA_NANOS;
         if (currentTimeNanos - eventTimeNanos <= waitForNanos) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/46516b70/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeLostTriggerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeLostTriggerIntegrationTest.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeLostTriggerIntegrationTest.java
index 744f1da..1e75b89 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeLostTriggerIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeLostTriggerIntegrationTest.java
@@ -283,7 +283,7 @@ public class NodeLostTriggerIntegrationTest extends SolrCloudTestCase
{
       try {
         if (triggerFired.compareAndSet(false, true)) {
           events.add(event);
-          long currentTimeNanos = TriggerIntegrationTest.timeSource.getTimeNs();
+          long currentTimeNanos = actionContext.getCloudManager().getTimeSource().getTimeNs();
           long eventTimeNanos = event.getEventTime();
           long waitForNanos = TimeUnit.NANOSECONDS.convert(waitForSeconds, TimeUnit.SECONDS)
- WAIT_FOR_DELTA_NANOS;
           if (currentTimeNanos - eventTimeNanos <= waitForNanos) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/46516b70/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeLostTriggerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeLostTriggerTest.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeLostTriggerTest.java
index ebe5081..c974de0 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeLostTriggerTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/NodeLostTriggerTest.java
@@ -51,9 +51,6 @@ public class NodeLostTriggerTest extends SolrCloudTestCase {
     return true;
   };
 
-  // use the same time source as the trigger
-  private final TimeSource timeSource = TimeSource.CURRENT_TIME;
-  // currentTimeMillis is not as precise so to avoid false positives while comparing time
of fire, we add some delta
   private static final long WAIT_FOR_DELTA_NANOS = TimeUnit.MILLISECONDS.toNanos(5);
 
   @After
@@ -82,7 +79,8 @@ public class NodeLostTriggerTest extends SolrCloudTestCase {
     Map<String, Object> props = createTriggerProps(waitForSeconds);
 
     try (NodeLostTrigger trigger = new NodeLostTrigger("node_lost_trigger")) {
-      trigger.configure(container.getResourceLoader(), container.getZkController().getSolrCloudManager(),
props);
+      final SolrCloudManager cloudManager = container.getZkController().getSolrCloudManager();
+      trigger.configure(container.getResourceLoader(), cloudManager, props);
       trigger.init();
       trigger.setProcessor(noFirstRunProcessor);
       trigger.run();
@@ -99,7 +97,7 @@ public class NodeLostTriggerTest extends SolrCloudTestCase {
       trigger.setProcessor(event -> {
         if (fired.compareAndSet(false, true)) {
           eventRef.set(event);
-          long currentTimeNanos = timeSource.getTimeNs();
+          long currentTimeNanos = cloudManager.getTimeSource().getTimeNs();
           long eventTimeNanos = event.getEventTime();
           long waitForNanos = TimeUnit.NANOSECONDS.convert(waitForSeconds, TimeUnit.SECONDS)
- WAIT_FOR_DELTA_NANOS;
           if (currentTimeNanos - eventTimeNanos <= waitForNanos) {
@@ -130,7 +128,8 @@ public class NodeLostTriggerTest extends SolrCloudTestCase {
     // remove a node but add it back before the waitFor period expires
     // and assert that the trigger doesn't fire at all
     try (NodeLostTrigger trigger = new NodeLostTrigger("node_lost_trigger")) {
-      trigger.configure(container.getResourceLoader(), container.getZkController().getSolrCloudManager(),
props);
+      final SolrCloudManager cloudManager = container.getZkController().getSolrCloudManager();
+      trigger.configure(container.getResourceLoader(), cloudManager, props);
       final long waitTime = 2;
       props.put("waitFor", waitTime);
       trigger.init();
@@ -143,7 +142,7 @@ public class NodeLostTriggerTest extends SolrCloudTestCase {
       AtomicBoolean fired = new AtomicBoolean(false);
       trigger.setProcessor(event -> {
         if (fired.compareAndSet(false, true)) {
-          long currentTimeNanos = timeSource.getTimeNs();
+          long currentTimeNanos = cloudManager.getTimeSource().getTimeNs();
           long eventTimeNanos = event.getEventTime();
           long waitForNanos = TimeUnit.NANOSECONDS.convert(waitTime, TimeUnit.SECONDS) -
WAIT_FOR_DELTA_NANOS;
           if (currentTimeNanos - eventTimeNanos <= waitForNanos) {
@@ -329,14 +328,15 @@ public class NodeLostTriggerTest extends SolrCloudTestCase {
     }
 
     try (NodeLostTrigger newTrigger = new NodeLostTrigger("node_lost_trigger")) {
-      newTrigger.configure(container.getResourceLoader(), container.getZkController().getSolrCloudManager(),
props);
+      final SolrCloudManager cloudManager = container.getZkController().getSolrCloudManager();
+      newTrigger.configure(container.getResourceLoader(), cloudManager, props);
       newTrigger.init();
       AtomicBoolean fired = new AtomicBoolean(false);
       AtomicReference<TriggerEvent> eventRef = new AtomicReference<>();
       newTrigger.setProcessor(event -> {
         if (fired.compareAndSet(false, true)) {
           eventRef.set(event);
-          long currentTimeNanos = timeSource.getTimeNs();
+          long currentTimeNanos = cloudManager.getTimeSource().getTimeNs();
           long eventTimeNanos = event.getEventTime();
           long waitForNanos = TimeUnit.NANOSECONDS.convert(waitForSeconds, TimeUnit.SECONDS)
- WAIT_FOR_DELTA_NANOS;
           if (currentTimeNanos - eventTimeNanos <= waitForNanos) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/46516b70/solr/core/src/test/org/apache/solr/cloud/autoscaling/RestoreTriggerStateTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/RestoreTriggerStateTest.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/RestoreTriggerStateTest.java
index 3088424..602b08d 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/RestoreTriggerStateTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/RestoreTriggerStateTest.java
@@ -40,7 +40,6 @@ import org.slf4j.LoggerFactory;
 
 import static org.apache.solr.cloud.autoscaling.AutoScalingHandlerTest.createAutoScalingRequest;
 import static org.apache.solr.cloud.autoscaling.TriggerIntegrationTest.WAIT_FOR_DELTA_NANOS;
-import static org.apache.solr.cloud.autoscaling.TriggerIntegrationTest.timeSource;
 
 /**
  * Integration test to ensure that triggers can restore state from ZooKeeper after overseer
restart
@@ -144,7 +143,7 @@ public class RestoreTriggerStateTest extends SolrCloudTestCase {
       try {
         if (triggerFired.compareAndSet(false, true))  {
           events.add(event);
-          long currentTimeNanos = timeSource.getTimeNs();
+          long currentTimeNanos = actionContext.getCloudManager().getTimeSource().getTimeNs();
           long eventTimeNanos = event.getEventTime();
           long waitForNanos = TimeUnit.NANOSECONDS.convert(waitForSeconds, TimeUnit.SECONDS)
- WAIT_FOR_DELTA_NANOS;
           if (currentTimeNanos - eventTimeNanos <= waitForNanos) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/46516b70/solr/core/src/test/org/apache/solr/cloud/autoscaling/SearchRateTriggerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/SearchRateTriggerIntegrationTest.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/SearchRateTriggerIntegrationTest.java
index 76e4b83..ea8e915 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/SearchRateTriggerIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/SearchRateTriggerIntegrationTest.java
@@ -47,6 +47,7 @@ import org.apache.solr.common.params.CollectionParams;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.TimeSource;
 import org.apache.solr.common.util.Utils;
 import org.apache.solr.core.SolrResourceLoader;
 import org.apache.solr.util.LogLevel;
@@ -59,7 +60,6 @@ import org.slf4j.LoggerFactory;
 
 import static org.apache.solr.cloud.autoscaling.AutoScalingHandlerTest.createAutoScalingRequest;
 import static org.apache.solr.cloud.autoscaling.TriggerIntegrationTest.WAIT_FOR_DELTA_NANOS;
-import static org.apache.solr.cloud.autoscaling.TriggerIntegrationTest.timeSource;
 import static org.apache.solr.common.cloud.ZkStateReader.SOLR_AUTOSCALING_CONF_PATH;
 
 /**
@@ -71,6 +71,7 @@ import static org.apache.solr.common.cloud.ZkStateReader.SOLR_AUTOSCALING_CONF_P
 public class SearchRateTriggerIntegrationTest extends SolrCloudTestCase {
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
+  private static final TimeSource timeSource = TimeSource.NANO_TIME;
   private static CountDownLatch listenerCreated = new CountDownLatch(1);
   private static Map<String, List<CapturedEvent>> listenerEvents = new HashMap<>();
   private static CountDownLatch finished = new CountDownLatch(1);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/46516b70/solr/core/src/test/org/apache/solr/cloud/autoscaling/TriggerCooldownIntegrationTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/TriggerCooldownIntegrationTest.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/TriggerCooldownIntegrationTest.java
index 5c9ae90..5974f77 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/TriggerCooldownIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/TriggerCooldownIntegrationTest.java
@@ -38,6 +38,7 @@ import org.apache.solr.client.solrj.impl.CloudSolrClient;
 import org.apache.solr.cloud.SolrCloudTestCase;
 import org.apache.solr.common.params.AutoScalingParams;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.TimeSource;
 import org.apache.solr.core.SolrResourceLoader;
 import org.apache.solr.util.LogLevel;
 import org.junit.BeforeClass;
@@ -47,7 +48,6 @@ import org.slf4j.LoggerFactory;
 
 import static org.apache.solr.cloud.autoscaling.AutoScalingHandlerTest.createAutoScalingRequest;
 import static org.apache.solr.cloud.autoscaling.TriggerIntegrationTest.WAIT_FOR_DELTA_NANOS;
-import static org.apache.solr.cloud.autoscaling.TriggerIntegrationTest.timeSource;
 
 @LogLevel("org.apache.solr.cloud.autoscaling=DEBUG;org.apache.solr.client.solrj.cloud.autoscaling=DEBUG")
 public class TriggerCooldownIntegrationTest extends SolrCloudTestCase {
@@ -199,7 +199,7 @@ public class TriggerCooldownIntegrationTest extends SolrCloudTestCase
{
       try {
         if (triggerFired.compareAndSet(false, true)) {
           events.add(event);
-          long currentTimeNanos = timeSource.getTimeNs();
+          long currentTimeNanos = actionContext.getCloudManager().getTimeSource().getTimeNs();
           long eventTimeNanos = event.getEventTime();
           long waitForNanos = TimeUnit.NANOSECONDS.convert(waitForSeconds, TimeUnit.SECONDS)
- WAIT_FOR_DELTA_NANOS;
           if (currentTimeNanos - eventTimeNanos <= waitForNanos) {
@@ -224,17 +224,20 @@ public class TriggerCooldownIntegrationTest extends SolrCloudTestCase
{
   }
 
   public static class TestTriggerListener extends TriggerListenerBase {
+    private TimeSource timeSource;
     @Override
     public void configure(SolrResourceLoader loader, SolrCloudManager cloudManager, AutoScalingConfig.TriggerListenerConfig
config) throws TriggerValidationException {
       super.configure(loader, cloudManager, config);
       listenerCreated.countDown();
+      timeSource = cloudManager.getTimeSource();
     }
 
     @Override
     public synchronized void onEvent(TriggerEvent event, TriggerEventProcessorStage stage,
String actionName,
                                      ActionContext context, Throwable error, String message)
{
       List<CapturedEvent> lst = listenerEvents.computeIfAbsent(config.name, s ->
new ArrayList<>());
-      lst.add(new CapturedEvent(timeSource.getTimeNs(), context, config, stage, actionName,
event, message));
+      lst.add(new CapturedEvent(timeSource.getTimeNs(),
+                                context, config, stage, actionName, event, message));
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/46516b70/solr/core/src/test/org/apache/solr/cloud/autoscaling/TriggerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/TriggerIntegrationTest.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/TriggerIntegrationTest.java
index 2fe3b95..c0b03ee 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/TriggerIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/TriggerIntegrationTest.java
@@ -78,9 +78,6 @@ public class TriggerIntegrationTest extends SolrCloudTestCase {
   public static volatile long eventQueueActionWait = 5000;
   private static SolrCloudManager cloudManager;
 
-  // use the same time source as triggers use
-  static final TimeSource timeSource = TimeSource.CURRENT_TIME;
-
   static final long WAIT_FOR_DELTA_NANOS = TimeUnit.MILLISECONDS.toNanos(5);
 
   @BeforeClass
@@ -292,7 +289,7 @@ public class TriggerIntegrationTest extends SolrCloudTestCase {
         return;
       }
       try {
-        long currentTime = timeSource.getTimeNs();
+        long currentTime = actionContext.getCloudManager().getTimeSource().getTimeNs();
         if (lastActionExecutedAt.get() != 0)  {
           long minDiff = TimeUnit.MILLISECONDS.toNanos(throttlingDelayMs.get() - DELTA_MS);
           log.info("last action at " + lastActionExecutedAt.get() + " current time = " +
currentTime +
@@ -378,7 +375,7 @@ public class TriggerIntegrationTest extends SolrCloudTestCase {
       try {
         if (triggerFired.compareAndSet(false, true))  {
           events.add(event);
-          long currentTimeNanos = timeSource.getTimeNs();
+          long currentTimeNanos = actionContext.getCloudManager().getTimeSource().getTimeNs();
           long eventTimeNanos = event.getEventTime();
           long waitForNanos = TimeUnit.NANOSECONDS.convert(waitForSeconds, TimeUnit.SECONDS)
- WAIT_FOR_DELTA_NANOS;
           if (currentTimeNanos - eventTimeNanos <= waitForNanos) {
@@ -501,10 +498,12 @@ public class TriggerIntegrationTest extends SolrCloudTestCase {
   static boolean failDummyAction = false;
 
   public static class TestTriggerListener extends TriggerListenerBase {
+    private TimeSource timeSource;
     @Override
     public void configure(SolrResourceLoader loader, SolrCloudManager cloudManager, AutoScalingConfig.TriggerListenerConfig
config) throws TriggerValidationException {
       super.configure(loader, cloudManager, config);
       listenerCreated.countDown();
+      timeSource = cloudManager.getTimeSource();
     }
 
     @Override
@@ -512,6 +511,7 @@ public class TriggerIntegrationTest extends SolrCloudTestCase {
                                      ActionContext context, Throwable error, String message)
{
       List<CapturedEvent> lst = listenerEvents.computeIfAbsent(config.name, s ->
new ArrayList<>());
       CapturedEvent ev = new CapturedEvent(timeSource.getTimeNs(), context, config, stage,
actionName, event, message);
+                                           
       lst.add(ev);
       allListenerEvents.add(ev);
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/46516b70/solr/core/src/test/org/apache/solr/cloud/autoscaling/TriggerSetPropertiesIntegrationTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/TriggerSetPropertiesIntegrationTest.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/TriggerSetPropertiesIntegrationTest.java
index c59e60b..a86bb39 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/TriggerSetPropertiesIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/TriggerSetPropertiesIntegrationTest.java
@@ -48,7 +48,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.apache.solr.cloud.autoscaling.AutoScalingHandlerTest.createAutoScalingRequest;
-import static org.apache.solr.cloud.autoscaling.TriggerIntegrationTest.timeSource;
 
 @LogLevel("org.apache.solr.cloud.autoscaling=DEBUG;org.apache.solr.client.solrj.cloud.autoscaling=DEBUG")
 public class TriggerSetPropertiesIntegrationTest extends SolrCloudTestCase {
@@ -89,7 +88,7 @@ public class TriggerSetPropertiesIntegrationTest extends SolrCloudTestCase
{
         @Override
         public void run() {
           log.info("Running {} in {}", this.getName(), Thread.currentThread().getName());
-          timestamps.offer(timeSource.getTimeNs());
+          timestamps.offer(solrCloudManager.getTimeSource().getTimeNs());
         }
       };
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/46516b70/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimExecutePlanAction.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimExecutePlanAction.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimExecutePlanAction.java
index 07b02c9..1d36f14 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimExecutePlanAction.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/TestSimExecutePlanAction.java
@@ -61,11 +61,12 @@ import com.google.common.collect.Lists;
 public class TestSimExecutePlanAction extends SimSolrCloudTestCase {
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
+  private static final TimeSource SIM_TIME_SOURCE = TimeSource.get("simTime:50");
   private static final int NODE_COUNT = 2;
 
   @Before
   public void setupCluster() throws Exception {
-    configureCluster(NODE_COUNT, TimeSource.get("simTime:50"));
+    configureCluster(NODE_COUNT, SIM_TIME_SOURCE);
   }
 
   @After
@@ -138,7 +139,7 @@ public class TestSimExecutePlanAction extends SimSolrCloudTestCase {
       };
       List<CollectionAdminRequest.AsyncCollectionAdminRequest> operations = Lists.asList(moveReplica,
new CollectionAdminRequest.AsyncCollectionAdminRequest[]{mockRequest});
       NodeLostTrigger.NodeLostEvent nodeLostEvent = new NodeLostTrigger.NodeLostEvent(TriggerEventType.NODELOST,
-          "mock_trigger_name", Collections.singletonList(TimeSource.CURRENT_TIME.getTimeNs()),
+          "mock_trigger_name", Collections.singletonList(SIM_TIME_SOURCE.getTimeNs()),
           Collections.singletonList(sourceNodeName), CollectionParams.CollectionAction.MOVEREPLICA.toLower());
       ActionContext actionContext = new ActionContext(cluster, null,
           new HashMap<>(Collections.singletonMap("operations", operations)));


Mime
View raw message