dsmiley commented on a change in pull request #455: SOLR-12638
URL: https://github.com/apache/lucene-solr/pull/455#discussion_r269405154
 
 

 ##########
 File path: 
solr/core/src/test/org/apache/solr/cloud/AtomicUpdateBlockShardedTest.java
 ##########
 @@ -0,0 +1,187 @@
+/*
+ * 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.cloud;
+
+import java.util.List;
+
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrDocument;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.SolrParams;
+import org.junit.Test;
+
+public class AtomicUpdateBlockShardedTest extends 
AbstractFullDistribZkTestBase {
+
+  public AtomicUpdateBlockShardedTest() {
+    stress = 0;
+    sliceCount = 4;
+    schemaString = "sharded-block-schema.xml";
+  }
+
+  @Override
+  protected String getCloudSolrConfig() {
+    return "solrconfig-block-atomic-update.xml";
+  }
+
+  @Override
+  protected String getCloudSchemaFile() {
+    return "sharded-block-schema.xml";
+  }
+
+  @Test
+  @ShardsFixed(num = 4)
+  public void test() throws Exception {
+    boolean testFinished = false;
+    try {
+      doNestedInplaceUpdateTest();
+      doRootShardRoutingTest();
+      testFinished = true;
+    } finally {
+      if (!testFinished) {
+        printLayoutOnTearDown = true;
+      }
+    }
+  }
+
+  public void doRootShardRoutingTest() throws Exception {
+    assertEquals(4, 
cloudClient.getZkStateReader().getClusterState().getCollection(DEFAULT_COLLECTION).getSlices().size());
+    final String[] ids = {"c", "d", "e", "f"};
+
+    assertEquals("size of ids to index should be the same as the number of 
clients", clients.size(), ids.length);
+    // for now,  we know how ranges will be distributed to shards.
+    // may have to look it up in clusterstate if that assumption changes.
+
+    SolrInputDocument doc = sdoc("id", "a", "level_s", "root");
+
+    final SolrParams params = new ModifiableSolrParams().set("update.chain", 
"nested-rtg").set("wt", "json").set("_route_", "a");
+
+    int which = (params.get("_route_").hashCode() & 0x7fffffff) % 
clients.size();
+    SolrClient aClient = clients.get(which);
+
+    indexDoc(aClient, params, doc);
+
+    aClient.commit();
+
+    doc = sdoc("id", "a", "children", map("add", sdocs(sdoc("id", "b", 
"level_s", "child"))));
+
+    indexDoc(aClient, params, doc);
+    aClient.commit();
+
+    int i = 0;
+    for (SolrClient client : clients) {
+
+      doc = sdoc("id", "b", "grandChildren", map("add", sdocs(sdoc("id", 
ids[i], "level_s", "grand_child"))));
+
+      indexDoc(client, params, doc);
+      client.commit();
 
 Review comment:
   The commits here could be made to occur randomly; I don't think semantically 
they need to be there.  Only truly needed before a query.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to