lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject lucene-solr:branch_7x: SOLR-11621: Fix spurious failures of TriggerIntegrationTest due to timing issues
Date Wed, 08 Nov 2017 10:25:11 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x ddf8b57ad -> 5c88aaad7


SOLR-11621: Fix spurious failures of TriggerIntegrationTest due to timing issues

(cherry picked from commit 70d1d94)


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

Branch: refs/heads/branch_7x
Commit: 5c88aaad75496a208b84e6e0e89c99668c49f095
Parents: ddf8b57
Author: Shalin Shekhar Mangar <shalin@apache.org>
Authored: Wed Nov 8 15:47:15 2017 +0530
Committer: Shalin Shekhar Mangar <shalin@apache.org>
Committed: Wed Nov 8 15:55:07 2017 +0530

----------------------------------------------------------------------
 solr/CHANGES.txt                                      |  2 ++
 .../cloud/autoscaling/TriggerIntegrationTest.java     | 14 +++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5c88aaad/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index f92ccd7..5116911 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -128,6 +128,8 @@ Other Changes
 
 * SOLR-11618: Tone down verbosity of BackupManager logging (Varun Thacker)
 
+* SOLR-11621: Fix spurious failures of TriggerIntegrationTest due to timing issues. (shalin)
+
 ==================  7.1.0 ==================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5c88aaad/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 68c1491..e64f588 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
@@ -88,6 +88,8 @@ public class TriggerIntegrationTest extends SolrCloudTestCase {
   // use the same time source as triggers use
   private static final TimeSource timeSource = TimeSource.CURRENT_TIME;
 
+  private static final long WAIT_FOR_DELTA_NANOS = TimeUnit.MILLISECONDS.toNanos(5);
+
   @BeforeClass
   public static void setupCluster() throws Exception {
     configureCluster(2)
@@ -587,7 +589,10 @@ public class TriggerIntegrationTest extends SolrCloudTestCase {
       try {
         if (triggerFired.compareAndSet(false, true))  {
           events.add(event);
-          if (TimeUnit.MILLISECONDS.convert(timeSource.getTime() - event.getEventTime(),
TimeUnit.NANOSECONDS) <= TimeUnit.MILLISECONDS.convert(waitForSeconds, TimeUnit.SECONDS))
{
+          long currentTimeNanos = timeSource.getTime();
+          long eventTimeNanos = event.getEventTime();
+          long waitForNanos = TimeUnit.NANOSECONDS.convert(waitForSeconds, TimeUnit.SECONDS)
- WAIT_FOR_DELTA_NANOS;
+          if (currentTimeNanos - eventTimeNanos <= waitForNanos) {
             fail(event.source + " was fired before the configured waitFor period");
           }
           getTriggerFiredLatch().countDown();
@@ -1221,7 +1226,10 @@ public class TriggerIntegrationTest extends SolrCloudTestCase {
     public void process(TriggerEvent event, ActionContext context) throws Exception {
       try {
         events.add(event);
-        if (TimeUnit.MILLISECONDS.convert(timeSource.getTime() - event.getEventTime(), TimeUnit.NANOSECONDS)
<= TimeUnit.MILLISECONDS.convert(waitForSeconds, TimeUnit.SECONDS)) {
+        long currentTimeNanos = timeSource.getTime();
+        long eventTimeNanos = event.getEventTime();
+        long waitForNanos = TimeUnit.NANOSECONDS.convert(waitForSeconds, TimeUnit.SECONDS)
- WAIT_FOR_DELTA_NANOS;
+        if (currentTimeNanos - eventTimeNanos <= waitForNanos) {
           fail(event.source + " was fired before the configured waitFor period");
         }
         getTriggerFiredLatch().countDown();
@@ -1278,7 +1286,7 @@ public class TriggerIntegrationTest extends SolrCloudTestCase {
     TestEvent ev = listenerEvents.get("srt").get(0);
     long now = timeSource.getTime();
     // verify waitFor
-    assertTrue(TimeUnit.SECONDS.convert(waitForSeconds, TimeUnit.NANOSECONDS) < now -
ev.event.getEventTime());
+    assertTrue(TimeUnit.SECONDS.convert(waitForSeconds, TimeUnit.NANOSECONDS) - WAIT_FOR_DELTA_NANOS
<= now - ev.event.getEventTime());
     Map<String, Double> nodeRates = (Map<String, Double>)ev.event.getProperties().get("node");
     assertNotNull("nodeRates", nodeRates);
     assertTrue(nodeRates.toString(), nodeRates.size() > 0);


Mime
View raw message