Apache Solr open-source search software
SOLR-16091 Wait for all nodes to register plugins in test (#747)
Mike Drobc10fac98cb12
diff --git a/solr/core/src/java/org/apache/solr/api/ContainerPluginsRegistry.java b/solr/core/src/java/org/apache/solr/api/ContainerPluginsRegistry.javaindex 74affd64c8f..f8d2e64bf72 100644--- a/solr/core/src/java/org/apache/solr/api/ContainerPluginsRegistry.java+++ b/solr/core/src/java/org/apache/solr/api/ContainerPluginsRegistry.java@@ -87,8 +87,6 @@ public class ContainerPluginsRegistry implements ClusterPropertiesListener, MapWrefresh();Phaser localPhaser = phaser; // volatile readif (localPhaser != null) {- assert localPhaser.getRegisteredParties() == 1;- // we should be the only ones registered, so this will advance phase each timelocalPhaser.arrive();}return false;diff --git a/solr/core/src/java/org/apache/solr/api/V2HttpCall.java b/solr/core/src/java/org/apache/solr/api/V2HttpCall.javaindex a463ce30d06..b5b27df5807 100644--- a/solr/core/src/java/org/apache/solr/api/V2HttpCall.java+++ b/solr/core/src/java/org/apache/solr/api/V2HttpCall.java@@ -95,8 +95,8 @@ public class V2HttpCall extends HttpSolrCall {}boolean isCompositeApi = false;+ api = getApiInfo(cores.getRequestHandlers(), path, req.getMethod(), fullPath, parts);if (knownPrefixes.contains(prefix)) {- api = getApiInfo(cores.getRequestHandlers(), path, req.getMethod(), fullPath, parts);if (api != null) {isCompositeApi = api instanceof CompositeApi;if (!isCompositeApi) {@@ -104,6 +104,14 @@ public class V2HttpCall extends HttpSolrCall {return;}}+ } else { // custom plugin+ if (api != null) {+ initAdminRequest(path);+ return;+ }+ assert core == null;+ throw new SolrException(+ SolrException.ErrorCode.NOT_FOUND, "Could not load plugin at " + path);}if ("c".equals(prefix) || "collections".equals(prefix)) {@@ -134,13 +142,6 @@ public class V2HttpCall extends HttpSolrCall {} else if ("cores".equals(prefix)) {origCorename = pathSegments.get(1);core = cores.getCore(origCorename);- } else {- api = getApiInfo(cores.getRequestHandlers(), path, req.getMethod(), fullPath, parts);- if (api != null) {- // custom plugin- initAdminRequest(path);- return;- }}if (core == null) {log.error(">> path: '{}'", path);@@ -150,7 +151,7 @@ public class V2HttpCall extends HttpSolrCall {} else {throw new SolrException(SolrException.ErrorCode.NOT_FOUND,- "no core retrieved for core name: " + origCorename + ". Path : " + path);+ "no core retrieved for core name: " + origCorename + ". Path: " + path);}}diff --git a/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java b/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.javaindex 0769613ef18..1c7b07b2f0d 100644--- a/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java+++ b/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java@@ -47,7 +47,6 @@ import org.apache.solr.client.solrj.request.beans.Package;import org.apache.solr.client.solrj.request.beans.PluginMeta;import org.apache.solr.client.solrj.response.V2Response;import org.apache.solr.cloud.ClusterSingleton;-import org.apache.solr.cloud.MiniSolrCloudCluster;import org.apache.solr.cloud.SolrCloudTestCase;import org.apache.solr.common.annotation.JsonProperty;import org.apache.solr.common.util.ReflectMapWriter;@@ -78,7 +77,9 @@ public class TestContainerPlugin extends SolrCloudTestCase {int nodes = TEST_NIGHTLY ? 4 : 2;cluster = configureCluster(nodes).withJettyConfig(jetty -> jetty.enableV2(true)).configure();- cluster.getOpenOverseer().getCoreContainer().getContainerPluginsRegistry().setPhaser(phaser);+ for (JettySolrRunner jetty : cluster.getJettySolrRunners()) {+ jetty.getCoreContainer().getContainerPluginsRegistry().setPhaser(phaser);+ }}@After@@ -160,9 +161,8 @@ public class TestContainerPlugin extends SolrCloudTestCase {assertEquals(404, e.code());assertThat(e.getMetaData().findRecursive("error", "msg").toString(),- containsString("no core retrieved"));- // V2HttpCall will separately log the path and stack trace, probably could be fixed- assertEquals(2, errors.getCount());+ containsString("Could not load plugin at"));+ assertEquals(1, errors.getCount());}// test ClusterSingleton plugin@@ -254,7 +254,6 @@ public class TestContainerPlugin extends SolrCloudTestCase {addPkgVersionReq.process(cluster.getSolrClient());waitForAllNodesToSync(- cluster,"/cluster/package",Map.of(":result:packages:mypkg[0]:version",@@ -450,14 +449,11 @@ public class TestContainerPlugin extends SolrCloudTestCase {.build();}- public static void waitForAllNodesToSync(- MiniSolrCloudCluster cluster, String path, Map<String, Object> expected) throws Exception {+ public void waitForAllNodesToSync(String path, Map<String, Object> expected) throws Exception {for (JettySolrRunner jettySolrRunner : cluster.getJettySolrRunners()) {String baseUrl = jettySolrRunner.getBaseUrl().toString().replace("/solr", "/api");String url = baseUrl + path + "?wt=javabin";- // Allow multiple retries here because we need multiple nodes to update- // and our single phaser only ensures that one of them has reached expected state- TestDistribPackageStore.assertResponseValues(10, new Fetcher(url, jettySolrRunner), expected);+ TestDistribPackageStore.assertResponseValues(1, new Fetcher(url, jettySolrRunner), expected);}}