risdenk commented on code in PR #1105:
URL: https://github.com/apache/solr/pull/1105#discussion_r1002111360


##########
solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionReloadTest.java:
##########
@@ -86,4 +96,107 @@ public void testReloadedLeaderStateAfterZkSessionLoss() 
throws Exception {
 
     log.info("testReloadedLeaderStateAfterZkSessionLoss succeeded ... shutting 
down now!");
   }
+
+  @Repeat(iterations = 5)
+  public void testCreateReloadDeleteAllNrt() throws Exception {
+    testCreateReloadDelete("testCreateReloadDeleteAllNrt", 3, 0, 0);
+  }
+
+  @Repeat(iterations = 5)
+  public void testCreateReloadDeleteAllTlog() throws Exception {
+    testCreateReloadDelete("testCreateReloadDeleteAllTlog", 0, 3, 0);
+  }
+
+  @Repeat(iterations = 5)
+  public void testCreateReloadDeletePull() throws Exception {
+    testCreateReloadDelete("testCreateReloadDeletePull", 0, 1, 2);
+  }
+
+  private void testCreateReloadDelete(
+      String collectionName, int nrtReplicas, int tlogReplicas, int 
pullReplicas) throws Exception {
+    int numShards = 3;
+    createCollection(numShards, nrtReplicas, tlogReplicas, pullReplicas, 
collectionName);
+    boolean reloaded = false;
+    while (true) {
+      waitForState(
+          "Timeout waiting for collection " + collectionName,
+          collectionName,
+          clusterShape(numShards, numShards * (nrtReplicas + tlogReplicas + 
pullReplicas)));
+      if (reloaded) {
+        break;
+      } else {
+        // reload
+        assertSuccessfulAdminRequest(
+            CollectionAdminRequest.reloadCollection(collectionName)
+                .process(cluster.getSolrClient()));
+        reloaded = true;
+      }
+    }
+    assertSuccessfulAdminRequest(
+        
CollectionAdminRequest.deleteCollection(collectionName).process(cluster.getSolrClient()));
+  }
+
+  private void assertSuccessfulAdminRequest(CollectionAdminResponse response) {
+    assertEquals("Unexpected response status", 0, response.getStatus());
+    assertTrue("Unsuccessful response: " + response, response.isSuccess());
+  }
+
+  private void createCollection(
+      int numShards, int nrtReplicas, int tlogReplicas, int pullReplicas, 
String collectionName)
+      throws SolrServerException, IOException {
+    switch (random().nextInt(3)) {
+      case 0:
+        log.info("Creating collection with SolrJ");
+        // Sometimes use SolrJ
+        assertSuccessfulAdminRequest(
+            CollectionAdminRequest.createCollection(
+                    collectionName, "conf", numShards, nrtReplicas, 
tlogReplicas, pullReplicas)
+                .process(cluster.getSolrClient()));
+        break;
+      case 1:
+        log.info("Creating collection with V1 API");
+        // Sometimes use v1 API
+        String url =
+            String.format(
+                Locale.ROOT,
+                
"%s/admin/collections?action=CREATE&name=%s&collection.configName=%s&numShards=%s&maxShardsPerNode=%s&nrtReplicas=%s&tlogReplicas=%s&pullReplicas=%s",
+                cluster.getRandomJetty(random()).getBaseUrl(),
+                collectionName,
+                "conf",
+                numShards,
+                100, // maxShardsPerNode
+                nrtReplicas,
+                tlogReplicas,
+                pullReplicas);
+        HttpGet createCollectionGet = new HttpGet(url);
+        ((CloudLegacySolrClient) cluster.getSolrClient())

Review Comment:
   Do we need this to be `CloudLegacySolrClient`?



##########
solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionReloadTest.java:
##########
@@ -86,4 +96,107 @@ public void testReloadedLeaderStateAfterZkSessionLoss() 
throws Exception {
 
     log.info("testReloadedLeaderStateAfterZkSessionLoss succeeded ... shutting 
down now!");
   }
+
+  @Repeat(iterations = 5)
+  public void testCreateReloadDeleteAllNrt() throws Exception {
+    testCreateReloadDelete("testCreateReloadDeleteAllNrt", 3, 0, 0);
+  }
+
+  @Repeat(iterations = 5)
+  public void testCreateReloadDeleteAllTlog() throws Exception {
+    testCreateReloadDelete("testCreateReloadDeleteAllTlog", 0, 3, 0);
+  }
+
+  @Repeat(iterations = 5)
+  public void testCreateReloadDeletePull() throws Exception {
+    testCreateReloadDelete("testCreateReloadDeletePull", 0, 1, 2);
+  }
+
+  private void testCreateReloadDelete(
+      String collectionName, int nrtReplicas, int tlogReplicas, int 
pullReplicas) throws Exception {
+    int numShards = 3;
+    createCollection(numShards, nrtReplicas, tlogReplicas, pullReplicas, 
collectionName);
+    boolean reloaded = false;
+    while (true) {
+      waitForState(
+          "Timeout waiting for collection " + collectionName,
+          collectionName,
+          clusterShape(numShards, numShards * (nrtReplicas + tlogReplicas + 
pullReplicas)));
+      if (reloaded) {
+        break;
+      } else {
+        // reload
+        assertSuccessfulAdminRequest(
+            CollectionAdminRequest.reloadCollection(collectionName)
+                .process(cluster.getSolrClient()));
+        reloaded = true;
+      }
+    }
+    assertSuccessfulAdminRequest(
+        
CollectionAdminRequest.deleteCollection(collectionName).process(cluster.getSolrClient()));
+  }
+
+  private void assertSuccessfulAdminRequest(CollectionAdminResponse response) {
+    assertEquals("Unexpected response status", 0, response.getStatus());
+    assertTrue("Unsuccessful response: " + response, response.isSuccess());
+  }
+
+  private void createCollection(
+      int numShards, int nrtReplicas, int tlogReplicas, int pullReplicas, 
String collectionName)
+      throws SolrServerException, IOException {
+    switch (random().nextInt(3)) {

Review Comment:
   Seems weird these create strings - don't we have admin API wrappers around 
these? We shouldn't need to build straight httpget/httppost commands...



##########
solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionReloadTest.java:
##########
@@ -16,10 +16,20 @@
  */
 package org.apache.solr.cloud.api.collections;
 
+import com.carrotsearch.randomizedtesting.annotations.Repeat;
+import java.io.IOException;
 import java.lang.invoke.MethodHandles;
+import java.util.Locale;
 import java.util.concurrent.TimeUnit;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
 import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.CloudLegacySolrClient;

Review Comment:
   Use non legacy client?



-- 
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-unsubscr...@solr.apache.org

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


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

Reply via email to