diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 0745371a5ea..2c5b3ccbf8d 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -57,7 +57,9 @@ Other Changes * SOLR-16892: bin/solr create command supports both standalone and cloud modes, and deprecate create_core and create_collection commands. (Eric Pugh) -* SOLR-16822: Change meaning of -h from shorhand for -host to instead return help information for bin/solr start and restart commands. (Eric Pugh) +* SOLR-16822: Change meaning of -h from shorthand for -host to instead return help information for bin/solr start and restart commands. (Eric Pugh) + +* SOLR-16911: Establish /solr as the only host context supported by Solr, removing legacy ability to change this. Solr paths will only be either /solr or /api now. (Eric Pugh) ================== 9.4.0 ================== New Features diff --git a/solr/benchmark/src/java/org/apache/solr/bench/lifecycle/SolrStartup.java b/solr/benchmark/src/java/org/apache/solr/bench/lifecycle/SolrStartup.java index 6924d3d604d..d0bd64d56ba 100644 --- a/solr/benchmark/src/java/org/apache/solr/bench/lifecycle/SolrStartup.java +++ b/solr/benchmark/src/java/org/apache/solr/bench/lifecycle/SolrStartup.java @@ -76,7 +76,7 @@ public void bootstrapJettyServer() throws Exception { Path.of("src/resources/configs/minimal/conf"), defaultConfigsetDir.resolve("conf")); PathUtils.copyFileToDirectory(Path.of("src/resources/solr.xml"), tmpSolrHome); - solrRunner = new JettySolrRunner(tmpSolrHome.toString(), buildJettyConfig("/solr")); + solrRunner = new JettySolrRunner(tmpSolrHome.toString(), buildJettyConfig()); solrRunner.start(false); try (SolrClient client = solrRunner.newClient()) { for (int i = 0; i < NUM_CORES; i++) { @@ -113,8 +113,8 @@ public void destroyJettyServer() throws Exception { IOUtils.rm(tmpSolrHome); } - private static JettyConfig buildJettyConfig(String context) { - return JettyConfig.builder().setContext(context).stopAtShutdown(true).build(); + private static JettyConfig buildJettyConfig() { + return JettyConfig.builder().stopAtShutdown(true).build(); } } } diff --git a/solr/benchmark/src/resources/solr.xml b/solr/benchmark/src/resources/solr.xml index 439c8defdba..c7c6b44a362 100644 --- a/solr/benchmark/src/resources/solr.xml +++ b/solr/benchmark/src/resources/solr.xml @@ -38,13 +38,12 @@ 127.0.0.1 ${hostPort:8983} - ${hostContext:solr} ${solr.zkclienttimeout:60000} ${genericCoreNodeNames:true} ${leaderVoteWait:15000} - ${leaderConflictResolveWait:45000} + ${leaderConflictResolveWait:45000} ${distribUpdateConnTimeout:5000} ${distribUpdateSoTimeout:30000} - + diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java index d8c3703957c..c812b7767cb 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -33,7 +33,6 @@ import java.lang.reflect.Array; import java.net.InetAddress; import java.net.NetworkInterface; -import java.net.URLEncoder; import java.net.UnknownHostException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -324,17 +323,10 @@ public ZkController( this.genericCoreNodeNames = cloudConfig.getGenericCoreNodeNames(); - // be forgiving and strip this off leading/trailing slashes - // this allows us to support users specifying hostContext="/" in - // solr.xml to indicate the root context, instead of hostContext="" - // which means the default of "solr" - String localHostContext = trimLeadingAndTrailingSlashes(cloudConfig.getSolrHostContext()); - this.zkServerAddress = zkServerAddress; this.localHostPort = cloudConfig.getSolrHostPort(); this.hostName = normalizeHostName(cloudConfig.getHost()); - this.nodeName = - generateNodeName(this.hostName, Integer.toString(this.localHostPort), localHostContext); + this.nodeName = generateNodeName(this.hostName, Integer.toString(this.localHostPort)); MDCLoggingContext.setNode(nodeName); this.leaderVoteWait = cloudConfig.getLeaderVoteWait(); this.leaderConflictResolveWait = cloudConfig.getLeaderConflictResolveWait(); @@ -2364,35 +2356,11 @@ public LeaderElector getOverseerElector() { * * @param hostName - must not be null or the empty string * @param hostPort - must consist only of digits, must not be null or the empty string - * @param hostContext - should not begin or end with a slash (leading/trailin slashes will be - * ignored), must not be null, may be the empty string to denote the root context * @lucene.experimental * @see ZkStateReader#getBaseUrlForNodeName */ - static String generateNodeName( - final String hostName, final String hostPort, final String hostContext) { - return hostName - + ':' - + hostPort - + '_' - + URLEncoder.encode(trimLeadingAndTrailingSlashes(hostContext), StandardCharsets.UTF_8); - } - - /** - * Utility method for trimming and leading and/or trailing slashes from its input. May return the - * empty string. May return null if and only if the input is null. - */ - public static String trimLeadingAndTrailingSlashes(final String in) { - if (null == in) return in; - - String out = in; - if (out.startsWith("/")) { - out = out.substring(1); - } - if (out.endsWith("/")) { - out = out.substring(0, out.length() - 1); - } - return out; + static String generateNodeName(final String hostName, final String hostPort) { + return hostName + ':' + hostPort + '_' + "solr"; } public void rejoinOverseerElection(String electionNode, boolean joinAtHead) { diff --git a/solr/core/src/java/org/apache/solr/core/CloudConfig.java b/solr/core/src/java/org/apache/solr/core/CloudConfig.java index 4cb4026579b..5cc3e58e37e 100644 --- a/solr/core/src/java/org/apache/solr/core/CloudConfig.java +++ b/solr/core/src/java/org/apache/solr/core/CloudConfig.java @@ -28,8 +28,6 @@ public class CloudConfig { private final String hostName; - private final String hostContext; - private final boolean useGenericCoreNames; private final int leaderVoteWait; @@ -63,7 +61,6 @@ public class CloudConfig { int zkClientTimeout, int hostPort, String hostName, - String hostContext, boolean useGenericCoreNames, int leaderVoteWait, int leaderConflictResolveWait, @@ -82,7 +79,6 @@ public class CloudConfig { this.zkClientTimeout = zkClientTimeout; this.hostPort = hostPort; this.hostName = hostName; - this.hostContext = hostContext; this.useGenericCoreNames = useGenericCoreNames; this.leaderVoteWait = leaderVoteWait; this.leaderConflictResolveWait = leaderConflictResolveWait; @@ -107,10 +103,6 @@ public class CloudConfig { if (this.hostPort == -1) throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "'hostPort' must be configured to run SolrCloud"); - if (this.hostContext == null) - throw new SolrException( - SolrException.ErrorCode.SERVER_ERROR, - "'hostContext' must be configured to run SolrCloud"); } public String getZkHost() { @@ -125,10 +117,6 @@ public int getSolrHostPort() { return hostPort; } - public String getSolrHostContext() { - return hostContext; - } - public String getHost() { return hostName; } @@ -203,7 +191,6 @@ public static class CloudConfigBuilder { private int zkClientTimeout = Integer.getInteger("zkClientTimeout", DEFAULT_ZK_CLIENT_TIMEOUT); private final int hostPort; private final String hostName; - private final String hostContext; private boolean useGenericCoreNames; private int leaderVoteWait = DEFAULT_LEADER_VOTE_WAIT; private int leaderConflictResolveWait = DEFAULT_LEADER_CONFLICT_RESOLVE_WAIT; @@ -222,13 +209,8 @@ public static class CloudConfigBuilder { private String stateCompressorClass; public CloudConfigBuilder(String hostName, int hostPort) { - this(hostName, hostPort, null); - } - - public CloudConfigBuilder(String hostName, int hostPort, String hostContext) { this.hostName = hostName; this.hostPort = hostPort; - this.hostContext = hostContext; } public CloudConfigBuilder setZkHost(String zkHost) { @@ -323,7 +305,6 @@ public CloudConfig build() { zkClientTimeout, hostPort, hostName, - hostContext, useGenericCoreNames, leaderVoteWait, leaderConflictResolveWait, diff --git a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java index 676026c82ed..32f36091101 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java +++ b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java @@ -411,13 +411,6 @@ private static List separateStrings(String commaSeparatedString) { return Arrays.asList(COMMA_SEPARATED_PATTERN.split(commaSeparatedString)); } - private static Set separateStringsToSet(String commaSeparatedString) { - if (StrUtils.isNullOrEmpty(commaSeparatedString)) { - return Collections.emptySet(); - } - return Set.of(COMMA_SEPARATED_PATTERN.split(commaSeparatedString)); - } - private static Set separatePaths(String commaSeparatedString) { if (StrUtils.isNullOrEmpty(commaSeparatedString)) { return Collections.emptySet(); @@ -516,10 +509,15 @@ private static CloudConfig fillSolrCloudSection(NamedList nl, String def hostPort = parseInt("jetty.port", System.getProperty("jetty.port", "8983")); } String hostName = required("solrcloud", "host", removeValue(nl, "host")); - String hostContext = required("solrcloud", "hostContext", removeValue(nl, "hostContext")); - CloudConfig.CloudConfigBuilder builder = - new CloudConfig.CloudConfigBuilder(hostName, hostPort, hostContext); + // We no longer require or support the hostContext property, but legacy users may have it, so + // remove it from the list. + String hostContext = removeValue(nl, "hostContext"); + if (hostContext != null) { + log.warn("solr.xml hostContext -- hostContext is deprecated and ignored."); + } + + CloudConfig.CloudConfigBuilder builder = new CloudConfig.CloudConfigBuilder(hostName, hostPort); // set the defaultZkHost until/unless it's overridden in the "cloud section" (below)... builder.setZkHost(defaultZkHost); diff --git a/solr/core/src/test-files/solr/solr-50-all.xml b/solr/core/src/test-files/solr/solr-50-all.xml index 6849ed85d44..6803d2be0db 100644 --- a/solr/core/src/test-files/solr/solr-50-all.xml +++ b/solr/core/src/test-files/solr/solr-50-all.xml @@ -43,7 +43,6 @@ 37 55 testHost - testHostContext ${hostPort:44} 77 testZkHost diff --git a/solr/core/src/test-files/solr/solr-jmxreporter.xml b/solr/core/src/test-files/solr/solr-jmxreporter.xml index 92ba4121b55..1a2a8365a27 100644 --- a/solr/core/src/test-files/solr/solr-jmxreporter.xml +++ b/solr/core/src/test-files/solr/solr-jmxreporter.xml @@ -26,7 +26,6 @@ 127.0.0.1 ${hostPort:8983} - ${hostContext:solr} ${solr.zkclienttimeout:30000} ${genericCoreNodeNames:true} ${leaderVoteWait:10000} diff --git a/solr/core/src/test-files/solr/solr-stress-new.xml b/solr/core/src/test-files/solr/solr-stress-new.xml index 24b2719a118..434ef91067d 100644 --- a/solr/core/src/test-files/solr/solr-stress-new.xml +++ b/solr/core/src/test-files/solr/solr-stress-new.xml @@ -24,7 +24,6 @@ 127.0.0.1 8983 - ${hostContext:solr} diff --git a/solr/core/src/test-files/solr/solr-trackingshardhandler.xml b/solr/core/src/test-files/solr/solr-trackingshardhandler.xml index 491d6460151..201177105ad 100644 --- a/solr/core/src/test-files/solr/solr-trackingshardhandler.xml +++ b/solr/core/src/test-files/solr/solr-trackingshardhandler.xml @@ -27,7 +27,6 @@ 127.0.0.1 - ${hostContext:solr} ${hostPort:8983} ${solr.zkclienttimeout:30000} ${genericCoreNodeNames:true} diff --git a/solr/core/src/test-files/solr/solr.xml b/solr/core/src/test-files/solr/solr.xml index 439c8defdba..c7c6b44a362 100644 --- a/solr/core/src/test-files/solr/solr.xml +++ b/solr/core/src/test-files/solr/solr.xml @@ -38,13 +38,12 @@ 127.0.0.1 ${hostPort:8983} - ${hostContext:solr} ${solr.zkclienttimeout:60000} ${genericCoreNodeNames:true} ${leaderVoteWait:15000} - ${leaderConflictResolveWait:45000} + ${leaderConflictResolveWait:45000} ${distribUpdateConnTimeout:5000} ${distribUpdateSoTimeout:30000} - + diff --git a/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java b/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java index 9f77a41a92a..b55b368cb3f 100644 --- a/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java +++ b/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java @@ -75,7 +75,7 @@ public static void beforeTest() throws Exception { } jetty = new JettySolrRunner( - homeDir.toAbsolutePath().toString(), nodeProperties, buildJettyConfig("/solr")); + homeDir.toAbsolutePath().toString(), nodeProperties, buildJettyConfig()); jetty.start(); port = jetty.getLocalPort(); diff --git a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java index 78afd0751dc..d6f7da99eee 100644 --- a/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java +++ b/solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java @@ -123,7 +123,7 @@ public int execute(org.apache.commons.exec.CommandLine cmd) throws IOException { Files.readAllBytes(Paths.get(solrHomeDir).resolve("solr.xml")), Charset.defaultCharset()); - JettyConfig jettyConfig = JettyConfig.builder().setContext("/solr").setPort(port).build(); + JettyConfig jettyConfig = JettyConfig.builder().setPort(port).build(); try { if (solrCloudCluster == null) { Path logDir = createTempDir("solr_logs"); @@ -230,7 +230,7 @@ protected int startStandaloneSolr(String[] args) { System.setProperty("jetty.port", String.valueOf(port)); System.setProperty("solr.log.dir", createTempDir("solr_logs").toString()); - standaloneSolr = new JettySolrRunner(solrHomeDir.getAbsolutePath(), "/solr", port); + standaloneSolr = new JettySolrRunner(solrHomeDir.getAbsolutePath(), port); Thread bg = new Thread() { @Override diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.java index 17e0f02b68a..103efc7856c 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.java @@ -264,7 +264,7 @@ private SolrZkClient electNewOverseer(String address) "/admin/cores", reader, null, - new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983, "solr").build()); + new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983).build()); overseer.close(); ElectionContext ec = new OverseerElectionContext(zkClient, overseer, address.replace("/", "_")); diff --git a/solr/core/src/test/org/apache/solr/cloud/ClusterStateMockUtilTest.java b/solr/core/src/test/org/apache/solr/cloud/ClusterStateMockUtilTest.java index 601e92e89b9..3b4cc30ab4d 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ClusterStateMockUtilTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ClusterStateMockUtilTest.java @@ -49,8 +49,8 @@ public void testBuildClusterState_Simple() { assertNotNull(replica1); assertEquals("baseUrl1:8983_", replica1.getNodeName()); assertEquals("slice1_replica1", replica1.getCoreName()); - assertEquals("http://baseUrl1:8983", replica1.getBaseUrl()); - assertEquals("http://baseUrl1:8983/slice1_replica1/", replica1.getCoreUrl()); + assertEquals("http://baseUrl1:8983/solr", replica1.getBaseUrl()); + assertEquals("http://baseUrl1:8983/solr/slice1_replica1/", replica1.getCoreUrl()); assertEquals(Replica.State.ACTIVE, replica1.getState()); assertEquals(Replica.Type.NRT, replica1.getType()); } diff --git a/solr/core/src/test/org/apache/solr/cloud/ConcurrentCreateRoutedAliasTest.java b/solr/core/src/test/org/apache/solr/cloud/ConcurrentCreateRoutedAliasTest.java index 3046181c193..7505c32a7bc 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ConcurrentCreateRoutedAliasTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ConcurrentCreateRoutedAliasTest.java @@ -44,7 +44,7 @@ public class ConcurrentCreateRoutedAliasTest extends SolrTestCaseJ4 { @Before public void setUp() throws Exception { super.setUp(); - solrCluster = new MiniSolrCloudCluster(4, createTempDir(), buildJettyConfig("/solr")); + solrCluster = new MiniSolrCloudCluster(4, createTempDir(), buildJettyConfig()); } @Override diff --git a/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java b/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java index 12affe3b0da..e372e355724 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java @@ -51,7 +51,6 @@ public class CreateCollectionCleanupTest extends SolrCloudTestCase { + " \n" + " 127.0.0.1\n" + " ${hostPort:8983}\n" - + " ${hostContext:solr}\n" + " ${solr.zkclienttimeout:30000}\n" + " ${genericCoreNodeNames:true}\n" + " 10000\n" diff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java index 3fb714faa92..44e226afdf0 100644 --- a/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java @@ -258,8 +258,8 @@ public void testCancelElection() throws Exception { Thread.sleep(1000); String urlScheme = zkStateReader.getClusterProperty(URL_SCHEME, "http"); - String url1 = Utils.getBaseUrlForNodeName("127.0.0.1:80_solr/1", urlScheme) + "/"; - String url2 = Utils.getBaseUrlForNodeName("127.0.0.1:80_solr/2", urlScheme) + "/"; + String url1 = Utils.getBaseUrlForNodeName("127.0.0.1:80_solr", urlScheme) + "/1/"; + String url2 = Utils.getBaseUrlForNodeName("127.0.0.1:80_solr", urlScheme) + "/2/"; assertEquals("original leader was not registered", url1, getLeaderUrl("collection2", "slice1")); diff --git a/solr/core/src/test/org/apache/solr/cloud/NodeMutatorTest.java b/solr/core/src/test/org/apache/solr/cloud/NodeMutatorTest.java index 0719f5beea6..965bab24c0f 100644 --- a/solr/core/src/test/org/apache/solr/cloud/NodeMutatorTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/NodeMutatorTest.java @@ -31,13 +31,13 @@ public class NodeMutatorTest extends SolrTestCaseJ4Test { private static final String NODE3 = "baseUrl3:8985_"; - private static final String NODE3_URL = "http://baseUrl3:8985"; + private static final String NODE3_URL = "http://baseUrl3:8985/solr"; private static final String NODE2 = "baseUrl2:8984_"; - private static final String NODE2_URL = "http://baseUrl2:8984"; + private static final String NODE2_URL = "http://baseUrl2:8984/solr"; private static final String NODE1 = "baseUrl1:8983_"; - private static final String NODE1_URL = "http://baseUrl1:8983"; + private static final String NODE1_URL = "http://baseUrl1:8983/solr"; @Test public void downNodeReportsAllImpactedCollectionsAndNothingElse() { diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java index 146f7d722a5..1e7c8de5124 100644 --- a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java @@ -1025,7 +1025,7 @@ public void testOverseerStatsReset() throws Exception { "/admin/cores", reader, zkController, - new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983, "") + new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983) .setUseDistributedClusterStateUpdates(false) .setUseDistributedCollectionConfigSetExecution(false) .build()); @@ -1863,7 +1863,7 @@ private SolrZkClient electNewOverseer(String address) "/admin/cores", reader, zkController, - new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983, "") + new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983) .setUseDistributedClusterStateUpdates(false) .build()); overseers.add(overseer); diff --git a/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java b/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java index fbc54b8831c..327561b14ff 100644 --- a/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/SSLMigrationTest.java @@ -69,7 +69,6 @@ public void testMigrateSSL(SSLTestConfig sslConfig) throws Exception { JettySolrRunner runner = jettys.get(i); JettyConfig config = JettyConfig.builder() - .setContext(context) .setPort(runner.getLocalPort()) .stopAtShutdown(false) .withServlets(getExtraServlets()) diff --git a/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java b/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java index fec4dfab74b..868cd91e62a 100644 --- a/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java @@ -183,7 +183,6 @@ public void testOnDiskOnly() throws Exception { + " " + " 127.0.0.1" + " 9045" - + " ${hostContext:solr}" + " " + " " + " ${socketTimeout:120000}" diff --git a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIExclusivity.java b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIExclusivity.java index 7e1e48bd568..2920e4ece52 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIExclusivity.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIExclusivity.java @@ -49,7 +49,7 @@ public class TestConfigSetsAPIExclusivity extends SolrTestCaseJ4 { @Before public void setUp() throws Exception { super.setUp(); - solrCluster = new MiniSolrCloudCluster(1, createTempDir(), buildJettyConfig("/solr")); + solrCluster = new MiniSolrCloudCluster(1, createTempDir(), buildJettyConfig()); } @Override diff --git a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIZkFailure.java b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIZkFailure.java index bbf0138a713..2ba85cfa437 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIZkFailure.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIZkFailure.java @@ -86,7 +86,7 @@ public void setUp() throws Exception { 1, testDir, MiniSolrCloudCluster.DEFAULT_CLOUD_SOLR_XML, - buildJettyConfig("/solr"), + buildJettyConfig(), zkTestServer, true); } diff --git a/solr/core/src/test/org/apache/solr/cloud/TestLeaderElectionZkExpiry.java b/solr/core/src/test/org/apache/solr/cloud/TestLeaderElectionZkExpiry.java index 884978298cc..28b05444ca2 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestLeaderElectionZkExpiry.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestLeaderElectionZkExpiry.java @@ -52,7 +52,7 @@ public void testLeaderElectionWithZkExpiry() throws Exception { server.run(); CloudConfig cloudConfig = - new CloudConfig.CloudConfigBuilder("dummy.host.com", 8984, "solr") + new CloudConfig.CloudConfigBuilder("dummy.host.com", 8984) .setLeaderConflictResolveWait(180000) .setLeaderVoteWait(180000) .build(); diff --git a/solr/core/src/test/org/apache/solr/cloud/TestRequestForwarding.java b/solr/core/src/test/org/apache/solr/cloud/TestRequestForwarding.java index 7a719262fe1..06fca2452c7 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestRequestForwarding.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestRequestForwarding.java @@ -34,7 +34,7 @@ public void setUp() throws Exception { super.setUp(); System.setProperty("solr.test.sys.prop1", "propone"); System.setProperty("solr.test.sys.prop2", "proptwo"); - solrCluster = new MiniSolrCloudCluster(3, createTempDir(), buildJettyConfig("/solr")); + solrCluster = new MiniSolrCloudCluster(3, createTempDir(), buildJettyConfig()); solrCluster.uploadConfigSet(TEST_PATH().resolve("collection1/conf"), "conf1"); } diff --git a/solr/core/src/test/org/apache/solr/cloud/TestSSLRandomization.java b/solr/core/src/test/org/apache/solr/cloud/TestSSLRandomization.java index 0c40d8a9a88..1cb1c7692ba 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestSSLRandomization.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestSSLRandomization.java @@ -43,9 +43,9 @@ public void testRandomizedSslAndClientAuth() throws Exception { } public void testBaseUrl() { - String url = buildUrl(6666, "/foo"); + String url = buildUrl(6666); assertEquals( - sslConfig.isSSLMode() ? "https://127.0.0.1:6666/foo" : "http://127.0.0.1:6666/foo", url); + sslConfig.isSSLMode() ? "https://127.0.0.1:6666/solr" : "http://127.0.0.1:6666/solr", url); } /** Used by {@link #testSSLRandomizer} */ diff --git a/solr/core/src/test/org/apache/solr/cloud/TestWaitForStateWithJettyShutdowns.java b/solr/core/src/test/org/apache/solr/cloud/TestWaitForStateWithJettyShutdowns.java index 66296cb2440..caf3467cc89 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestWaitForStateWithJettyShutdowns.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestWaitForStateWithJettyShutdowns.java @@ -42,7 +42,7 @@ public class TestWaitForStateWithJettyShutdowns extends SolrTestCaseJ4 { public void testWaitForStateAfterShutDown() throws Exception { final String col_name = "test_col"; final MiniSolrCloudCluster cluster = - new MiniSolrCloudCluster(1, createTempDir(), buildJettyConfig("/solr")); + new MiniSolrCloudCluster(1, createTempDir(), buildJettyConfig()); try { log.info("Create our collection"); CollectionAdminRequest.createCollection(col_name, "_default", 1, 1) @@ -76,7 +76,7 @@ public void testWaitForStateBeforeShutDown() throws Exception { ExecutorUtil.newMDCAwareFixedThreadPool( 1, new SolrNamedThreadFactory("background_executor")); final MiniSolrCloudCluster cluster = - new MiniSolrCloudCluster(1, createTempDir(), buildJettyConfig("/solr")); + new MiniSolrCloudCluster(1, createTempDir(), buildJettyConfig()); try { log.info("Create our collection"); CollectionAdminRequest.createCollection(col_name, "_default", 1, 1) diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java index 0f0b4ef28cf..f1df3febab4 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java @@ -73,24 +73,11 @@ public static void afterClass() {} public void testNodeNameUrlConversion() throws Exception { // nodeName from parts - assertEquals("localhost:8888_solr", ZkController.generateNodeName("localhost", "8888", "solr")); - assertEquals( - "localhost:8888_solr", ZkController.generateNodeName("localhost", "8888", "/solr")); - assertEquals( - "localhost:8888_solr", ZkController.generateNodeName("localhost", "8888", "/solr/")); + assertEquals("localhost:8888_solr", ZkController.generateNodeName("localhost", "8888")); // root context - assertEquals("localhost:8888_", ZkController.generateNodeName("localhost", "8888", "")); - assertEquals("localhost:8888_", ZkController.generateNodeName("localhost", "8888", "/")); + assertEquals("localhost:8888_solr", ZkController.generateNodeName("localhost", "8888")); // subdir - assertEquals( - "foo-bar:77_solr%2Fsub_dir", - ZkController.generateNodeName("foo-bar", "77", "solr/sub_dir")); - assertEquals( - "foo-bar:77_solr%2Fsub_dir", - ZkController.generateNodeName("foo-bar", "77", "/solr/sub_dir")); - assertEquals( - "foo-bar:77_solr%2Fsub_dir", - ZkController.generateNodeName("foo-bar", "77", "/solr/sub_dir/")); + assertEquals("foo-bar:77_solr", ZkController.generateNodeName("foo-bar", "77")); // setup a SolrZkClient to do some getBaseUrlForNodeName testing Path zkDir = createTempDir("zkData"); @@ -110,56 +97,35 @@ public void testNodeNameUrlConversion() throws Exception { try (ZkStateReader zkStateReader = new ZkStateReader(client)) { zkStateReader.createClusterStateWatchersAndUpdate(); - // getBaseUrlForNodeName - assertEquals( - "http://zzz.xxx:1234/solr", zkStateReader.getBaseUrlForNodeName("zzz.xxx:1234_solr")); assertEquals( "http://zzz_xxx:1234/solr", zkStateReader.getBaseUrlForNodeName("zzz_xxx:1234_solr")); - assertEquals("http://xxx:99", zkStateReader.getBaseUrlForNodeName("xxx:99_")); + + // test that no matter what you pass in, you end up with /solr. + assertEquals("http://xxx:99/solr", zkStateReader.getBaseUrlForNodeName("xxx:99_")); + // assertEquals("http://xxx:99/solr", result); assertEquals( - "http://foo-bar.baz.org:9999/some_dir", + "http://foo-bar.baz.org:9999/solr", zkStateReader.getBaseUrlForNodeName("foo-bar.baz.org:9999_some_dir")); assertEquals( - "http://foo-bar.baz.org:9999/solr/sub_dir", + "http://foo-bar.baz.org:9999/solr", zkStateReader.getBaseUrlForNodeName("foo-bar.baz.org:9999_solr%2Fsub_dir")); // generateNodeName + getBaseUrlForNodeName assertEquals( "http://foo:9876/solr", - zkStateReader.getBaseUrlForNodeName( - ZkController.generateNodeName("foo", "9876", "solr"))); - assertEquals( - "http://foo:9876/solr", - zkStateReader.getBaseUrlForNodeName( - ZkController.generateNodeName("foo", "9876", "/solr"))); - assertEquals( - "http://foo:9876/solr", - zkStateReader.getBaseUrlForNodeName( - ZkController.generateNodeName("foo", "9876", "/solr/"))); - assertEquals( - "http://foo.bar.com:9876/solr/sub_dir", - zkStateReader.getBaseUrlForNodeName( - ZkController.generateNodeName("foo.bar.com", "9876", "solr/sub_dir"))); - assertEquals( - "http://foo.bar.com:9876/solr/sub_dir", - zkStateReader.getBaseUrlForNodeName( - ZkController.generateNodeName("foo.bar.com", "9876", "/solr/sub_dir/"))); - assertEquals( - "http://foo-bar:9876", - zkStateReader.getBaseUrlForNodeName( - ZkController.generateNodeName("foo-bar", "9876", ""))); + zkStateReader.getBaseUrlForNodeName(ZkController.generateNodeName("foo", "9876"))); assertEquals( - "http://foo-bar:9876", + "http://foo.bar.com:9876/solr", zkStateReader.getBaseUrlForNodeName( - ZkController.generateNodeName("foo-bar", "9876", "/"))); + ZkController.generateNodeName("foo.bar.com", "9876"))); assertEquals( - "http://foo-bar.com:80/some_dir", + "http://foo-bar:9876/solr", zkStateReader.getBaseUrlForNodeName( - ZkController.generateNodeName("foo-bar.com", "80", "some_dir"))); + ZkController.generateNodeName("foo-bar", "9876"))); assertEquals( - "http://foo-bar.com:80/some_dir", + "http://foo-bar.com:80/solr", zkStateReader.getBaseUrlForNodeName( - ZkController.generateNodeName("foo-bar.com", "80", "/some_dir"))); + ZkController.generateNodeName("foo-bar.com", "80"))); } ClusterProperties cp = new ClusterProperties(client); @@ -176,9 +142,9 @@ public void testNodeNameUrlConversion() throws Exception { zkStateReader.getBaseUrlForNodeName("zzz.xxx:1234_solr")); assertEquals( - "https://foo-bar.com:80/some_dir", + "https://foo-bar.com:80/solr", zkStateReader.getBaseUrlForNodeName( - ZkController.generateNodeName("foo-bar.com", "80", "/some_dir"))); + ZkController.generateNodeName("foo-bar.com", "80"))); } } } finally { @@ -197,8 +163,7 @@ public void testGetHostName() throws Exception { ZkController zkController = null; try { - CloudConfig cloudConfig = - new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983, "solr").build(); + CloudConfig cloudConfig = new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983).build(); zkController = new ZkController(cc, server.getZkAddress(), TIMEOUT, cloudConfig, () -> null); } catch (IllegalArgumentException e) { @@ -258,8 +223,7 @@ public List getCoreDescriptors() { ZkController zkController = null; try { - CloudConfig cloudConfig = - new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983, "solr").build(); + CloudConfig cloudConfig = new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983).build(); zkController = new ZkController(cc, server.getZkAddress(), TIMEOUT, cloudConfig, () -> null); zkControllerRef.set(zkController); @@ -365,8 +329,7 @@ public void testTouchConfDir() throws Exception { .build()) { CoreContainer cc = getCoreContainer(); try { - CloudConfig cloudConfig = - new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983, "solr").build(); + CloudConfig cloudConfig = new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983).build(); try (ZkController zkController = new ZkController(cc, server.getZkAddress(), TIMEOUT, cloudConfig, () -> null)) { final Path dir = createTempDir(); @@ -447,8 +410,7 @@ public void testCheckNoOldClusterstate() throws Exception { cc, server.getZkAddress(), TIMEOUT, - new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983 + index, "solr") - .build(), + new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983 + index).build(), () -> null); } catch (Exception e) { exception.compareAndSet(null, e); diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/ConcurrentDeleteAndCreateCollectionTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/ConcurrentDeleteAndCreateCollectionTest.java index 51678f06d5f..98937a4395b 100644 --- a/solr/core/src/test/org/apache/solr/cloud/api/collections/ConcurrentDeleteAndCreateCollectionTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/ConcurrentDeleteAndCreateCollectionTest.java @@ -46,7 +46,7 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 { @Before public void setUp() throws Exception { super.setUp(); - solrCluster = new MiniSolrCloudCluster(1, createTempDir(), buildJettyConfig("/solr")); + solrCluster = new MiniSolrCloudCluster(1, createTempDir(), buildJettyConfig()); } @Override diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/LocalFSCloudIncrementalBackupTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/LocalFSCloudIncrementalBackupTest.java index 1c1f3536b76..c6e52ffeab6 100644 --- a/solr/core/src/test/org/apache/solr/cloud/api/collections/LocalFSCloudIncrementalBackupTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/LocalFSCloudIncrementalBackupTest.java @@ -40,7 +40,6 @@ public class LocalFSCloudIncrementalBackupTest extends AbstractIncrementalBackup + " \n" + " 127.0.0.1\n" + " ${hostPort:8983}\n" - + " ${hostContext:solr}\n" + " ${solr.zkclienttimeout:30000}\n" + " ${genericCoreNodeNames:true}\n" + " 10000\n" diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java index a7b2a65918d..44cd51b6c41 100644 --- a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java +++ b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java @@ -630,7 +630,6 @@ public void testSolrHomeNotReadable() throws Exception { + Paths.get(TEST_HOME()).resolve("configsets") + "" + " " - + "solrprop " + "20 " + "222.333.444.555 " + "6000 " diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java b/solr/core/src/test/org/apache/solr/core/TestSolrXml.java index 9cdc5b1a253..46e6c6ba9b9 100644 --- a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java +++ b/solr/core/src/test/org/apache/solr/core/TestSolrXml.java @@ -97,7 +97,6 @@ public void testAllInfoPresent() throws IOException { assertEquals("max update conn", 3, ucfg.getMaxUpdateConnections()); assertEquals("max update conn/host", 37, ucfg.getMaxUpdateConnectionsPerHost()); assertEquals("host", "testHost", ccfg.getHost()); - assertEquals("zk host context", "testHostContext", ccfg.getSolrHostContext()); assertEquals("solr host port", 44, ccfg.getSolrHostPort()); assertEquals("leader vote wait", 55, ccfg.getLeaderVoteWait()); assertEquals("logging class", "testLoggingClass", cfg.getLogWatcherConfig().getLoggingClass()); @@ -160,7 +159,6 @@ public void testExplicitNullGivesDefaults() { + "" + "host" + "0" - + "solr" + "" + ""; @@ -317,7 +315,7 @@ public void testFailAtConfigParseTimeWhenIntTypeIsExpectedAndBoolTypeIsGiven() { public void testFailAtConfigParseTimeWhenUnrecognizedSolrCloudOptionWasFound() { String solrXml = - "host8983true"; + "host8983true"; SolrException thrown = assertThrows(SolrException.class, () -> SolrXmlConfig.fromString(solrHome, solrXml)); @@ -448,12 +446,10 @@ public void testCloudConfigRequiresHost() { assertEquals("solrcloud section missing required entry 'host'", thrown.getMessage()); } - public void testCloudConfigRequiresHostContext() { + public void testCloudConfigContinuesToWorkIfHostContextDefined() { String solrXml = - "host8983"; - SolrException thrown = - assertThrows(SolrException.class, () -> SolrXmlConfig.fromString(solrHome, solrXml)); - assertEquals("solrcloud section missing required entry 'hostContext'", thrown.getMessage()); + "hostlegacyHostContent8983"; + SolrXmlConfig.fromString(solrHome, solrXml); } public void testMultiBackupSectionError() { diff --git a/solr/core/src/test/org/apache/solr/handler/PingRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/PingRequestHandlerTest.java index 859a07e3e15..fc6e8fd19a2 100644 --- a/solr/core/src/test/org/apache/solr/handler/PingRequestHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/PingRequestHandlerTest.java @@ -169,7 +169,7 @@ public void testBadActionRaisesException() { public void testPingInClusterWithNoHealthCheck() throws Exception { MiniSolrCloudCluster miniCluster = - new MiniSolrCloudCluster(NUM_SERVERS, createTempDir(), buildJettyConfig("/solr")); + new MiniSolrCloudCluster(NUM_SERVERS, createTempDir(), buildJettyConfig()); final CloudSolrClient cloudSolrClient = miniCluster.getSolrClient(); diff --git a/solr/core/src/test/org/apache/solr/handler/ReplicationTestHelper.java b/solr/core/src/test/org/apache/solr/handler/ReplicationTestHelper.java index 83b60838b06..bb6a06c16cd 100644 --- a/solr/core/src/test/org/apache/solr/handler/ReplicationTestHelper.java +++ b/solr/core/src/test/org/apache/solr/handler/ReplicationTestHelper.java @@ -58,7 +58,7 @@ public static JettySolrRunner createAndStartJetty(SolrInstance instance) throws new File(instance.getHomeDir(), "solr.xml")); Properties nodeProperties = new Properties(); nodeProperties.setProperty("solr.data.dir", instance.getDataDir()); - JettyConfig jettyConfig = JettyConfig.builder().setContext("/solr").setPort(0).build(); + JettyConfig jettyConfig = JettyConfig.builder().setPort(0).build(); JettySolrRunner jetty = new JettySolrRunner(instance.getHomeDir(), nodeProperties, jettyConfig); jetty.start(); return jetty; diff --git a/solr/core/src/test/org/apache/solr/handler/TestHealthCheckHandlerLegacyMode.java b/solr/core/src/test/org/apache/solr/handler/TestHealthCheckHandlerLegacyMode.java index 1d3ecfeed62..c5a4ba0be25 100644 --- a/solr/core/src/test/org/apache/solr/handler/TestHealthCheckHandlerLegacyMode.java +++ b/solr/core/src/test/org/apache/solr/handler/TestHealthCheckHandlerLegacyMode.java @@ -46,8 +46,6 @@ public class TestHealthCheckHandlerLegacyMode extends SolrTestCaseJ4 { SolrClient leaderClient, followerClient; ReplicationTestHelper.SolrInstance leader = null, follower = null; - private static final String context = "/solr"; - @Override @Before public void setUp() throws Exception { @@ -62,9 +60,9 @@ public void setUp() throws Exception { leaderJetty = ReplicationTestHelper.createAndStartJetty(leader); leaderClient = ReplicationTestHelper.createNewSolrClient( - buildUrl(leaderJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME); + buildUrl(leaderJetty.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME); leaderClientHealthCheck = - ReplicationTestHelper.createNewSolrClient(buildUrl(leaderJetty.getLocalPort(), context)); + ReplicationTestHelper.createNewSolrClient(buildUrl(leaderJetty.getLocalPort())); follower = new SolrInstance( @@ -73,9 +71,9 @@ public void setUp() throws Exception { followerJetty = createAndStartJetty(follower); followerClient = ReplicationTestHelper.createNewSolrClient( - buildUrl(followerJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME); + buildUrl(followerJetty.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME); followerClientHealthCheck = - ReplicationTestHelper.createNewSolrClient(buildUrl(followerJetty.getLocalPort(), context)); + ReplicationTestHelper.createNewSolrClient(buildUrl(followerJetty.getLocalPort())); System.setProperty("solr.indexfetcher.sotimeout2", "45000"); } @@ -130,8 +128,7 @@ public void doTestHealthCheckWithReplication() throws Exception { // stop replication so that the follower doesn't pull the index invokeReplicationCommand( - buildUrl(followerJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME, - "disablepoll"); + buildUrl(followerJetty.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME, "disablepoll"); // create multiple commits int docsAdded = 0; @@ -236,8 +233,8 @@ public void doTestHealthCheckWithReplication() throws Exception { public static void pullFromTo(JettySolrRunner srcSolr, JettySolrRunner destSolr) throws IOException { - String srcUrl = buildUrl(srcSolr.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME; - String destUrl = buildUrl(destSolr.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME; + String srcUrl = buildUrl(srcSolr.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME; + String destUrl = buildUrl(destSolr.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME; ReplicationTestHelper.pullFromTo(srcUrl, destUrl); } diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java index f01fad15f6e..8fc56376c2a 100644 --- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java +++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java @@ -98,8 +98,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 { SolrClient leaderClient, followerClient, repeaterClient; SolrInstance leader = null, follower = null, repeater = null; - static String context = "/solr"; - // number of docs to index... decremented for each test case to tell if we accidentally reuse // index from previous test method static int nDocs = 500; @@ -125,7 +123,7 @@ public void setUp() throws Exception { leaderJetty = createAndStartJetty(leader); leaderClient = ReplicationTestHelper.createNewSolrClient( - buildUrl(leaderJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME); + buildUrl(leaderJetty.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME); follower = new SolrInstance( @@ -134,7 +132,7 @@ public void setUp() throws Exception { followerJetty = createAndStartJetty(follower); followerClient = ReplicationTestHelper.createNewSolrClient( - buildUrl(followerJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME); + buildUrl(followerJetty.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME); System.setProperty("solr.indexfetcher.sotimeout2", "45000"); } @@ -302,10 +300,10 @@ public void doTestDetails() throws Exception { leaderClient.close(); leaderClient = ReplicationTestHelper.createNewSolrClient( - buildUrl(leaderJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME); + buildUrl(leaderJetty.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME); followerClient = ReplicationTestHelper.createNewSolrClient( - buildUrl(followerJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME); + buildUrl(followerJetty.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME); clearIndexWithReplication(); { @@ -375,7 +373,7 @@ public void doTestDetails() throws Exception { repeaterJetty = createAndStartJetty(repeater); repeaterClient = ReplicationTestHelper.createNewSolrClient( - buildUrl(repeaterJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME); + buildUrl(repeaterJetty.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME); NamedList details = getDetails(repeaterClient); @@ -409,7 +407,7 @@ public void testLegacyConfiguration() throws Exception { instanceJetty = createAndStartJetty(solrInstance); client = ReplicationTestHelper.createNewSolrClient( - buildUrl(instanceJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME); + buildUrl(instanceJetty.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME); NamedList details = getDetails(client); @@ -812,7 +810,7 @@ public void doTestIndexFetchWithLeaderUrl() throws Exception { followerClient.close(); followerClient = ReplicationTestHelper.createNewSolrClient( - buildUrl(followerJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME); + buildUrl(followerJetty.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME); leaderClient.deleteByQuery("*:*"); followerClient.deleteByQuery("*:*"); @@ -1815,8 +1813,4 @@ private void assertReplicationResponseSucceeded(NamedList response) { assertNotNull("Expected replication response to have 'status' field", response.get("status")); assertEquals("OK", response.get("status")); } - - public static String buildUrl(int port) { - return buildUrl(port, context); - } } diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.java index aff53aa66e3..a85416727e6 100644 --- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.java +++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.java @@ -64,8 +64,6 @@ public class TestReplicationHandlerBackup extends SolrJettyTestBase { private static final String CONF_DIR = "solr" + File.separator + "collection1" + File.separator + "conf" + File.separator; - private static String context = "/solr"; - boolean addNumberToKeepInRequest = true; String backupKeepParamName = ReplicationHandler.NUMBER_BACKUPS_TO_KEEP_REQUEST_PARAM; private static long docsSeed; // see indexDocs() @@ -78,14 +76,14 @@ private static JettySolrRunner createAndStartJetty(ReplicationTestHelper.SolrIns new File(instance.getHomeDir(), "solr.xml")); Properties nodeProperties = new Properties(); nodeProperties.setProperty("solr.data.dir", instance.getDataDir()); - JettyConfig jettyConfig = JettyConfig.builder().setContext("/solr").setPort(0).build(); + JettyConfig jettyConfig = JettyConfig.builder().setPort(0).build(); JettySolrRunner jetty = new JettySolrRunner(instance.getHomeDir(), nodeProperties, jettyConfig); jetty.start(); return jetty; } private static SolrClient createNewSolrClient(int port) { - final String baseUrl = buildUrl(port, context); + final String baseUrl = buildUrl(port); return new HttpSolrClient.Builder(baseUrl) .withConnectionTimeout(15000, TimeUnit.MILLISECONDS) .withSocketTimeout(60000, TimeUnit.MILLISECONDS) @@ -255,7 +253,7 @@ private void testDeleteNamedBackup(String backupNames[]) throws Exception { public static void runBackupCommand(JettySolrRunner leaderJetty, String cmd, String params) throws IOException { String leaderUrl = - buildUrl(leaderJetty.getLocalPort(), context) + buildUrl(leaderJetty.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME + ReplicationHandler.PATH diff --git a/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java b/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java index 553bf5912d3..b46bbfb6ff6 100644 --- a/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java +++ b/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java @@ -52,7 +52,6 @@ public class TestRestoreCore extends SolrJettyTestBase { private static final String CONF_DIR = "solr" + File.separator + DEFAULT_TEST_CORENAME + File.separator + "conf" + File.separator; - private static String context = "/solr"; private static long docsSeed; // see indexDocs() private static JettySolrRunner createAndStartJetty(ReplicationTestHelper.SolrInstance instance) @@ -62,7 +61,7 @@ private static JettySolrRunner createAndStartJetty(ReplicationTestHelper.SolrIns new File(instance.getHomeDir(), "solr.xml")); Properties nodeProperties = new Properties(); nodeProperties.setProperty("solr.data.dir", instance.getDataDir()); - JettyConfig jettyConfig = JettyConfig.builder().setContext("/solr").setPort(0).build(); + JettyConfig jettyConfig = JettyConfig.builder().setPort(0).build(); JettySolrRunner jetty = new JettySolrRunner(instance.getHomeDir(), nodeProperties, jettyConfig); jetty.start(); return jetty; @@ -70,7 +69,7 @@ private static JettySolrRunner createAndStartJetty(ReplicationTestHelper.SolrIns private static SolrClient createNewSolrClient(int port) { - final String baseUrl = buildUrl(port, context); + final String baseUrl = buildUrl(port); return new HttpSolrClient.Builder(baseUrl) .withConnectionTimeout(15000, TimeUnit.MILLISECONDS) .withSocketTimeout(60000, TimeUnit.MILLISECONDS) diff --git a/solr/core/src/test/org/apache/solr/handler/V2StandaloneTest.java b/solr/core/src/test/org/apache/solr/handler/V2StandaloneTest.java index a5672d42b3d..3ba2be501b3 100644 --- a/solr/core/src/test/org/apache/solr/handler/V2StandaloneTest.java +++ b/solr/core/src/test/org/apache/solr/handler/V2StandaloneTest.java @@ -37,10 +37,10 @@ public void testWelcomeMessage() throws Exception { Files.copy(Path.of(TEST_HOME(), "solr.xml"), solrHomeTmp.resolve("solr.xml")); JettySolrRunner jetty = - new JettySolrRunner(solrHomeTmp.toAbsolutePath().toString(), buildJettyConfig("/solr")); + new JettySolrRunner(solrHomeTmp.toAbsolutePath().toString(), buildJettyConfig()); jetty.start(); - try (SolrClient client = getHttpSolrClient(buildUrl(jetty.getLocalPort(), "/solr/"))) { + try (SolrClient client = getHttpSolrClient(buildUrl(jetty.getLocalPort()))) { NamedList res = client.request(new V2Request.Builder("/").build()); NamedList header = (NamedList) res.get("responseHeader"); assertEquals(0, header.get("status")); diff --git a/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java index 0ab68fc397e..f1a76a8efe6 100644 --- a/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java @@ -301,8 +301,7 @@ public void testDeleteInstanceDir() throws Exception { Files.writeString(renamePropFile, "", StandardCharsets.UTF_8); JettySolrRunner runner = - new JettySolrRunner( - solrHomeDirectory.toAbsolutePath().toString(), buildJettyConfig("/solr")); + new JettySolrRunner(solrHomeDirectory.toAbsolutePath().toString(), buildJettyConfig()); runner.start(); try (SolrClient client = @@ -374,8 +373,7 @@ public void testUnloadForever() throws Exception { Path corex = solrHomeDirectory.resolve("corex"); Files.writeString(corex.resolve("core.properties"), "", StandardCharsets.UTF_8); JettySolrRunner runner = - new JettySolrRunner( - solrHomeDirectory.toAbsolutePath().toString(), buildJettyConfig("/solr")); + new JettySolrRunner(solrHomeDirectory.toAbsolutePath().toString(), buildJettyConfig()); runner.start(); try (SolrClient client = @@ -436,8 +434,7 @@ public void testDeleteInstanceDirAfterCreateFailure() throws Exception { Path corex = solrHomeDirectory.resolve("corex"); Files.writeString(corex.resolve("core.properties"), "", StandardCharsets.UTF_8); JettySolrRunner runner = - new JettySolrRunner( - solrHomeDirectory.toAbsolutePath().toString(), buildJettyConfig("/solr")); + new JettySolrRunner(solrHomeDirectory.toAbsolutePath().toString(), buildJettyConfig()); runner.start(); try (SolrClient client = diff --git a/solr/core/src/test/org/apache/solr/handler/admin/DaemonStreamApiTest.java b/solr/core/src/test/org/apache/solr/handler/admin/DaemonStreamApiTest.java index e5d2d09b663..e0ab41ac9ab 100644 --- a/solr/core/src/test/org/apache/solr/handler/admin/DaemonStreamApiTest.java +++ b/solr/core/src/test/org/apache/solr/handler/admin/DaemonStreamApiTest.java @@ -65,7 +65,7 @@ public class DaemonStreamApiTest extends SolrTestCaseJ4 { @Before public void setUp() throws Exception { super.setUp(); - cluster = new MiniSolrCloudCluster(1, createTempDir(), buildJettyConfig("/solr")); + cluster = new MiniSolrCloudCluster(1, createTempDir(), buildJettyConfig()); url = cluster.getJettySolrRunners().get(0).getBaseUrl().toString() + "/" + CHECKPOINT_COLL; diff --git a/solr/core/src/test/org/apache/solr/handler/component/CloudReplicaSourceTest.java b/solr/core/src/test/org/apache/solr/handler/component/CloudReplicaSourceTest.java index f52aefbb42c..5af92386712 100644 --- a/solr/core/src/test/org/apache/solr/handler/component/CloudReplicaSourceTest.java +++ b/solr/core/src/test/org/apache/solr/handler/component/CloudReplicaSourceTest.java @@ -58,10 +58,12 @@ public void testSimple_ShardsParam() { assertEquals(2, cloudReplicaSource.getSliceNames().size()); assertEquals(1, cloudReplicaSource.getReplicasBySlice(0).size()); assertEquals( - "http://baseUrl1:8983/slice1_replica1/", cloudReplicaSource.getReplicasBySlice(0).get(0)); + "http://baseUrl1:8983/solr/slice1_replica1/", + cloudReplicaSource.getReplicasBySlice(0).get(0)); assertEquals(1, cloudReplicaSource.getReplicasBySlice(1).size()); assertEquals( - "http://baseUrl2:8984/slice2_replica2/", cloudReplicaSource.getReplicasBySlice(1).get(0)); + "http://baseUrl2:8984/solr/slice2_replica2/", + cloudReplicaSource.getReplicasBySlice(1).get(0)); } } @@ -87,7 +89,8 @@ public void testShardsParam_DeadNode() { assertEquals(2, cloudReplicaSource.getSliceNames().size()); assertEquals(1, cloudReplicaSource.getReplicasBySlice(0).size()); assertEquals( - "http://baseUrl1:8983/slice1_replica1/", cloudReplicaSource.getReplicasBySlice(0).get(0)); + "http://baseUrl1:8983/solr/slice1_replica1/", + cloudReplicaSource.getReplicasBySlice(0).get(0)); assertEquals(0, cloudReplicaSource.getReplicasBySlice(1).size()); } } @@ -115,11 +118,13 @@ public void testShardsParam_DownReplica() { assertEquals(2, cloudReplicaSource.getSliceNames().size()); assertEquals(1, cloudReplicaSource.getReplicasBySlice(0).size()); assertEquals( - "http://baseUrl1:8983/slice1_replica1/", cloudReplicaSource.getReplicasBySlice(0).get(0)); + "http://baseUrl1:8983/solr/slice1_replica1/", + cloudReplicaSource.getReplicasBySlice(0).get(0)); assertEquals(1, cloudReplicaSource.getReplicasBySlice(1).size()); assertEquals(1, cloudReplicaSource.getReplicasBySlice(1).size()); assertEquals( - "http://baseUrl2:8984/slice2_replica2/", cloudReplicaSource.getReplicasBySlice(1).get(0)); + "http://baseUrl2:8984/solr/slice2_replica2/", + cloudReplicaSource.getReplicasBySlice(1).get(0)); } } @@ -153,17 +158,17 @@ public void testMultipleCollections() { switch (sliceName) { case "collection1_slice1": assertEquals( - "http://baseUrl1:8983/slice1_replica1/", + "http://baseUrl1:8983/solr/slice1_replica1/", cloudReplicaSource.getReplicasBySlice(i).get(0)); break; case "collection1_slice2": assertEquals( - "http://baseUrl2:8984/slice2_replica2/", + "http://baseUrl2:8984/solr/slice2_replica2/", cloudReplicaSource.getReplicasBySlice(i).get(0)); break; case "collection2_slice1": assertEquals( - "http://baseUrl1:8983/slice1_replica3/", + "http://baseUrl1:8983/solr/slice1_replica3/", cloudReplicaSource.getReplicasBySlice(i).get(0)); break; } @@ -198,12 +203,12 @@ public void testSimple_UsingClusterState() { switch (sliceName) { case "slice1": assertEquals( - "http://baseUrl1:8983/slice1_replica1/", + "http://baseUrl1:8983/solr/slice1_replica1/", cloudReplicaSource.getReplicasBySlice(i).get(0)); break; case "slice2": assertEquals( - "http://baseUrl2:8984/slice2_replica2/", + "http://baseUrl2:8984/solr/slice2_replica2/", cloudReplicaSource.getReplicasBySlice(i).get(0)); break; } @@ -239,13 +244,13 @@ public void testSimple_OnlyNrt() { case "slice1": assertEquals(2, cloudReplicaSource.getReplicasBySlice(i).size()); assertEquals( - "http://baseUrl1:8983/slice1_replica1/", + "http://baseUrl1:8983/solr/slice1_replica1/", cloudReplicaSource.getReplicasBySlice(i).get(0)); break; case "slice2": assertEquals(1, cloudReplicaSource.getReplicasBySlice(i).size()); assertEquals( - "http://baseUrl2:8984/slice2_replica3/", + "http://baseUrl2:8984/solr/slice2_replica3/", cloudReplicaSource.getReplicasBySlice(i).get(0)); break; } @@ -284,19 +289,19 @@ public void testMultipleCollections_OnlyNrt() { case "collection1_slice1": assertEquals(2, cloudReplicaSource.getReplicasBySlice(i).size()); assertEquals( - "http://baseUrl1:8983/slice1_replica1/", + "http://baseUrl1:8983/solr/slice1_replica1/", cloudReplicaSource.getReplicasBySlice(i).get(0)); break; case "collection1_slice2": assertEquals(1, cloudReplicaSource.getReplicasBySlice(i).size()); assertEquals( - "http://baseUrl2:8984/slice2_replica3/", + "http://baseUrl2:8984/solr/slice2_replica3/", cloudReplicaSource.getReplicasBySlice(i).get(0)); break; case "collection2_slice1": assertEquals(1, cloudReplicaSource.getReplicasBySlice(i).size()); assertEquals( - "http://baseUrl1:8983/slice1_replica5/", + "http://baseUrl1:8983/solr/slice1_replica5/", cloudReplicaSource.getReplicasBySlice(i).get(0)); break; } diff --git a/solr/core/src/test/org/apache/solr/handler/component/SearchHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/component/SearchHandlerTest.java index 0f22a624093..752e4e21c57 100644 --- a/solr/core/src/test/org/apache/solr/handler/component/SearchHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/component/SearchHandlerTest.java @@ -125,7 +125,7 @@ public void testInitialization() { @Test public void testZkConnected() throws Exception { MiniSolrCloudCluster miniCluster = - new MiniSolrCloudCluster(5, createTempDir(), buildJettyConfig("/solr")); + new MiniSolrCloudCluster(5, createTempDir(), buildJettyConfig()); final CloudSolrClient cloudSolrClient = miniCluster.getSolrClient(); @@ -170,7 +170,7 @@ public void testZkConnected() throws Exception { @Test public void testRequireZkConnected() throws Exception { MiniSolrCloudCluster miniCluster = - new MiniSolrCloudCluster(5, createTempDir(), buildJettyConfig("/solr")); + new MiniSolrCloudCluster(5, createTempDir(), buildJettyConfig()); final CloudSolrClient cloudSolrClient = miniCluster.getSolrClient(); @@ -222,7 +222,7 @@ public void testRequireZkConnected() throws Exception { @Test public void testRequireZkConnectedDistrib() throws Exception { MiniSolrCloudCluster miniCluster = - new MiniSolrCloudCluster(2, createTempDir(), buildJettyConfig("/solr")); + new MiniSolrCloudCluster(2, createTempDir(), buildJettyConfig()); final CloudSolrClient cloudSolrClient = miniCluster.getSolrClient(); diff --git a/solr/core/src/test/org/apache/solr/response/TestRawTransformer.java b/solr/core/src/test/org/apache/solr/response/TestRawTransformer.java index 329cef1b13b..393674c2eca 100644 --- a/solr/core/src/test/org/apache/solr/response/TestRawTransformer.java +++ b/solr/core/src/test/org/apache/solr/response/TestRawTransformer.java @@ -93,7 +93,7 @@ private static void initStandalone() throws Exception { nodeProperties.setProperty("solr.data.dir", h.getCore().getDataDir()); JSR = new JettySolrRunner( - homeDir.toAbsolutePath().toString(), nodeProperties, buildJettyConfig("/solr")); + homeDir.toAbsolutePath().toString(), nodeProperties, buildJettyConfig()); } private static void initCloud() throws Exception { diff --git a/solr/core/src/test/org/apache/solr/search/stats/TestDistribIDF.java b/solr/core/src/test/org/apache/solr/search/stats/TestDistribIDF.java index a8bb1ecb69c..caaa8e2386d 100644 --- a/solr/core/src/test/org/apache/solr/search/stats/TestDistribIDF.java +++ b/solr/core/src/test/org/apache/solr/search/stats/TestDistribIDF.java @@ -52,7 +52,7 @@ public void setUp() throws Exception { } super.setUp(); - solrCluster = new MiniSolrCloudCluster(3, createTempDir(), buildJettyConfig("/solr")); + solrCluster = new MiniSolrCloudCluster(3, createTempDir(), buildJettyConfig()); // set some system properties for use by tests System.setProperty("solr.test.sys.prop1", "propone"); System.setProperty("solr.test.sys.prop2", "proptwo"); diff --git a/solr/core/src/test/org/apache/solr/security/BasicAuthStandaloneTest.java b/solr/core/src/test/org/apache/solr/security/BasicAuthStandaloneTest.java index dad37ef47b8..9bf2787afce 100644 --- a/solr/core/src/test/org/apache/solr/security/BasicAuthStandaloneTest.java +++ b/solr/core/src/test/org/apache/solr/security/BasicAuthStandaloneTest.java @@ -92,7 +92,7 @@ public void testBasicAuth() throws Exception { SolrClient solrClient = null; try { httpClient = HttpClientUtil.createClient(null); - String baseUrl = buildUrl(jetty.getLocalPort(), "/solr"); + String baseUrl = buildUrl(jetty.getLocalPort()); solrClient = getHttpSolrClient(baseUrl); verifySecurityStatus(httpClient, baseUrl + authcPrefix, "/errorMessages", null, 20); @@ -201,8 +201,7 @@ static JettySolrRunner createAndStartJetty(SolrInstance instance) throws Excepti Properties nodeProperties = new Properties(); nodeProperties.setProperty("solr.data.dir", instance.getDataDir().toString()); JettySolrRunner jetty = - new JettySolrRunner( - instance.getHomeDir().toString(), nodeProperties, buildJettyConfig("/solr")); + new JettySolrRunner(instance.getHomeDir().toString(), nodeProperties, buildJettyConfig()); jetty.start(); return jetty; } diff --git a/solr/core/src/test/org/apache/solr/security/MultiAuthPluginTest.java b/solr/core/src/test/org/apache/solr/security/MultiAuthPluginTest.java index 1f3bd062121..ec6dcd65c41 100644 --- a/solr/core/src/test/org/apache/solr/security/MultiAuthPluginTest.java +++ b/solr/core/src/test/org/apache/solr/security/MultiAuthPluginTest.java @@ -91,7 +91,7 @@ public void testMultiAuthEditAPI() throws Exception { SolrClient solrClient = null; try { httpClient = HttpClientUtil.createClient(null); - String baseUrl = buildUrl(jetty.getLocalPort(), "/solr"); + String baseUrl = buildUrl(jetty.getLocalPort()); solrClient = getHttpSolrClient(baseUrl); verifySecurityStatus(httpClient, baseUrl + authcPrefix, "/errorMessages", null, 5); diff --git a/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java b/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java index 9f6cafa9d2c..57866f8a716 100644 --- a/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java +++ b/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java @@ -842,7 +842,7 @@ private void testRetryNodeAgainstBadAddress() throws SolrServerException, IOExce ZkNodeProps nodeProps = new ZkNodeProps( - ZkStateReader.BASE_URL_PROP, DEAD_HOST_1 + context, ZkStateReader.CORE_NAME_PROP, ""); + ZkStateReader.BASE_URL_PROP, DEAD_HOST_1 + "/solr", ZkStateReader.CORE_NAME_PROP, ""); ForwardNode retryNode = new ForwardNode(new ZkCoreNodeProps(nodeProps), null, "collection1", "shard1", 5) { @Override diff --git a/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/GCSIncrementalBackupTest.java b/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/GCSIncrementalBackupTest.java index ac0b15a0187..83b93b2ce58 100644 --- a/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/GCSIncrementalBackupTest.java +++ b/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/GCSIncrementalBackupTest.java @@ -48,7 +48,6 @@ public class GCSIncrementalBackupTest extends AbstractIncrementalBackupTest { + " \n" + " 127.0.0.1\n" + " ${hostPort:8983}\n" - + " ${hostContext:solr}\n" + " ${solr.zkclienttimeout:30000}\n" + " ${genericCoreNodeNames:true}\n" + " 10000\n" diff --git a/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithDelegationTokens.java b/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithDelegationTokens.java index 7d3fce1ef23..859857eed1b 100644 --- a/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithDelegationTokens.java +++ b/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithDelegationTokens.java @@ -67,7 +67,7 @@ public static void startup() throws Exception { System.setProperty(KerberosPlugin.DELEGATION_TOKEN_ENABLED, "true"); System.setProperty("solr.kerberos.cookie.domain", "127.0.0.1"); - miniCluster = new MiniSolrCloudCluster(NUM_SERVERS, createTempDir(), buildJettyConfig("/solr")); + miniCluster = new MiniSolrCloudCluster(NUM_SERVERS, createTempDir(), buildJettyConfig()); JettySolrRunner runnerPrimary = miniCluster.getJettySolrRunners().get(0); solrClientPrimary = new HttpSolrClient.Builder(runnerPrimary.getBaseUrl().toString()).build(); JettySolrRunner runnerSecondary = miniCluster.getJettySolrRunners().get(1); diff --git a/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithSecureImpersonation.java b/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithSecureImpersonation.java index 2975410a442..0a098d0387d 100644 --- a/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithSecureImpersonation.java +++ b/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithSecureImpersonation.java @@ -112,7 +112,7 @@ public static void startup() throws Exception { SolrRequestParsers.DEFAULT.setAddRequestHeadersToContext(true); System.setProperty("collectionsHandler", ImpersonatorCollectionsHandler.class.getName()); - miniCluster = new MiniSolrCloudCluster(NUM_SERVERS, createTempDir(), buildJettyConfig("/solr")); + miniCluster = new MiniSolrCloudCluster(NUM_SERVERS, createTempDir(), buildJettyConfig()); JettySolrRunner runner = miniCluster.getJettySolrRunners().get(0); solrClient = new HttpSolrClient.Builder(runner.getBaseUrl().toString()).build(); } diff --git a/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.java b/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.java index d79aadb1811..ec65c0ed96c 100644 --- a/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.java +++ b/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.java @@ -47,7 +47,6 @@ import org.apache.lucene.store.NRTCachingDirectory; import org.apache.lucene.store.NoLockFactory; import org.apache.lucene.store.SingleInstanceLockFactory; -import org.apache.solr.cloud.ZkController; import org.apache.solr.cloud.api.collections.SplitShardCmd; import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException.ErrorCode; @@ -476,11 +475,7 @@ public String getDataHome(CoreDescriptor cd) throws IOException { return normalize( SolrPaths.normalizeDir( - ZkController.trimLeadingAndTrailingSlashes(hdfsDataDir) - + "/" - + path - + "/" - + cd.getDataDir())); + trimLeadingAndTrailingSlashes(hdfsDataDir) + "/" + path + "/" + cd.getDataDir())); } /** @@ -724,4 +719,21 @@ public void move(Directory fromDir, Directory toDir, String fileName, IOContext public UpdateLog newDefaultUpdateLog() { return new HdfsUpdateLog(getConfDir()); } + + /** + * Utility method for trimming and leading and/or trailing slashes from its input. May return the + * empty string. May return null if and only if the input is null. + */ + public static String trimLeadingAndTrailingSlashes(final String in) { + if (null == in) return in; + + String out = in; + if (out.startsWith("/")) { + out = out.substring(1); + } + if (out.endsWith("/")) { + out = out.substring(0, out.length() - 1); + } + return out; + } } diff --git a/solr/modules/hdfs/src/test/org/apache/solr/hdfs/cloud/api/collections/HdfsCloudIncrementalBackupTest.java b/solr/modules/hdfs/src/test/org/apache/solr/hdfs/cloud/api/collections/HdfsCloudIncrementalBackupTest.java index 9ae15f86e0b..aed608ef37b 100644 --- a/solr/modules/hdfs/src/test/org/apache/solr/hdfs/cloud/api/collections/HdfsCloudIncrementalBackupTest.java +++ b/solr/modules/hdfs/src/test/org/apache/solr/hdfs/cloud/api/collections/HdfsCloudIncrementalBackupTest.java @@ -66,7 +66,6 @@ public class HdfsCloudIncrementalBackupTest extends AbstractIncrementalBackupTes + " \n" + " 127.0.0.1\n" + " ${hostPort:8983}\n" - + " ${hostContext:solr}\n" + " ${solr.zkclienttimeout:30000}\n" + " ${genericCoreNodeNames:true}\n" + " 10000\n" diff --git a/solr/modules/hdfs/src/test/org/apache/solr/hdfs/cloud/api/collections/TestHdfsCloudBackupRestore.java b/solr/modules/hdfs/src/test/org/apache/solr/hdfs/cloud/api/collections/TestHdfsCloudBackupRestore.java index 38e0e221874..9cb6c9ec25a 100644 --- a/solr/modules/hdfs/src/test/org/apache/solr/hdfs/cloud/api/collections/TestHdfsCloudBackupRestore.java +++ b/solr/modules/hdfs/src/test/org/apache/solr/hdfs/cloud/api/collections/TestHdfsCloudBackupRestore.java @@ -88,7 +88,6 @@ public class TestHdfsCloudBackupRestore extends AbstractCloudBackupRestoreTestCa + " \n" + " 127.0.0.1\n" + " ${hostPort:8983}\n" - + " ${hostContext:solr}\n" + " ${solr.zkclienttimeout:30000}\n" + " ${genericCoreNodeNames:true}\n" + " 10000\n" diff --git a/solr/modules/hdfs/src/test/org/apache/solr/hdfs/handler/TestHdfsBackupRestoreCore.java b/solr/modules/hdfs/src/test/org/apache/solr/hdfs/handler/TestHdfsBackupRestoreCore.java index 0bdfc507403..29674f74886 100644 --- a/solr/modules/hdfs/src/test/org/apache/solr/hdfs/handler/TestHdfsBackupRestoreCore.java +++ b/solr/modules/hdfs/src/test/org/apache/solr/hdfs/handler/TestHdfsBackupRestoreCore.java @@ -92,7 +92,6 @@ public class TestHdfsBackupRestoreCore extends SolrCloudTestCase { + " \n" + " 127.0.0.1\n" + " ${hostPort:8983}\n" - + " ${hostContext:solr}\n" + " ${solr.zkclienttimeout:30000}\n" + " ${genericCoreNodeNames:true}\n" + " 10000\n" diff --git a/solr/modules/ltr/src/test-files/solr/solr.xml b/solr/modules/ltr/src/test-files/solr/solr.xml index c8c3ebeb30a..7506c1c8951 100644 --- a/solr/modules/ltr/src/test-files/solr/solr.xml +++ b/solr/modules/ltr/src/test-files/solr/solr.xml @@ -31,7 +31,6 @@ 127.0.0.1 ${hostPort:8983} - ${hostContext:solr} ${solr.zkclienttimeout:30000} ${genericCoreNodeNames:true} ${leaderVoteWait:10000} diff --git a/solr/modules/ltr/src/test/org/apache/solr/ltr/TestLTROnSolrCloud.java b/solr/modules/ltr/src/test/org/apache/solr/ltr/TestLTROnSolrCloud.java index ce5aa367d39..816fccab2d7 100644 --- a/solr/modules/ltr/src/test/org/apache/solr/ltr/TestLTROnSolrCloud.java +++ b/solr/modules/ltr/src/test/org/apache/solr/ltr/TestLTROnSolrCloud.java @@ -323,7 +323,7 @@ public void testSimpleQuery() throws Exception { } private void setupSolrCluster(int numShards, int numReplicas, int numServers) throws Exception { - JettyConfig jc = buildJettyConfig("/solr"); + JettyConfig jc = buildJettyConfig(); jc = JettyConfig.builder(jc).build(); solrCluster = new MiniSolrCloudCluster(numServers, tmpSolrHome, jc); Path configDir = tmpSolrHome.resolve("collection1/conf"); diff --git a/solr/modules/opentelemetry/src/test-files/solr/solr.xml b/solr/modules/opentelemetry/src/test-files/solr/solr.xml index 725934bd0a6..6ad63be5e84 100644 --- a/solr/modules/opentelemetry/src/test-files/solr/solr.xml +++ b/solr/modules/opentelemetry/src/test-files/solr/solr.xml @@ -39,7 +39,6 @@ 127.0.0.1 ${hostPort:8983} - ${hostContext:solr} ${solr.zkclienttimeout:30000} ${genericCoreNodeNames:true} ${leaderVoteWait:10000} @@ -54,4 +53,4 @@ solr_${hostPort:8983} - \ No newline at end of file + diff --git a/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3IncrementalBackupTest.java b/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3IncrementalBackupTest.java index 48c462da548..7214fe6418b 100644 --- a/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3IncrementalBackupTest.java +++ b/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3IncrementalBackupTest.java @@ -60,7 +60,6 @@ public class S3IncrementalBackupTest extends AbstractIncrementalBackupTest { + " \n" + " 127.0.0.1\n" + " ${hostPort:8983}\n" - + " ${hostContext:solr}\n" + " ${solr.zkclienttimeout:30000}\n" + " ${genericCoreNodeNames:true}\n" + " 10000\n" diff --git a/solr/prometheus-exporter/src/test-files/solr/solr.xml b/solr/prometheus-exporter/src/test-files/solr/solr.xml index f87a5876fc8..33ea82a72c5 100644 --- a/solr/prometheus-exporter/src/test-files/solr/solr.xml +++ b/solr/prometheus-exporter/src/test-files/solr/solr.xml @@ -32,7 +32,6 @@ 127.0.0.1 ${hostPort:8983} - ${hostContext:solr} ${solr.zkclienttimeout:30000} ${genericCoreNodeNames:true} ${leaderVoteWait:10000} diff --git a/solr/server/solr/solr.xml b/solr/server/solr/solr.xml index 17783906c6c..d309f18cb40 100644 --- a/solr/server/solr/solr.xml +++ b/solr/server/solr/solr.xml @@ -38,7 +38,6 @@ ${host:} ${solr.port.advertise:0} - ${hostContext:solr} ${genericCoreNodeNames:true} diff --git a/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc b/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc index fe6348c4c0a..8fd032db318 100644 --- a/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc +++ b/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc @@ -44,7 +44,6 @@ The default `solr.xml` file is found in `$SOLR_TIP/server/solr/solr.xml` and loo ${host:} ${solr.port.advertise:0} - ${hostContext:solr} ${genericCoreNodeNames:true} @@ -354,15 +353,6 @@ Used to set the underlying `socketTimeout` for intra-cluster updates. + The hostname Solr uses to access cores. -`hostContext`:: -+ -[%autowidth,frame=none] -|=== -|Optional |Default: none -|=== -+ -The url context path. - `hostPort`:: + [%autowidth,frame=none] diff --git a/solr/solrj-streaming/src/test-files/solrj/solr/solr.xml b/solr/solrj-streaming/src/test-files/solrj/solr/solr.xml index 76d992170f1..c4413d38ce3 100644 --- a/solr/solrj-streaming/src/test-files/solrj/solr/solr.xml +++ b/solr/solrj-streaming/src/test-files/solrj/solr/solr.xml @@ -36,7 +36,6 @@ 127.0.0.1 ${hostPort:8983} - ${hostContext:solr} ${solr.zkclienttimeout:30000} ${genericCoreNodeNames:true} 0 diff --git a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java b/solr/solrj/src/java/org/apache/solr/common/util/Utils.java index a796872a825..391ad2eaed2 100644 --- a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java +++ b/solr/solrj/src/java/org/apache/solr/common/util/Utils.java @@ -38,7 +38,6 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.URL; -import java.net.URLDecoder; import java.nio.BufferOverflowException; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; @@ -711,8 +710,7 @@ public static String getBaseUrlForNodeName( "nodeName does not contain expected '_' separator: " + nodeName); } final String hostAndPort = nodeName.substring(0, _offset); - final String path = URLDecoder.decode(nodeName.substring(1 + _offset), UTF_8); - return urlScheme + "://" + hostAndPort + (path.isEmpty() ? "" : ("/" + (isV2 ? "api" : path))); + return urlScheme + "://" + hostAndPort + "/" + (isV2 ? "api" : "solr"); } public static long time(TimeSource timeSource, TimeUnit unit) { diff --git a/solr/solrj/src/test-files/solrj/solr/shared/solr.xml b/solr/solrj/src/test-files/solrj/solr/shared/solr.xml index 75e95f79b0b..aefabeaa6a2 100644 --- a/solr/solrj/src/test-files/solrj/solr/shared/solr.xml +++ b/solr/solrj/src/test-files/solrj/solr/shared/solr.xml @@ -31,7 +31,6 @@ 127.0.0.1 ${hostPort:8983} - ${hostContext:solr} ${solr.zkclienttimeout:30000} ${genericCoreNodeNames:true} 0 diff --git a/solr/solrj/src/test-files/solrj/solr/solr.xml b/solr/solrj/src/test-files/solrj/solr/solr.xml index 76d992170f1..c4413d38ce3 100644 --- a/solr/solrj/src/test-files/solrj/solr/solr.xml +++ b/solr/solrj/src/test-files/solrj/solr/solr.xml @@ -36,7 +36,6 @@ 127.0.0.1 ${hostPort:8983} - ${hostContext:solr} ${solr.zkclienttimeout:30000} ${genericCoreNodeNames:true} 0 diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttp2SolrClient.java b/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttp2SolrClient.java index aa523e2f5e0..60e3cff52cd 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttp2SolrClient.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttp2SolrClient.java @@ -271,7 +271,7 @@ public String getHomeDir() { } public String getUrl() { - return buildUrl(port, "/solr/collection1"); + return buildUrl(port) + "/collection1"; } public String getSchemaFile() { @@ -320,8 +320,7 @@ public void startJetty() throws Exception { props.setProperty("solrconfig", "bad_solrconfig.xml"); props.setProperty("solr.data.dir", getDataDir()); - JettyConfig jettyConfig = - JettyConfig.builder(buildJettyConfig("/solr")).setPort(port).build(); + JettyConfig jettyConfig = JettyConfig.builder(buildJettyConfig()).setPort(port).build(); jetty = new JettySolrRunner(getHomeDir(), props, jettyConfig); jetty.start(); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrClient.java b/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrClient.java index c251afdba91..f53139d53ba 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrClient.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/TestLBHttpSolrClient.java @@ -274,7 +274,7 @@ public String getHomeDir() { } public String getUrl() { - return buildUrl(port, "/solr/collection1"); + return buildUrl(port) + "/collection1"; } public String getSchemaFile() { @@ -323,8 +323,7 @@ public void startJetty() throws Exception { props.setProperty("solrconfig", "bad_solrconfig.xml"); props.setProperty("solr.data.dir", getDataDir()); - JettyConfig jettyConfig = - JettyConfig.builder(buildJettyConfig("/solr")).setPort(port).build(); + JettyConfig jettyConfig = JettyConfig.builder(buildJettyConfig()).setPort(port).build(); jetty = new JettySolrRunner(getHomeDir(), props, jettyConfig); jetty.start(); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java index 20b651e4f9f..ec631da7081 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java @@ -43,7 +43,6 @@ */ public class JettyWebappTest extends SolrTestCaseJ4 { int port = 0; - static final String context = "/test"; Server server; @@ -64,7 +63,7 @@ public void setUp() throws Exception { // insecure: only use for tests!!!! server.setSessionIdManager( new DefaultSessionIdManager(server, new Random(random().nextLong()))); - new WebAppContext(server, path, context); + new WebAppContext(server, path, "/solr"); ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory()); connector.setIdleTimeout(1000 * 60 * 60); @@ -89,10 +88,8 @@ public void tearDown() throws Exception { } public void testAdminUI() throws Exception { - // Currently not an extensive test, but it does fire up the JSP pages and make - // sure they compile ok - - String adminPath = "http://127.0.0.1:" + port + context + "/"; + // Not an extensive test, but it does connect to Solr and verify the Admin ui shows up. + String adminPath = "http://127.0.0.1:" + port + "/solr/"; try (InputStream is = new URL(adminPath).openStream()) { assertNotNull(is.readAllBytes()); // real error will be an exception } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/TestCloudSolrClientConnections.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/TestCloudSolrClientConnections.java index 20853430218..d678106f873 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/TestCloudSolrClientConnections.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/TestCloudSolrClientConnections.java @@ -32,8 +32,7 @@ public class TestCloudSolrClientConnections extends SolrTestCaseJ4 { public void testCloudClientCanConnectAfterClusterComesUp() throws Exception { // Start by creating a cluster with no jetties - MiniSolrCloudCluster cluster = - new MiniSolrCloudCluster(0, createTempDir(), buildJettyConfig("/solr")); + MiniSolrCloudCluster cluster = new MiniSolrCloudCluster(0, createTempDir(), buildJettyConfig()); try { CloudSolrClient client = cluster.getSolrClient(); @@ -61,8 +60,7 @@ public void testCloudClientUploads() throws Exception { Path configPath = getFile("solrj").toPath().resolve("solr/configsets/configset-2/conf"); - MiniSolrCloudCluster cluster = - new MiniSolrCloudCluster(0, createTempDir(), buildJettyConfig("/solr")); + MiniSolrCloudCluster cluster = new MiniSolrCloudCluster(0, createTempDir(), buildJettyConfig()); try { CloudSolrClient client = cluster.getSolrClient(); SolrException e = @@ -94,9 +92,9 @@ public void testCloudClientUploads() throws Exception { public void testAlreadyClosedClusterStateProvider() throws Exception { final MiniSolrCloudCluster cluster = - new MiniSolrCloudCluster(1, createTempDir(), buildJettyConfig("/solr")); + new MiniSolrCloudCluster(1, createTempDir(), buildJettyConfig()); // from a client perspective the behavior of ZkClientClusterStateProvider should be - // consistent regardless of wether it's constructed with a zkhost or an existing ZkStateReader + // consistent regardless of whether it's constructed with a zkhost or an existing ZkStateReader try { final ZkClientClusterStateProvider zkHost_provider = new ZkClientClusterStateProvider(cluster.getZkServer().getZkAddress()); diff --git a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java index ff3b8a17c8c..d466d993a48 100644 --- a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java +++ b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java @@ -46,7 +46,6 @@ import java.util.concurrent.atomic.AtomicInteger; import javax.servlet.Filter; import org.apache.commons.io.FileUtils; -import org.apache.lucene.tests.util.TestUtil; import org.apache.lucene.util.Constants; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrResponse; @@ -122,60 +121,6 @@ public static void initialize() { r = new Random(random().nextLong()); } - /** - * Set's the value of the "hostContext" system property to a random path like string (which may or - * may not contain sub-paths). This is used in the default constructor for this test to help - * ensure no code paths have hardcoded assumptions about the servlet context used to run solr. - * - *

Test configs may use the ${hostContext} variable to access this system - * property. - * - * @see #BaseDistributedSearchTestCase() - * @see #clearHostContext - */ - @BeforeClass - public static void initHostContext() { - // Can't use randomRealisticUnicodeString because unescaped unicode is - // not allowed in URL paths - // Can't use URLEncoder.encode(randomRealisticUnicodeString) because - // Jetty freaks out and returns 404's when the context uses escapes - - StringBuilder hostContext = new StringBuilder("/"); - if (random().nextBoolean()) { - // half the time we use the root context, the other half... - - // Remember: randomSimpleString might be the empty string - hostContext.append(TestUtil.randomSimpleString(random(), 2)); - if (random().nextBoolean()) { - hostContext.append("_"); - } - hostContext.append(TestUtil.randomSimpleString(random(), 3)); - if (!"/".equals(hostContext.toString())) { - // if our random string is empty, this might add a trailing slash, - // but our code should be ok with that - hostContext.append("/").append(TestUtil.randomSimpleString(random(), 2)); - } else { - // we got 'lucky' and still just have the root context, - // NOOP: don't try to add a subdir to nothing (ie "//" is bad) - } - } - // paranoia, we *really* don't want to ever get "//" in a path... - final String hc = hostContext.toString().replaceAll("/+", "/"); - - log.info("Setting hostContext system property: {}", hc); - System.setProperty("hostContext", hc); - } - - /** - * Clears the "hostContext" system property - * - * @see #initHostContext - */ - @AfterClass - public static void clearHostContext() throws Exception { - System.clearProperty("hostContext"); - } - @SuppressWarnings("deprecation") @BeforeClass public static void setSolrDisableShardsWhitelist() throws Exception { @@ -189,40 +134,17 @@ public static void clearSolrDisableShardsWhitelist() throws Exception { } private static String getHostContextSuitableForServletContext() { - String ctx = System.getProperty("hostContext", "/solr"); - if (ctx == null || ctx.isEmpty()) ctx = "/solr"; - if (ctx.endsWith("/")) ctx = ctx.substring(0, ctx.length() - 1); - if (!ctx.startsWith("/")) ctx = "/" + ctx; - return ctx; + return "/solr"; } - /** - * Constructs a test in which the jetty+solr instances as well as the solr clients all use the - * value of the "hostContext" system property. - * - *

If the system property is not set, or is set to the empty string (neither of which should - * normally happen unless a subclass explicitly modifies the property set by {@link - * #initHostContext} prior to calling this constructor) a servlet context of "/solr" is used. - * (this is for consistency with the default behavior of solr.xml parsing when using - * hostContext="${hostContext:}" - * - *

If the system property is set to a value which does not begin with a "/" (which should - * normally happen unless a subclass explicitly modifies the property set by {@link - * #initHostContext} prior to calling this constructor) a leading "/" will be prepended. - * - * @see #initHostContext - */ protected BaseDistributedSearchTestCase() { - this(getHostContextSuitableForServletContext()); - } - - /** - * @param context explicit servlet context path to use (eg: "/solr") - */ - protected BaseDistributedSearchTestCase(final String context) { - this.context = context; + String solrHostContext = "/solr"; this.deadServers = - new String[] {DEAD_HOST_1 + context, DEAD_HOST_2 + context, DEAD_HOST_3 + context}; + new String[] { + DEAD_HOST_1 + solrHostContext, + DEAD_HOST_2 + solrHostContext, + DEAD_HOST_3 + solrHostContext + }; // Speed up the test cycle by only running a single configuration instead of the repeat rule if (TEST_NIGHTLY == false) { @@ -250,7 +172,6 @@ public void fixShardCount(int count) { protected final List clients = Collections.synchronizedList(new ArrayList<>()); protected final List jettys = Collections.synchronizedList(new ArrayList<>()); - protected volatile String context; protected volatile String[] deadServers; protected volatile String shards; protected volatile String[] shardsArr; @@ -508,7 +429,6 @@ public JettySolrRunner createJetty( props, JettyConfig.builder() .stopAtShutdown(true) - .setContext(context) .withFilters(getExtraRequestFilters()) .withServlets(getExtraServlets()) .withSSLConfig(sslConfig.buildServerSSLConfig()) @@ -546,10 +466,6 @@ protected String getServerUrl(int port) { } } - protected String buildUrl(int port) { - return buildUrl(port, context); - } - protected static void addFields(SolrInputDocument doc, Object... fields) { for (int i = 0; i < fields.length; i += 2) { doc.addField((String) (fields[i]), fields[i + 1]); diff --git a/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java b/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java index 3f946add592..2042b24a498 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java @@ -69,7 +69,6 @@ public static JettySolrRunner createAndStartJetty( JettyConfig jettyConfig = JettyConfig.builder() - .setContext(context) .stopAtShutdown(stopAtShutdown) .withServlets(extraServlets) .withSSLConfig(sslConfig.buildServerSSLConfig()) diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseHS.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseHS.java index 42dc8b3aeb7..26234b5e9f3 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseHS.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseHS.java @@ -510,7 +510,6 @@ public void start() throws Exception { JettyConfig jettyConfig = JettyConfig.builder() .stopAtShutdown(true) - .setContext("/solr") .setPort(port) .withSSLConfig(sslConfig.buildServerSSLConfig()) .build(); diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java index 47e0b473fb9..ba96e729562 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java @@ -520,15 +520,12 @@ private static SSLTestConfig buildSSLConfig() { return result; } - protected static JettyConfig buildJettyConfig(String context) { - return JettyConfig.builder() - .setContext(context) - .withSSLConfig(sslConfig.buildServerSSLConfig()) - .build(); + protected static JettyConfig buildJettyConfig() { + return JettyConfig.builder().withSSLConfig(sslConfig.buildServerSSLConfig()).build(); } - protected static String buildUrl(final int port, final String context) { - return (isSSLMode() ? "https" : "http") + "://127.0.0.1:" + port + context; + protected static String buildUrl(final int port) { + return (isSSLMode() ? "https" : "http") + "://127.0.0.1:" + port + "/solr"; } protected static MockTokenizer whitespaceMockTokenizer(Reader input) throws IOException { diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java index b21aa73831a..e2f2074873d 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java @@ -729,7 +729,6 @@ public JettySolrRunner createJetty( JettyConfig jettyconfig = JettyConfig.builder() - .setContext(context) .stopAtShutdown(false) .withServlets(getExtraServlets()) .withFilters(getExtraRequestFilters()) @@ -775,7 +774,6 @@ public JettySolrRunner createJetty( JettyConfig jettyconfig = JettyConfig.builder() - .setContext(context) .stopAtShutdown(false) .withServlets(getExtraServlets()) .withFilters(getExtraRequestFilters()) @@ -814,7 +812,6 @@ public JettySolrRunner createProxiedJetty( JettyConfig jettyconfig = JettyConfig.builder() - .setContext(context) .stopAtShutdown(false) .withServlets(getExtraServlets()) .withFilters(getExtraRequestFilters()) diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java index 704cbfa8589..3a4d41d0420 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java @@ -121,7 +121,6 @@ public class MiniSolrCloudCluster { + " \n" + " 127.0.0.1\n" + " ${hostPort:8983}\n" - + " ${hostContext:solr}\n" + " ${solr.zkclienttimeout:30000}\n" + " ${genericCoreNodeNames:true}\n" + " ${leaderVoteWait:10000}\n" @@ -177,61 +176,6 @@ public MiniSolrCloudCluster(int numServers, Path baseDir, JettyConfig jettyConfi this(numServers, baseDir, DEFAULT_CLOUD_SOLR_XML, jettyConfig, null, false); } - /** - * Create a MiniSolrCloudCluster - * - * @param numServers number of Solr servers to start - * @param hostContext context path of Solr servers used by Jetty - * @param baseDir base directory that the mini cluster should be run from - * @param solrXml solr.xml file to be uploaded to ZooKeeper - * @param extraServlets Extra servlets to be started by Jetty - * @param extraRequestFilters extra filters to be started by Jetty - * @throws Exception if there was an error starting the cluster - */ - public MiniSolrCloudCluster( - int numServers, - String hostContext, - Path baseDir, - String solrXml, - SortedMap extraServlets, - SortedMap, String> extraRequestFilters) - throws Exception { - this(numServers, hostContext, baseDir, solrXml, extraServlets, extraRequestFilters, null); - } - - /** - * Create a MiniSolrCloudCluster - * - * @param numServers number of Solr servers to start - * @param hostContext context path of Solr servers used by Jetty - * @param baseDir base directory that the mini cluster should be run from - * @param solrXml solr.xml file to be uploaded to ZooKeeper - * @param extraServlets Extra servlets to be started by Jetty - * @param extraRequestFilters extra filters to be started by Jetty - * @param sslConfig SSL configuration - * @throws Exception if there was an error starting the cluster - */ - public MiniSolrCloudCluster( - int numServers, - String hostContext, - Path baseDir, - String solrXml, - SortedMap extraServlets, - SortedMap, String> extraRequestFilters, - SSLConfig sslConfig) - throws Exception { - this( - numServers, - baseDir, - solrXml, - JettyConfig.builder() - .setContext(hostContext) - .withSSLConfig(sslConfig) - .withFilters(extraRequestFilters) - .withServlets(extraServlets) - .build()); - } - /** * Create a MiniSolrCloudCluster * @@ -370,7 +314,7 @@ public MiniSolrCloudCluster( List> startups = new ArrayList<>(numServers); for (int i = 0; i < numServers; ++i) { - startups.add(() -> startJettySolrRunner(newNodeName(), jettyConfig.context, jettyConfig)); + startups.add(() -> startJettySolrRunner(newNodeName(), jettyConfig)); } final ExecutorService executorLauncher = @@ -510,13 +454,12 @@ public JettySolrRunner startJettySolrRunner( SortedMap extraServlets, SortedMap, String> extraRequestFilters) throws Exception { - return startJettySolrRunner(name, hostContext, extraServlets, extraRequestFilters, null); + return startJettySolrRunner(name, extraServlets, extraRequestFilters, null); } /** * Start a new Solr instance * - * @param hostContext context path of Solr servers used by Jetty * @param extraServlets Extra servlets to be started by Jetty * @param extraRequestFilters extra filters to be started by Jetty * @param sslConfig SSL configuration @@ -524,14 +467,12 @@ public JettySolrRunner startJettySolrRunner( */ public JettySolrRunner startJettySolrRunner( String name, - String hostContext, SortedMap extraServlets, SortedMap, String> extraRequestFilters, SSLConfig sslConfig) throws Exception { return startJettySolrRunner( name, - hostContext, JettyConfig.builder() .withServlets(extraServlets) .withFilters(extraRequestFilters) @@ -547,19 +488,16 @@ public JettySolrRunner getJettySolrRunner(int index) { * Start a new Solr instance on a particular servlet context * * @param name the instance name - * @param hostContext the context to run on * @param config a JettyConfig for the instance's {@link org.apache.solr.embedded.JettySolrRunner} * @return a JettySolrRunner */ - public JettySolrRunner startJettySolrRunner(String name, String hostContext, JettyConfig config) - throws Exception { + public JettySolrRunner startJettySolrRunner(String name, JettyConfig config) throws Exception { // tell solr node to look in zookeeper for solr.xml final Properties nodeProps = new Properties(); nodeProps.setProperty("zkHost", zkServer.getZkAddress()); Path runnerPath = createInstancePath(name); - String context = getHostContextSuitableForServletContext(hostContext); - JettyConfig newConfig = JettyConfig.builder(config).setContext(context).build(); + JettyConfig newConfig = JettyConfig.builder(config).build(); JettySolrRunner jetty = !trackJettyMetrics ? new JettySolrRunner(runnerPath.toString(), nodeProps, newConfig) @@ -578,7 +516,7 @@ public JettySolrRunner startJettySolrRunner(String name, String hostContext, Jet * @return a JettySolrRunner */ public JettySolrRunner startJettySolrRunner() throws Exception { - return startJettySolrRunner(newNodeName(), jettyConfig.context, jettyConfig); + return startJettySolrRunner(newNodeName(), jettyConfig); } /** @@ -1117,7 +1055,7 @@ public Builder(int nodeCount, Path baseDir) { this.nodeCount = nodeCount; this.baseDir = baseDir; - jettyConfigBuilder = JettyConfig.builder().setContext("/solr"); + jettyConfigBuilder = JettyConfig.builder(); if (SolrTestCaseJ4.sslConfig != null) { jettyConfigBuilder = jettyConfigBuilder.withSSLConfig(SolrTestCaseJ4.sslConfig.buildServerSSLConfig()); diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractInstallShardTest.java b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractInstallShardTest.java index 8bcd85077b7..70f1a38e18e 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractInstallShardTest.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractInstallShardTest.java @@ -224,7 +224,6 @@ public static String defaultSolrXmlTextWithBackupRepository(String backupReposit + " \n" + " 127.0.0.1\n" + " ${hostPort:8983}\n" - + " ${hostContext:solr}\n" + " ${solr.zkclienttimeout:30000}\n" + " ${genericCoreNodeNames:true}\n" + " 10000\n" diff --git a/solr/test-framework/src/java/org/apache/solr/embedded/JettyConfig.java b/solr/test-framework/src/java/org/apache/solr/embedded/JettyConfig.java index b03b1c234db..cbaad484503 100644 --- a/solr/test-framework/src/java/org/apache/solr/embedded/JettyConfig.java +++ b/solr/test-framework/src/java/org/apache/solr/embedded/JettyConfig.java @@ -28,7 +28,6 @@ public class JettyConfig { public final boolean onlyHttp1; public final int port; public final int portRetryTime; - public final String context; public final boolean stopAtShutdown; public final Long waitForLoadingCoresToFinishMs; public final Map extraServlets; @@ -40,7 +39,6 @@ private JettyConfig( boolean onlyHttp1, int port, int portRetryTime, - String context, boolean stopAtShutdown, Long waitForLoadingCoresToFinishMs, Map extraServlets, @@ -50,7 +48,6 @@ private JettyConfig( this.onlyHttp1 = onlyHttp1; this.port = port; this.portRetryTime = portRetryTime; - this.context = context; this.stopAtShutdown = stopAtShutdown; this.waitForLoadingCoresToFinishMs = waitForLoadingCoresToFinishMs; this.extraServlets = extraServlets; @@ -69,7 +66,6 @@ public static Builder builder(JettyConfig other) { builder.onlyHttp1 = other.onlyHttp1; builder.port = other.port; builder.portRetryTime = other.portRetryTime; - builder.context = other.context; builder.stopAtShutdown = other.stopAtShutdown; builder.waitForLoadingCoresToFinishMs = other.waitForLoadingCoresToFinishMs; builder.extraServlets = other.extraServlets; @@ -83,7 +79,6 @@ public static class Builder { boolean onlyHttp1 = false; int port = 0; - String context = "/solr"; boolean enableV2 = true; boolean stopAtShutdown = true; Long waitForLoadingCoresToFinishMs = 300000L; @@ -107,11 +102,6 @@ public Builder setPort(int port) { return this; } - public Builder setContext(String context) { - this.context = context; - return this; - } - public Builder stopAtShutdown(boolean stopAtShutdown) { this.stopAtShutdown = stopAtShutdown; return this; @@ -157,7 +147,6 @@ public JettyConfig build() { onlyHttp1, port, portRetryTime, - context, stopAtShutdown, waitForLoadingCoresToFinishMs, extraServlets, diff --git a/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java b/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java index 27d3052e74a..1130df5d7ce 100644 --- a/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java +++ b/solr/test-framework/src/java/org/apache/solr/embedded/JettySolrRunner.java @@ -217,11 +217,10 @@ private void executeDelay() { *

After construction, you must start the jetty with {@link #start()} * * @param solrHome the solr home directory to use - * @param context the context to run in * @param port the port to run on */ - public JettySolrRunner(String solrHome, String context, int port) { - this(solrHome, JettyConfig.builder().setContext(context).setPort(port).build()); + public JettySolrRunner(String solrHome, int port) { + this(solrHome, JettyConfig.builder().setPort(port).build()); } /** @@ -373,7 +372,7 @@ private void init(int port) { { // Initialize the servlets final ServletContextHandler root = - new ServletContextHandler(server, config.context, ServletContextHandler.SESSIONS); + new ServletContextHandler(server, "/solr", ServletContextHandler.SESSIONS); root.setResourceBase("."); server.addEventListener( @@ -396,7 +395,6 @@ public synchronized void lifeCycleStarted(LifeCycle arg0) { int port = jettyPort; if (proxyPort != -1) port = proxyPort; nodeProperties.setProperty("hostPort", Integer.toString(port)); - nodeProperties.setProperty("hostContext", config.context); root.getServletContext() .setAttribute(SolrDispatchFilter.PROPERTIES_ATTRIBUTE, nodeProperties); @@ -840,7 +838,7 @@ public void setProxyPort(int proxyPort) { */ public URL getBaseUrl() { try { - return new URL(protocol, host, jettyPort, config.context); + return new URL(protocol, host, jettyPort, "/solr"); } catch (MalformedURLException e) { throw new RuntimeException(e); } @@ -859,7 +857,7 @@ public URL getBaseURLV2() { */ public URL getProxyBaseUrl() { try { - return new URL(protocol, host, getLocalPort(), config.context); + return new URL(protocol, host, getLocalPort(), "/solr"); } catch (MalformedURLException e) { throw new RuntimeException(e); } @@ -893,7 +891,7 @@ public void service(HttpServletRequest req, HttpServletResponse res) throws IOEx /** A main class that starts jetty+solr This is useful for debugging */ public static void main(String[] args) throws Exception { - JettySolrRunner jetty = new JettySolrRunner(".", "/solr", 8983); + JettySolrRunner jetty = new JettySolrRunner(".", 8983); jetty.start(); } diff --git a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java index 662b23f08ea..3384a03d0be 100644 --- a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java +++ b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java @@ -189,9 +189,7 @@ public static NodeConfig buildTestNodeConfig(Path solrHome) { (null == System.getProperty("zkHost")) ? null : new CloudConfig.CloudConfigBuilder( - System.getProperty("host"), - Integer.getInteger("hostPort", 8983), - System.getProperty("hostContext", "")) + System.getProperty("host"), Integer.getInteger("hostPort", 8983)) .setZkClientTimeout(Integer.getInteger("zkClientTimeout", 30000)) .setZkHost(System.getProperty("zkHost")) .build(); diff --git a/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.java b/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.java index 26024ff548d..49b68a134fb 100644 --- a/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.java +++ b/solr/test-framework/src/test/org/apache/solr/cloud/MiniSolrCloudClusterTest.java @@ -56,10 +56,10 @@ public void testErrorsInStartup() throws Exception { cluster = new MiniSolrCloudCluster(3, createTempDir(), JettyConfig.builder().build()) { @Override - public JettySolrRunner startJettySolrRunner( - String name, String context, JettyConfig config) throws Exception { + public JettySolrRunner startJettySolrRunner(String name, JettyConfig config) + throws Exception { if (jettyIndex.incrementAndGet() != 2) - return super.startJettySolrRunner(name, context, config); + return super.startJettySolrRunner(name, config); throw new IOException("Fake exception on startup!"); } }; @@ -199,15 +199,15 @@ public void testJettyUsingSysProp() throws Exception { final MiniSolrCloudCluster x = new MiniSolrCloudCluster(1, createTempDir(), JettyConfig.builder().build()) { @Override - public JettySolrRunner startJettySolrRunner( - String name, String hostContext, JettyConfig config) throws Exception { + public JettySolrRunner startJettySolrRunner(String name, JettyConfig config) + throws Exception { System.setProperty("zkHost", getZkServer().getZkAddress()); final Properties nodeProps = new Properties(); nodeProps.setProperty("test-from-sysprop", "yup"); Path runnerPath = createTempDir(name); - JettyConfig newConfig = JettyConfig.builder(config).setContext("/blarfh").build(); + JettyConfig newConfig = JettyConfig.builder(config).build(); JettySolrRunner jetty = new JettySolrRunner(runnerPath.toString(), nodeProps, newConfig); return super.startJettySolrRunner(jetty); diff --git a/solr/test-framework/src/test/org/apache/solr/embedded/TestJettySolrRunner.java b/solr/test-framework/src/test/org/apache/solr/embedded/TestJettySolrRunner.java index 2fc1299a734..34f48b79fe4 100644 --- a/solr/test-framework/src/test/org/apache/solr/embedded/TestJettySolrRunner.java +++ b/solr/test-framework/src/test/org/apache/solr/embedded/TestJettySolrRunner.java @@ -48,7 +48,7 @@ public void testPassSolrHomeToRunner() throws Exception { .replace("COREROOT", coresDir.toString()); Files.write(solrHome.resolve("solr.xml"), solrxml.getBytes(StandardCharsets.UTF_8)); - JettyConfig jettyConfig = buildJettyConfig("/solr"); + JettyConfig jettyConfig = buildJettyConfig(); JettySolrRunner runner = new JettySolrRunner(solrHome.toString(), new Properties(), jettyConfig);