Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@
</httpCaching>
</requestDispatcher>

<!-- test getting system property -->
<propTest attr1="${solr.test.sys.prop1}-$${literal}"
attr2="${non.existent.sys.prop:default-from-config}">prefix-${solr.test.sys.prop2}-suffix</propTest>

<queryParser name="count" class="org.apache.solr.search.AnalyticsTestQParserPlugin"/>

<updateRequestProcessorChain name="uniq-fields">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,6 @@
</httpCaching>
</requestDispatcher>

<!-- test getting system property -->
<propTest attr1="${solr.test.sys.prop1}-$${literal}"
attr2="${non.existent.sys.prop:default-from-config}">prefix-${solr.test.sys.prop2}-suffix</propTest>

<queryParser name="foo" class="FooQParserPlugin"/>

<updateRequestProcessorChain name="uniq-fields">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@
</httpCaching>
</requestDispatcher>

<!-- test getting system property -->
<propTest attr1="${solr.test.sys.prop1}-$${literal}"
attr2="${non.existent.sys.prop:default-from-config}">prefix-${solr.test.sys.prop2}-suffix</propTest>

<queryParser name="foo" class="FooQParserPlugin"/>

<initParams path="/elevate,/dataElevate">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,6 @@
</lst>
</requestHandler>

<!-- test getting system property -->
<propTest attr1="${solr.test.sys.prop1}-$${literal}"
attr2="${non.existent.sys.prop:default-from-config}">prefix-${solr.test.sys.prop2}-suffix</propTest>

<queryParser name="foo" class="FooQParserPlugin"/>

<updateRequestProcessorChain name="uniq-fields">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,6 @@
</httpCaching>
</requestDispatcher>

<!-- test getting system property -->
<propTest attr1="${solr.test.sys.prop1}-$${literal}"
attr2="${non.existent.sys.prop:default-from-config}">prefix-${solr.test.sys.prop2}-suffix</propTest>

<queryParser name="rank" class="org.apache.solr.search.RankQueryTestPlugin"/>

<updateRequestProcessorChain name="uniq-fields">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,8 @@
<directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.MockDirectoryFactory}"/>
<schemaFactory class="ClassicIndexSchemaFactory"/>

<!-- see TestConfig.testJavaProperty -->
<propTest attr1="${solr.test.sys.prop1}-$${literal}"
attr2="${non.existent.sys.prop:default-from-config}">prefix-${solr.test.sys.prop2}-suffix</propTest>

<!-- see TestConfig.testDisableRequetsHandler -->
<requestHandler name="/disabled" class="solr.SearchHandler" enable="false"/>
<requestHandler name="/enabled" class="solr.SearchHandler" enable="true"/>



</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" ?>

<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!--
A minimal solrconfig specifically for testing property substitution functionality.
This config is used by TestConfigPropertySubstitution.testJavaPropertySubstitution() to test
that system property substitution works correctly in Solr configuration files.
-->
<config>
<luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
<dataDir>${solr.data.dir:}</dataDir>
<xi:include href="solrconfig.snippet.randomindexconfig.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.MockDirectoryFactory}"/>
<schemaFactory class="ClassicIndexSchemaFactory"/>

<!-- This element is specifically for testing property substitution -->
<propTest attr1="${solr.test.sys.prop1}-$${literal}"
attr2="${non.existent.sys.prop:default-from-config}">prefix-${solr.test.sys.prop2}-suffix</propTest>

<requestHandler name="/select" class="solr.SearchHandler" />
</config>
4 changes: 0 additions & 4 deletions solr/core/src/test-files/solr/collection1/conf/solrconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,6 @@
</lst>
</requestHandler>

<!-- test getting system property -->
<propTest attr1="${solr.test.sys.prop1}-$${literal}"
attr2="${non.existent.sys.prop:default-from-config}">prefix-${solr.test.sys.prop2}-suffix</propTest>

<queryParser name="foo" class="FooQParserPlugin"/>

