This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 9d7cc2884e8 SolrTestCase: reset system properties per test (#5056)
9d7cc2884e8 is described below
commit 9d7cc2884e8a843f33076e8171401e3f39d1f533
Author: David Smiley <[email protected]>
AuthorDate: Wed Oct 7 18:21:33 2026 -0400
SolrTestCase: reset system properties per test (#5056)
---
.../src/java/org/apache/solr/SolrTestCase.java | 20 ++++++++------------
.../src/java/org/apache/solr/SolrTestCaseJ4.java | 6 ------
2 files changed, 8 insertions(+), 18 deletions(-)
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
index 554f65b8d49..e467e583b39 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
@@ -57,12 +57,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * All Solr test cases should derive from this class eventually. This is
originally a result of
- * async logging, see: SOLR-12055 and associated. To enable async logging, we
must gracefully shut
- * down logging. Many Solr tests subclass LuceneTestCase.
+ * All Solr test cases should derive from this class.
*
- * <p>Rather than add the cruft from SolrTestCaseJ4 to all the Solr tests that
currently subclass
- * LuceneTestCase, we'll add the shutdown to this class and subclass it.
+ * <p><em>Be conservative in what's here; avoid arbitrary/misc utilities.</em>
*
* <p>Other changes that should affect every Solr test case may go here if
they don't require the
* added capabilities in SolrTestCaseJ4.
@@ -195,11 +192,14 @@ public class SolrTestCase extends LuceneTestCase {
}
@AfterClass
- public static void afterClassShutdownLogging() {
+ public static void afterClassSolrTestCase() {
StartupLoggingUtils.shutdown();
+ OpenTelemetryConfigurator.resetForTest();
}
- @Rule public TestRule methodRules = new LogLevelTestRule();
+ @Rule
+ public TestRule solrTestRules =
+ RuleChain.outerRule(new SystemPropertiesRestoreRule()).around(new
LogLevelTestRule());
/**
* Special hook for sanity checking if any tests trigger failures when an
Assumption failure
@@ -213,12 +213,8 @@ public class SolrTestCase extends LuceneTestCase {
assumeFalse(PROP + " == true", systemPropertyAsBoolean(PROP, false));
}
- @AfterClass
- public static void afterSolrTestCase() {
- OpenTelemetryConfigurator.resetForTest();
- }
-
// UTILITY METHODS FOLLOW
+ // NOTE: be very conservative in what we add!
public static void assertJSONEquals(String expected, String actual) {
Object json1 = fromJSONString(expected);
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 fc9416924fa..402ce3c9633 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
@@ -22,7 +22,6 @@ import static org.hamcrest.core.StringContains.containsString;
import com.carrotsearch.randomizedtesting.RandomizedContext;
import com.carrotsearch.randomizedtesting.RandomizedTest;
-import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.StringReader;
@@ -132,9 +131,6 @@ import org.apache.zookeeper.KeeperException;
import org.hamcrest.Matcher;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TestRule;
import org.noggit.CharArr;
import org.noggit.JSONUtil;
import org.noggit.ObjectBuilder;
@@ -230,8 +226,6 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
// thread will read the latest value
public static volatile SSLTestConfig sslConfig;
- @Rule public TestRule solrTestRules = RuleChain.outerRule(new
SystemPropertiesRestoreRule());
-
@BeforeClass
public static void setupTestCases() {
if (ignoreExceptionMuter != null) {