Re: [PR] SOLR-18280: Fix flaky TestReplicationHandler.testUrlAllowList [solr]
nick-boss-tech commented on code in PR #4996:
URL: https://github.com/apache/solr/pull/4996#discussion_r4161832034
##
changelog/unreleased/SOLR-18280.yml:
##
@@ -0,0 +1,7 @@
+title: Fix flaky TestReplicationHandler.testUrlAllowList (honor
TEST_URL_ALLOW_LIST, stop wrapping doTestDetails).
Review Comment:
🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
Done; removed the changelog entry.
##
solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java:
##
@@ -144,6 +144,8 @@ public void clearIndexWithReplication() throws Exception {
@After
public void tearDown() throws Exception {
super.tearDown();
+System.clearProperty(AllowListUrlChecker.ENABLE_URL_ALLOW_LIST);
+System.clearProperty(TEST_URL_ALLOW_LIST);
Review Comment:
🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
Done; removed both clears. I had argued for keeping the tearDown one
earlier; that was wrong, the harness rule covers it.
##
solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerUrlAllowList.java:
##
@@ -0,0 +1,135 @@
+/*
+ * 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.handler;
+
+import static org.hamcrest.CoreMatchers.containsString;
+
+import java.nio.file.Path;
+import java.util.List;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.embedded.JettySolrRunner;
+import org.apache.solr.handler.ReplicationTestHelper.SolrInstance;
+import org.apache.solr.security.AllowListUrlChecker;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Non-nightly coverage for SOLR-18280. {@link TestReplicationHandler} is
{@code @Nightly}; the
Review Comment:
🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
Done; reworded without the ticket reference. Also removed the manual
property save/restore in that test since the rule covers it too.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] SOLR-18280: Fix flaky TestReplicationHandler.testUrlAllowList [solr]
dsmiley commented on code in PR #4996:
URL: https://github.com/apache/solr/pull/4996#discussion_r4161623697
##
changelog/unreleased/SOLR-18280.yml:
##
@@ -0,0 +1,7 @@
+title: Fix flaky TestReplicationHandler.testUrlAllowList (honor
TEST_URL_ALLOW_LIST, stop wrapping doTestDetails).
Review Comment:
fixing tests isn't changelog worthy.
##
solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java:
##
@@ -144,6 +144,8 @@ public void clearIndexWithReplication() throws Exception {
@After
public void tearDown() throws Exception {
super.tearDown();
+System.clearProperty(AllowListUrlChecker.ENABLE_URL_ALLOW_LIST);
+System.clearProperty(TEST_URL_ALLOW_LIST);
Review Comment:
Solr's test infra resets all System properties without tests needing to do
this. It's in SolrTestCase as a Rule
##
solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerUrlAllowList.java:
##
@@ -0,0 +1,135 @@
+/*
+ * 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.handler;
+
+import static org.hamcrest.CoreMatchers.containsString;
+
+import java.nio.file.Path;
+import java.util.List;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.embedded.JettySolrRunner;
+import org.apache.solr.handler.ReplicationTestHelper.SolrInstance;
+import org.apache.solr.security.AllowListUrlChecker;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Non-nightly coverage for SOLR-18280. {@link TestReplicationHandler} is
{@code @Nightly}; the
Review Comment:
Lets drop the JIRA reference here, unless you think there's great context
for someone reading later.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] SOLR-18280: Fix flaky TestReplicationHandler.testUrlAllowList [solr]
nick-boss-tech commented on code in PR #4996:
URL: https://github.com/apache/solr/pull/4996#discussion_r4161243538
##
solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java:
##
@@ -255,19 +257,47 @@ public void doTestHandlerPathUnchanged() {
@Test
public void testUrlAllowList() throws Exception {
-// Run another test with URL allow-list enabled and allow-list is empty.
-// Expect an exception because the leader URL is not allowed.
+// Allow-list denial during doTestDetails() is not reliably a
SolrException (SOLR-18280).
System.setProperty(AllowListUrlChecker.ENABLE_URL_ALLOW_LIST, "true");
-SolrException e = expectThrows(SolrException.class, this::doTestDetails);
-assertTrue(
-e.getMessage()
-.contains("nor in the configured '" +
AllowListUrlChecker.URL_ALLOW_LIST + "'"));
-
-// Set the allow-list to allow the leader URL.
-// Expect the same test to pass now.
-System.setProperty(
-TEST_URL_ALLOW_LIST, leaderJetty.getBaseUrl() + "," +
followerJetty.getBaseUrl());
-doTestDetails();
+try {
+ leaderJetty.stop();
+ leaderJetty = createAndStartJetty(leader);
+ leaderClient.close();
+ leaderClient =
+ ReplicationTestHelper.createNewSolrClient(
+ buildUrl(leaderJetty.getLocalPort()), DEFAULT_TEST_CORENAME);
+
+ AllowListUrlChecker checker =
leaderJetty.getCoreContainer().getAllowListUrlChecker();
+ assertTrue(checker.isEnabled());
+ SolrException denied =
+ expectThrows(
+ SolrException.class,
+ () ->
checker.checkAllowList(List.of("http://127.0.0.1:7574/solr/collection1";)));
+ assertThat(denied.getMessage(),
containsString(AllowListUrlChecker.URL_ALLOW_LIST));
+
+ System.setProperty(TEST_URL_ALLOW_LIST,
buildUrl(leaderJetty.getLocalPort()));
+ follower.setTestPort(leaderJetty.getLocalPort());
+ follower.copyConfigFile(CONF_DIR + "solrconfig-follower.xml",
"solrconfig.xml");
+ followerJetty.stop();
+ followerJetty = createAndStartJetty(follower);
+ followerClient.close();
+ followerClient =
+ ReplicationTestHelper.createNewSolrClient(
+ buildUrl(followerJetty.getLocalPort()), DEFAULT_TEST_CORENAME);
+
+ followerJetty
+ .getCoreContainer()
+ .getAllowListUrlChecker()
+ .checkAllowList(List.of(buildUrl(leaderJetty.getLocalPort(;
+
+ index(leaderClient, "id", "allow-list-1", "name", "allowed");
+ leaderClient.commit();
+ pullFromTo(leaderJetty, followerJetty);
+ rQuery(1, "id:allow-list-1", followerClient);
+} finally {
+ System.clearProperty(TEST_URL_ALLOW_LIST);
Review Comment:
🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
Done — removed the finally block in c093a3eae, the tearDown clear stays.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] SOLR-18280: Fix flaky TestReplicationHandler.testUrlAllowList [solr]
VishnuPriyaChandraSekar commented on code in PR #4996:
URL: https://github.com/apache/solr/pull/4996#discussion_r4161112256
##
solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java:
##
@@ -255,19 +257,47 @@ public void doTestHandlerPathUnchanged() {
@Test
public void testUrlAllowList() throws Exception {
-// Run another test with URL allow-list enabled and allow-list is empty.
-// Expect an exception because the leader URL is not allowed.
+// Allow-list denial during doTestDetails() is not reliably a
SolrException (SOLR-18280).
System.setProperty(AllowListUrlChecker.ENABLE_URL_ALLOW_LIST, "true");
-SolrException e = expectThrows(SolrException.class, this::doTestDetails);
-assertTrue(
-e.getMessage()
-.contains("nor in the configured '" +
AllowListUrlChecker.URL_ALLOW_LIST + "'"));
-
-// Set the allow-list to allow the leader URL.
-// Expect the same test to pass now.
-System.setProperty(
-TEST_URL_ALLOW_LIST, leaderJetty.getBaseUrl() + "," +
followerJetty.getBaseUrl());
-doTestDetails();
+try {
+ leaderJetty.stop();
+ leaderJetty = createAndStartJetty(leader);
+ leaderClient.close();
+ leaderClient =
+ ReplicationTestHelper.createNewSolrClient(
+ buildUrl(leaderJetty.getLocalPort()), DEFAULT_TEST_CORENAME);
+
+ AllowListUrlChecker checker =
leaderJetty.getCoreContainer().getAllowListUrlChecker();
+ assertTrue(checker.isEnabled());
+ SolrException denied =
+ expectThrows(
+ SolrException.class,
+ () ->
checker.checkAllowList(List.of("http://127.0.0.1:7574/solr/collection1";)));
+ assertThat(denied.getMessage(),
containsString(AllowListUrlChecker.URL_ALLOW_LIST));
+
+ System.setProperty(TEST_URL_ALLOW_LIST,
buildUrl(leaderJetty.getLocalPort()));
+ follower.setTestPort(leaderJetty.getLocalPort());
+ follower.copyConfigFile(CONF_DIR + "solrconfig-follower.xml",
"solrconfig.xml");
+ followerJetty.stop();
+ followerJetty = createAndStartJetty(follower);
+ followerClient.close();
+ followerClient =
+ ReplicationTestHelper.createNewSolrClient(
+ buildUrl(followerJetty.getLocalPort()), DEFAULT_TEST_CORENAME);
+
+ followerJetty
+ .getCoreContainer()
+ .getAllowListUrlChecker()
+ .checkAllowList(List.of(buildUrl(leaderJetty.getLocalPort(;
+
+ index(leaderClient, "id", "allow-list-1", "name", "allowed");
+ leaderClient.commit();
+ pullFromTo(leaderJetty, followerJetty);
+ rQuery(1, "id:allow-list-1", followerClient);
+} finally {
+ System.clearProperty(TEST_URL_ALLOW_LIST);
Review Comment:
Since tearDown() runs after each test, it makes sense to remove the
System.clearProperty in the finally block (we don't want to repeat things)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] SOLR-18280: Fix flaky TestReplicationHandler.testUrlAllowList [solr]
nick-boss-tech commented on code in PR #4996:
URL: https://github.com/apache/solr/pull/4996#discussion_r4160951510
##
solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java:
##
@@ -255,19 +257,47 @@ public void doTestHandlerPathUnchanged() {
@Test
public void testUrlAllowList() throws Exception {
-// Run another test with URL allow-list enabled and allow-list is empty.
-// Expect an exception because the leader URL is not allowed.
+// Allow-list denial during doTestDetails() is not reliably a
SolrException (SOLR-18280).
System.setProperty(AllowListUrlChecker.ENABLE_URL_ALLOW_LIST, "true");
-SolrException e = expectThrows(SolrException.class, this::doTestDetails);
-assertTrue(
-e.getMessage()
-.contains("nor in the configured '" +
AllowListUrlChecker.URL_ALLOW_LIST + "'"));
-
-// Set the allow-list to allow the leader URL.
-// Expect the same test to pass now.
-System.setProperty(
-TEST_URL_ALLOW_LIST, leaderJetty.getBaseUrl() + "," +
followerJetty.getBaseUrl());
-doTestDetails();
+try {
+ leaderJetty.stop();
+ leaderJetty = createAndStartJetty(leader);
+ leaderClient.close();
+ leaderClient =
+ ReplicationTestHelper.createNewSolrClient(
+ buildUrl(leaderJetty.getLocalPort()), DEFAULT_TEST_CORENAME);
+
+ AllowListUrlChecker checker =
leaderJetty.getCoreContainer().getAllowListUrlChecker();
+ assertTrue(checker.isEnabled());
+ SolrException denied =
+ expectThrows(
+ SolrException.class,
+ () ->
checker.checkAllowList(List.of("http://127.0.0.1:7574/solr/collection1";)));
+ assertThat(denied.getMessage(),
containsString(AllowListUrlChecker.URL_ALLOW_LIST));
+
+ System.setProperty(TEST_URL_ALLOW_LIST,
buildUrl(leaderJetty.getLocalPort()));
+ follower.setTestPort(leaderJetty.getLocalPort());
+ follower.copyConfigFile(CONF_DIR + "solrconfig-follower.xml",
"solrconfig.xml");
+ followerJetty.stop();
+ followerJetty = createAndStartJetty(follower);
+ followerClient.close();
+ followerClient =
+ ReplicationTestHelper.createNewSolrClient(
+ buildUrl(followerJetty.getLocalPort()), DEFAULT_TEST_CORENAME);
+
+ followerJetty
+ .getCoreContainer()
+ .getAllowListUrlChecker()
+ .checkAllowList(List.of(buildUrl(leaderJetty.getLocalPort(;
+
+ index(leaderClient, "id", "allow-list-1", "name", "allowed");
+ leaderClient.commit();
+ pullFromTo(leaderJetty, followerJetty);
+ rQuery(1, "id:allow-list-1", followerClient);
+} finally {
+ System.clearProperty(TEST_URL_ALLOW_LIST);
Review Comment:
🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
Good question — there are actually two clears: this finally block and the
same pair in tearDown(). Before this PR, nothing cleared these properties at
all. setUp sets the flag to "false", the old test flipped it to "true", and a
failure mid-test would leak that into whatever ran next in the same JVM.
The tearDown clear is the one that matters: it runs after every test even on
failure. The finally block here is redundant with it — JUnit always runs
tearDown, so the finally can't do anything tearDown wouldn't already do.
Want me to remove the finally block and keep just the tearDown clear, or
keep both?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] SOLR-18280: Fix flaky TestReplicationHandler.testUrlAllowList [solr]
VishnuPriyaChandraSekar commented on code in PR #4996:
URL: https://github.com/apache/solr/pull/4996#discussion_r4160855908
##
solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java:
##
@@ -255,19 +257,47 @@ public void doTestHandlerPathUnchanged() {
@Test
public void testUrlAllowList() throws Exception {
-// Run another test with URL allow-list enabled and allow-list is empty.
-// Expect an exception because the leader URL is not allowed.
+// Allow-list denial during doTestDetails() is not reliably a
SolrException (SOLR-18280).
System.setProperty(AllowListUrlChecker.ENABLE_URL_ALLOW_LIST, "true");
-SolrException e = expectThrows(SolrException.class, this::doTestDetails);
-assertTrue(
-e.getMessage()
-.contains("nor in the configured '" +
AllowListUrlChecker.URL_ALLOW_LIST + "'"));
-
-// Set the allow-list to allow the leader URL.
-// Expect the same test to pass now.
-System.setProperty(
-TEST_URL_ALLOW_LIST, leaderJetty.getBaseUrl() + "," +
followerJetty.getBaseUrl());
-doTestDetails();
+try {
+ leaderJetty.stop();
+ leaderJetty = createAndStartJetty(leader);
+ leaderClient.close();
+ leaderClient =
+ ReplicationTestHelper.createNewSolrClient(
+ buildUrl(leaderJetty.getLocalPort()), DEFAULT_TEST_CORENAME);
+
+ AllowListUrlChecker checker =
leaderJetty.getCoreContainer().getAllowListUrlChecker();
+ assertTrue(checker.isEnabled());
+ SolrException denied =
+ expectThrows(
+ SolrException.class,
+ () ->
checker.checkAllowList(List.of("http://127.0.0.1:7574/solr/collection1";)));
+ assertThat(denied.getMessage(),
containsString(AllowListUrlChecker.URL_ALLOW_LIST));
+
+ System.setProperty(TEST_URL_ALLOW_LIST,
buildUrl(leaderJetty.getLocalPort()));
+ follower.setTestPort(leaderJetty.getLocalPort());
+ follower.copyConfigFile(CONF_DIR + "solrconfig-follower.xml",
"solrconfig.xml");
+ followerJetty.stop();
+ followerJetty = createAndStartJetty(follower);
+ followerClient.close();
+ followerClient =
+ ReplicationTestHelper.createNewSolrClient(
+ buildUrl(followerJetty.getLocalPort()), DEFAULT_TEST_CORENAME);
+
+ followerJetty
+ .getCoreContainer()
+ .getAllowListUrlChecker()
+ .checkAllowList(List.of(buildUrl(leaderJetty.getLocalPort(;
+
+ index(leaderClient, "id", "allow-list-1", "name", "allowed");
+ leaderClient.commit();
+ pullFromTo(leaderJetty, followerJetty);
+ rQuery(1, "id:allow-list-1", followerClient);
+} finally {
+ System.clearProperty(TEST_URL_ALLOW_LIST);
Review Comment:
`tearDown()` clears this system property, curious to know why the system
property has to be cleared here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
