Apache Solr open-source search software
Fix instant resolution issue for ClusterEventProducerTest on Windows (#3310)
Houston Putman98988415d8dd
diff --git a/solr/core/src/test/org/apache/solr/cluster/events/ClusterEventProducerTest.java b/solr/core/src/test/org/apache/solr/cluster/events/ClusterEventProducerTest.javaindex e46266f2f80..adab07457b8 100644--- a/solr/core/src/test/org/apache/solr/cluster/events/ClusterEventProducerTest.java+++ b/solr/core/src/test/org/apache/solr/cluster/events/ClusterEventProducerTest.java@@ -30,6 +30,7 @@ import java.util.Map;import java.util.concurrent.CountDownLatch;import java.util.concurrent.Phaser;import java.util.concurrent.TimeUnit;+import org.apache.commons.exec.OS;import org.apache.solr.client.solrj.request.CollectionAdminRequest;import org.apache.solr.client.solrj.request.V2Request;import org.apache.solr.client.solrj.request.beans.PluginMeta;@@ -379,7 +380,13 @@ public class ClusterEventProducerTest extends SolrCloudTestCase {lastEvent.getType());// verify timestampInstant now = Instant.now();- assertTrue("timestamp of the event is in the future", now.isAfter(lastEvent.getTimestamp()));+ if (OS.isFamilyWindows()) {+ // JDK-8180466 - Windows does not have fine-grained Instant support, so accept equal times+ assertFalse(+ "timestamp of the event is in the future", now.isBefore(lastEvent.getTimestamp()));+ } else {+ assertTrue("timestamp of the event is in the future", now.isAfter(lastEvent.getTimestamp()));+ }assertEquals(collection, ((CollectionsAddedEvent) lastEvent).getCollectionNames().next());dummyEventLatch = new CountDownLatch(1);@@ -398,7 +405,13 @@ public class ClusterEventProducerTest extends SolrCloudTestCase {lastEvent.getType());// verify timestampnow = Instant.now();- assertTrue("timestamp of the event is in the future", now.isAfter(lastEvent.getTimestamp()));+ if (OS.isFamilyWindows()) {+ // JDK-8180466 - Windows does not have fine-grained Instant support, so accept equal times+ assertFalse(+ "timestamp of the event is in the future", now.isBefore(lastEvent.getTimestamp()));+ } else {+ assertTrue("timestamp of the event is in the future", now.isAfter(lastEvent.getTimestamp()));+ }assertEquals(collection, ((CollectionsRemovedEvent) lastEvent).getCollectionNames().next());// test changing the ClusterEventProducer plugin dynamically