Apache Solr open-source search software
SOLR-16104 Fix TestCoreDiscovery.testTooManyTransientCores (#1355)
David Smileyca81c81df82d
diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.javaindex 0c282618d82..cfab1f69c15 100644--- a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java+++ b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java@@ -29,6 +29,7 @@ import java.io.FileOutputStream;import java.io.InputStreamReader;import java.io.OutputStreamWriter;import java.io.Writer;+import java.lang.invoke.MethodHandles;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Path;@@ -45,8 +46,11 @@ import org.hamcrest.MatcherAssert;import org.junit.After;import org.junit.BeforeClass;import org.junit.Test;+import org.slf4j.Logger;+import org.slf4j.LoggerFactory;public class TestCoreDiscovery extends SolrTestCaseJ4 {+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());@BeforeClasspublic static void beforeClass() throws Exception {@@ -334,11 +338,19 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {// Just check that the proper number of cores are loaded since making the test depend on order// would be fragileRetryUtil.retryUntil(- "There should only be 3 cores loaded, coreLOS and two coreT? cores",- 5,+ "There should only be 3 cores loaded, coreLOS and two coreT# cores",+ 20,200,TimeUnit.MILLISECONDS,- () -> 3 == cc.getLoadedCoreNames().size());+ () -> {+ // See SOLR-16104 about this flakiness+ final var loadedCoreNames = cc.getLoadedCoreNames();+ if (3 == loadedCoreNames.size()) {+ return true;+ }+ log.warn("Waiting for 3 loaded cores but got: {}", loadedCoreNames);+ return false;+ });SolrCore c1 = cc.getCore("coreT1");assertNotNull("Core T1 should NOT BE NULL", c1);