This is an automated email from the ASF dual-hosted git repository. krisden pushed a commit to branch branch_9_0 in repository https://gitbox.apache.org/repos/asf/solr.git
commit 1d9d6d81fa4962d80162baf13f8f90cad7a3ffc5 Author: Mike Drob <[email protected]> AuthorDate: Fri Mar 18 09:19:13 2022 -0500 SOLR-16091 Wait for all nodes to register plugins in test (#747) (cherry picked from commit c10fac98cb1207786cfc5f651456207edbf25c00) --- .../org/apache/solr/api/ContainerPluginsRegistry.java | 2 -- .../core/src/java/org/apache/solr/api/V2HttpCall.java | 19 ++++++++++--------- .../org/apache/solr/handler/TestContainerPlugin.java | 18 +++++++----------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/api/ContainerPluginsRegistry.java b/solr/core/src/java/org/apache/solr/api/ContainerPluginsRegistry.java index 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, MapW refresh(); Phaser localPhaser = phaser; // volatile read if (localPhaser != null) { - assert localPhaser.getRegisteredParties() == 1; - // we should be the only ones registered, so this will advance phase each time localPhaser.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.java index 4680de629de..9ca12a8fc84 100644 --- a/solr/core/src/java/org/apache/solr/api/V2HttpCall.java +++ b/solr/core/src/java/org/apache/solr/api/V2HttpCall.java @@ -101,8 +101,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) { @@ -110,6 +110,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)) { @@ -140,13 +148,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); @@ -156,7 +157,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); } } else { Thread.currentThread().setContextClassLoader(core.getResourceLoader().getClassLoader()); diff --git a/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java b/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java index 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); } }
