You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2021/10/18 09:51:38 UTC

[lucene-solr] branch branch_8x updated (0fb62e5 -> 277e1e0)

This is an automated email from the ASF dual-hosted git repository.

cpoerschke pushed a change to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


    from 0fb62e5  LUCENE-10179 No longer check for release status on mirrors (#2592)
     new d3fbfd4  SOLR-15676: add UpdateLogCloudTest (#328)
     new 277e1e0  SOLR-15676, SOLR-15687: make UpdateLogCloudTest repeatable (via @Before and @After) (#341)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../solr/handler/component/UpdateLogCloudTest.java | 130 +++++++++++++++++++++
 1 file changed, 130 insertions(+)
 create mode 100644 solr/core/src/test/org/apache/solr/handler/component/UpdateLogCloudTest.java

[lucene-solr] 01/02: SOLR-15676: add UpdateLogCloudTest (#328)

Posted by cp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cpoerschke pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit d3fbfd4d5c96eca95d94c9c4d0977ed9b7551db6
Author: Christine Poerschke <cp...@apache.org>
AuthorDate: Thu Oct 7 10:28:00 2021 +0100

    SOLR-15676: add UpdateLogCloudTest (#328)
    
    (cherry picked from commit 75d6ac8a2787234e604a95414e198d1f193b7346)
---
 .../solr/handler/component/UpdateLogCloudTest.java | 118 +++++++++++++++++++++
 1 file changed, 118 insertions(+)

diff --git a/solr/core/src/test/org/apache/solr/handler/component/UpdateLogCloudTest.java b/solr/core/src/test/org/apache/solr/handler/component/UpdateLogCloudTest.java
new file mode 100644
index 0000000..010fda2
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/handler/component/UpdateLogCloudTest.java
@@ -0,0 +1,118 @@
+/*
+ * 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.component;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.embedded.JettySolrRunner;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.request.QueryRequest;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.cloud.AbstractDistribZkTestBase;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.apache.solr.common.util.NamedList;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class UpdateLogCloudTest extends SolrCloudTestCase {
+
+  private static String COLLECTION;
+  private static final int NUM_SHARDS = 1;
+  private static final int NUM_REPLICAS = 4;
+
+  @BeforeClass
+  public static void setupCluster() throws Exception {
+
+    // decide collection name ...
+    COLLECTION = "collection"+(1+random().nextInt(100)) ;
+
+    // create and configure cluster
+    configureCluster(NUM_SHARDS*NUM_REPLICAS /* nodeCount */)
+    .addConfig("conf", configset("cloud-dynamic"))
+    .configure();
+
+    // create an empty collection
+    CollectionAdminRequest
+    .createCollection(COLLECTION, "conf", NUM_SHARDS, NUM_REPLICAS)
+    .processAndWait(cluster.getSolrClient(), DEFAULT_TIMEOUT);
+    AbstractDistribZkTestBase.waitForRecoveriesToFinish(COLLECTION, cluster.getSolrClient().getZkStateReader(), false, true, DEFAULT_TIMEOUT);
+  }
+
+  @Test
+  public void test() throws Exception {
+
+    final List<SolrClient> solrClients = new ArrayList<>();
+    for (JettySolrRunner jettySolrRunner : cluster.getJettySolrRunners()) {
+      solrClients.add(jettySolrRunner.newClient());
+    }
+
+    cluster.getJettySolrRunner(0).stop();
+
+    new UpdateRequest()
+    .add(sdoc("id", "1", "a_t", "one"))
+    .deleteById("2")
+    .deleteByQuery("a_t:three")
+    .commit(cluster.getSolrClient(), COLLECTION);
+
+    cluster.getJettySolrRunner(0).start();
+    AbstractDistribZkTestBase.waitForRecoveriesToFinish(COLLECTION, cluster.getSolrClient().getZkStateReader(), false, true, DEFAULT_TIMEOUT);
+
+    int idx = 0;
+    for (SolrClient solrClient : solrClients) {
+      implTest(solrClient, idx==0 ? 0 : 3);
+      ++idx;
+    }
+
+    for (SolrClient solrClient : solrClients) {
+      solrClient.close();
+    }
+
+  }
+
+  @SuppressWarnings("unchecked")
+  private void implTest(SolrClient solrClient, int numExpected) throws Exception {
+
+    final QueryRequest reqV = new QueryRequest(params("qt","/get", "getVersions","12345"));
+    final NamedList<?> rspV = solrClient.request(reqV, COLLECTION);
+    final List<Long> versions = (List<Long>)rspV.get("versions");
+    assertEquals(numExpected, versions.size());
+    if (numExpected == 0) {
+      return;
+    }
+
+    final LinkedList<Long> absVersions = new LinkedList<>();
+    for (Long version : versions) {
+      absVersions.add(Math.abs(version));
+    }
+    Collections.sort(absVersions);
+    final Long minVersion = absVersions.getFirst();
+    final Long maxVersion = absVersions.getLast();
+
+    for (boolean skipDbq : new boolean[] { false, true }) {
+      final QueryRequest reqU = new QueryRequest(params("qt","/get", "getUpdates", minVersion + "..."+maxVersion, "skipDbq", Boolean.toString(skipDbq)));
+      final NamedList<?> rspU = solrClient.request(reqU, COLLECTION);
+      final List<?> updatesList = (List<?>)rspU.get("updates");
+      assertEquals(numExpected + (skipDbq ? 1 : 0), updatesList.size());
+    }
+
+  }
+
+}

[lucene-solr] 02/02: SOLR-15676, SOLR-15687: make UpdateLogCloudTest repeatable (via @Before and @After) (#341)

Posted by cp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cpoerschke pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 277e1e064559117ccbc3004be88160bf24380d55
Author: Christine Poerschke <cp...@apache.org>
AuthorDate: Mon Oct 18 09:37:29 2021 +0100

    SOLR-15676, SOLR-15687: make UpdateLogCloudTest repeatable (via @Before and @After) (#341)
    
    (cherry picked from commit d63d316c65afaa93f177f7175455d1c7d029f334)
---
 .../solr/handler/component/UpdateLogCloudTest.java   | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/solr/core/src/test/org/apache/solr/handler/component/UpdateLogCloudTest.java b/solr/core/src/test/org/apache/solr/handler/component/UpdateLogCloudTest.java
index 010fda2..9868657 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/UpdateLogCloudTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/UpdateLogCloudTest.java
@@ -29,6 +29,8 @@ import org.apache.solr.client.solrj.request.UpdateRequest;
 import org.apache.solr.cloud.AbstractDistribZkTestBase;
 import org.apache.solr.cloud.SolrCloudTestCase;
 import org.apache.solr.common.util.NamedList;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -40,14 +42,17 @@ public class UpdateLogCloudTest extends SolrCloudTestCase {
 
   @BeforeClass
   public static void setupCluster() throws Exception {
-
-    // decide collection name ...
-    COLLECTION = "collection"+(1+random().nextInt(100)) ;
-
     // create and configure cluster
     configureCluster(NUM_SHARDS*NUM_REPLICAS /* nodeCount */)
     .addConfig("conf", configset("cloud-dynamic"))
     .configure();
+  }
+
+  @Before
+  public void beforeTest() throws Exception {
+
+    // decide collection name ...
+    COLLECTION = "collection"+(1+random().nextInt(100)) ;
 
     // create an empty collection
     CollectionAdminRequest
@@ -56,6 +61,13 @@ public class UpdateLogCloudTest extends SolrCloudTestCase {
     AbstractDistribZkTestBase.waitForRecoveriesToFinish(COLLECTION, cluster.getSolrClient().getZkStateReader(), false, true, DEFAULT_TIMEOUT);
   }
 
+  @After
+  public void afterTest() throws Exception {
+    CollectionAdminRequest
+    .deleteCollection(COLLECTION)
+    .process(cluster.getSolrClient());
+  }
+
   @Test
   public void test() throws Exception {