You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2021/09/15 00:22:54 UTC

[GitHub] [solr] madrob commented on a change in pull request #238: SOLR-15286 A brand new follower in the legacy mode should wait to replicate index before reporting healthy

madrob commented on a change in pull request #238:
URL: https://github.com/apache/solr/pull/238#discussion_r708747482



##########
File path: solr/core/src/test/org/apache/solr/handler/TestHealthCheckHandlerLegacyMode.java
##########
@@ -0,0 +1,208 @@
+/*
+ * 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 org.apache.lucene.util.LuceneTestCase.Slow;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
+import org.apache.solr.client.solrj.embedded.JettySolrRunner;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.client.solrj.request.HealthCheckRequest;
+import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.util.TestInjection;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.apache.solr.handler.ReplicationTestHelper.*;
+
+
+/**
+ * Test for HealthCheckHandler in legacy mode
+ *
+ *
+ */
+@Slow
+@SuppressSSL     // Currently unknown why SSL does not work with this test
+public class TestHealthCheckHandlerLegacyMode extends SolrTestCaseJ4 {
+    HttpSolrClient leaderClientHealthCheck, followerClientHealthCheck;
+
+    JettySolrRunner leaderJetty, followerJetty;
+    HttpSolrClient leaderClient, followerClient;
+    ReplicationTestHelper.SolrInstance leader = null, follower = null;
+
+    private static String context = "/solr";
+
+    static int nDocs = 500;
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+
+        systemSetPropertySolrDisableUrlAllowList("true");
+
+        leader = new ReplicationTestHelper.SolrInstance(createTempDir("solr-instance").toFile(), "leader", null);
+        leader.setUp();
+        leaderJetty = ReplicationTestHelper.createAndStartJetty(leader);
+        leaderClient = ReplicationTestHelper.createNewSolrClient(buildUrl(leaderJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME);
+        leaderClientHealthCheck = ReplicationTestHelper.createNewSolrClient(buildUrl(leaderJetty.getLocalPort(), context));
+
+        follower = new SolrInstance(createTempDir("solr-instance").toFile(), "follower", leaderJetty.getLocalPort());
+        follower.setUp();
+        followerJetty = createAndStartJetty(follower);
+        followerClient = ReplicationTestHelper.createNewSolrClient(buildUrl(followerJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME);
+        followerClientHealthCheck = ReplicationTestHelper.createNewSolrClient(buildUrl(followerJetty.getLocalPort(), context));
+
+        System.setProperty("solr.indexfetcher.sotimeout2", "45000");
+    }
+
+    public void clearIndexWithReplication() throws Exception {
+        if (numFound(ReplicationTestHelper.query("*:*", leaderClient)) != 0) {
+            leaderClient.deleteByQuery("*:*");
+            leaderClient.commit();
+            // wait for replication to sync & verify
+            assertEquals(0, numFound(rQuery(0, "*:*", followerClient)));
+        }
+    }
+
+    @Override
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+        if (null != leaderJetty) {
+            leaderJetty.stop();
+            leaderJetty = null;
+        }
+        if (null != followerJetty) {
+            followerJetty.stop();
+            followerJetty = null;
+        }
+        if (null != leaderClient) {
+            leaderClient.close();
+            leaderClient = null;
+        }
+        if (null != followerClient) {
+            followerClient.close();
+            followerClient = null;
+        }
+        if (null != leaderClientHealthCheck) {
+            leaderClientHealthCheck.close();
+            leaderClientHealthCheck = null;
+        }
+
+        if (null != followerClientHealthCheck) {
+            followerClientHealthCheck.close();
+            followerClientHealthCheck = null;
+        }
+        System.clearProperty("solr.indexfetcher.sotimeout");
+    }
+
+
+    @Test
+    // keep this
+    public void doTestHealthCheckWithReplication() throws Exception {
+
+        TestInjection.delayBeforeFollowerCommitRefresh = random().nextInt(10);
+
+        // stop replication so that the follower doesn't pull the index
+        invokeReplicationCommand(buildUrl(followerJetty.getLocalPort(), context) + "/" + DEFAULT_TEST_CORENAME, "disablepoll");
+
+        nDocs--;

Review comment:
       @praste did the fix to this get missed?




-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org