Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 56BED200D33 for ; Wed, 8 Nov 2017 11:17:21 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 5531C160BE0; Wed, 8 Nov 2017 10:17:21 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9B777160BDA for ; Wed, 8 Nov 2017 11:17:20 +0100 (CET) Received: (qmail 79903 invoked by uid 500); 8 Nov 2017 10:17:19 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 79894 invoked by uid 99); 8 Nov 2017 10:17:19 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Nov 2017 10:17:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 967FCDFC27; Wed, 8 Nov 2017 10:17:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: shalin@apache.org To: commits@lucene.apache.org Message-Id: <51f1e2620a7245ebb2c8ec7cc1d45ee3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: lucene-solr:master: SOLR-11621: Fix spurious failures of TriggerIntegrationTest due to timing issues Date: Wed, 8 Nov 2017 10:17:19 +0000 (UTC) archived-at: Wed, 08 Nov 2017 10:17:21 -0000 Repository: lucene-solr Updated Branches: refs/heads/master 23fe16d3e -> 70d1d9411 SOLR-11621: Fix spurious failures of TriggerIntegrationTest due to timing issues Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/70d1d941 Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/70d1d941 Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/70d1d941 Branch: refs/heads/master Commit: 70d1d941107e60dd53d41c22b0c3a20e778c3874 Parents: 23fe16d Author: Shalin Shekhar Mangar Authored: Wed Nov 8 15:47:15 2017 +0530 Committer: Shalin Shekhar Mangar Committed: Wed Nov 8 15:47:15 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/70d1d941/solr/CHANGES.txt ---------------------------------------------------------------------- diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index c8d5ad1..343bd5b 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -144,6 +144,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/70d1d941/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 nodeRates = (Map)ev.event.getProperties().get("node"); assertNotNull("nodeRates", nodeRates); assertTrue(nodeRates.toString(), nodeRates.size() > 0);