<updateRequestProcessorChain name="uniq-fields">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,13 @@ public class TestRequestForwarding extends SolrTestCaseJ4 {
@Override
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(), JettyConfig.builder().build());
solrCluster.uploadConfigSet(TEST_PATH().resolve("collection1/conf"), "conf1");
}

@Override
public void tearDown() throws Exception {
solrCluster.shutdown();
System.clearProperty("solr.test.sys.prop1");
System.clearProperty("solr.test.sys.prop2");

super.tearDown();
}

Expand Down
26 changes: 0 additions & 26 deletions solr/core/src/test/org/apache/solr/core/TestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@
import java.io.InputStream;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import org.apache.lucene.index.ConcurrentMergeScheduler;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.TieredMergePolicy;
import org.apache.lucene.util.InfoStream;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.ConfigNode;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.IndexSchemaFactory;
import org.apache.solr.search.CacheConfig;
Expand Down Expand Up @@ -63,30 +61,6 @@ public void testDisableRequetsHandler() {
assertNotNull(h.getCore().getRequestHandler("/enabled"));
}

@Test
public void testJavaProperty() {
// property values defined in build.xml

String s = solrConfig.get("propTest").txt();
assertEquals("prefix-proptwo-suffix", s);

s = solrConfig.get("propTest").attr("attr1", "default");
assertEquals("propone-${literal}", s);

s = solrConfig.get("propTest").attr("attr2", "default");
assertEquals("default-from-config", s);

assertEquals(
"prefix-proptwo-suffix",
solrConfig.get("propTest", it -> "default-from-config".equals(it.attr("attr2"))).txt());

List<ConfigNode> nl = solrConfig.root.getAll("propTest");
assertEquals(1, nl.size());
assertEquals("prefix-proptwo-suffix", nl.get(0).txt());

assertEquals("prefix-proptwo-suffix", solrConfig.get("propTest").txt());
}

@Test
public void testCacheEnablingDisabling() throws Exception {
// ensure if cache is not defined in the config then cache is disabled
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.core;

import java.util.List;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.ConfigNode;
import org.junit.BeforeClass;
import org.junit.Test;

/**
* Test class specifically for testing system property substitution in Solr configuration files.
* This class is isolated from other tests to minimize the global impact of setting test-specific
* system properties.
*/
public class TestConfigPropertySubstitution extends SolrTestCaseJ4 {

@BeforeClass
public static void beforeClass() throws Exception {
// Set the test properties specifically for property substitution testing
System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo");

// Use a minimal configuration file that only contains the propTest element
initCore("solrconfig-test-properties.xml", "schema.xml");
}

@Test
public void testJavaPropertySubstitution() {
// Test that system property substitution works correctly in configuration files
// These property values are set in beforeClass()

String s = solrConfig.get("propTest").txt();
assertEquals("prefix-proptwo-suffix", s);

s = solrConfig.get("propTest").attr("attr1", "default");
assertEquals("propone-${literal}", s);

s = solrConfig.get("propTest").attr("attr2", "default");
assertEquals("default-from-config", s);

assertEquals(
"prefix-proptwo-suffix",
solrConfig.get("propTest", it -> "default-from-config".equals(it.attr("attr2"))).txt());

List<ConfigNode> nl = solrConfig.root.getAll("propTest");
assertEquals(1, nl.size());
assertEquals("prefix-proptwo-suffix", nl.get(0).txt());

assertEquals("prefix-proptwo-suffix", solrConfig.get("propTest").txt());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public static void beforeClass() throws Exception {
solrHomeDirectory = createTempDir();
PathUtils.copyDirectory(TEST_HOME(), solrHomeDirectory);

System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo");
Properties props = new Properties();
props.setProperty("test", "Before reload");
writeCustomProperties(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,6 @@ public void setTestPort(Integer testPort) {
}

public void setUp() throws Exception {
System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo");

Properties props = new Properties();
props.setProperty("name", "collection1");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ public class SolrMetricsIntegrationTest extends SolrTestCaseJ4 {
@Before
public void beforeTest() throws Exception {
Path home = TEST_PATH();
// define these properties, they are used in solrconfig.xml
System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo");
String solrXml =
Files.readString(home.resolve("solr-metricreporter.xml"), StandardCharsets.UTF_8);
NodeConfig cfg = SolrXmlConfig.fromString(home, solrXml);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ public static void init() throws Exception {
System.setProperty("coreRootDirectory", coresDir.toString());
System.setProperty("configSetBaseDir", TEST_HOME().toString());

System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo");

final SortedMap<ServletHolder, String> extraServlets = new TreeMap<>();

Properties props = new Properties();
Expand Down
3 changes: 0 additions & 3 deletions solr/core/src/test/org/apache/solr/schema/DateFieldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ public class DateFieldTest extends SolrTestCaseJ4 {
@Override
public void setUp() throws Exception {
super.setUp();
// set some system properties for use by tests
System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo");
SolrConfig config =
new SolrConfig(testInstanceDir, testConfHome.resolve("solrconfig.xml").toString());
IndexSchema schema =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public void setUp() throws Exception {
// set some system properties for use by tests
System.setProperty(
"solr.index.updatelog.enabled", "false"); // schema12 doesn't support _version_
System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo");

initMap = new HashMap<>();
config =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -43,7 +42,6 @@
import org.apache.solr.client.solrj.request.beans.PluginMeta;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.cloud.MiniSolrCloudCluster;
import org.apache.solr.cloud.SolrCloudTestCase;
import org.apache.solr.cluster.placement.PlacementPluginFactory;
import org.apache.solr.cluster.placement.plugins.AffinityPlacementConfig;
Expand All @@ -52,13 +50,12 @@
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** Tests using fromIndex that points to a collection in SolrCloud mode. */
// @LogLevel("org.apache.solr.schema.IndexSchema=TRACE")
public class ShardToShardJoinAbstract extends SolrCloudTestCase {
public abstract class ShardToShardJoinAbstract extends SolrCloudTestCase {

private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

Expand All @@ -68,25 +65,17 @@ public class ShardToShardJoinAbstract extends SolrCloudTestCase {
protected static String toColl = "parent";
protected static String fromColl = "children";

@BeforeClass
public static void setPropos() {
System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo");
}

public static void setupCluster(
Consumer<CollectionAdminRequest.Create> fromDecorator,
Consumer<CollectionAdminRequest.Create> parentDecorator,
Function<String, SolrInputDocument> parentDocFactory,
BiFunction<String, String, SolrInputDocument> childDocFactory)
throws Exception {
final Path configDir = TEST_COLL1_CONF();

String configName = "_default"; // "solrCloudCollectionConfig";
int nodeCount = 5;
final MiniSolrCloudCluster cloudCluster =
configureCluster(nodeCount) // .addConfig(configName, configDir)
.configure();

configureCluster(nodeCount).configure();

PluginMeta plugin = new PluginMeta();
plugin.name = PlacementPluginFactory.PLUGIN_NAME;
Expand Down Expand Up @@ -151,8 +140,6 @@ public static void setupCluster(

@AfterClass
public static void shutdown() {
System.clearProperty("solr.test.sys.prop1");
System.clearProperty("solr.test.sys.prop2");
log.info("logic complete ... deleting the {} and {} collections", toColl, fromColl);

// try to clean up
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ public void setUp() throws Exception {

super.setUp();
solrCluster = new MiniSolrCloudCluster(3, createTempDir(), JettyConfig.builder().build());
// set some system properties for use by tests
System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo");
solrCluster.uploadConfigSet(TEST_PATH().resolve("collection1/conf"), "conf1");
solrCluster.uploadConfigSet(configset("configset-2"), "conf2");
}
Expand All @@ -66,8 +63,6 @@ public void setUp() throws Exception {
public void tearDown() throws Exception {
solrCluster.shutdown();
System.clearProperty("solr.statsCache");
System.clearProperty("solr.test.sys.prop1");
System.clearProperty("solr.test.sys.prop2");
super.tearDown();
}

Expand Down
Loading
Loading