Index: solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java (revision a22099a3986de1f36f926b4e106827c5308708b0) +++ solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java (revision ) @@ -40,6 +40,7 @@ import org.apache.solr.common.params.CollectionParams; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.util.Utils; +import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,6 +48,7 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -75,14 +77,14 @@ waitForThingsToLevelOut(15); - if (usually()) { + if (true) { log.info("Using legacyCloud=false for cluster"); CollectionsAPIDistributedZkTest.setClusterProp(cloudClient, "legacyCloud", "false"); } - incompleteOrOverlappingCustomRangeTest(); - splitByUniqueKeyTest(); + //incompleteOrOverlappingCustomRangeTest(); + //splitByUniqueKeyTest(); splitByRouteFieldTest(); - splitByRouteKeyTest(); + //splitByRouteKeyTest(); // todo can't call waitForThingsToLevelOut because it looks for jettys of all shards // and the new sub-shards don't have any. @@ -90,7 +92,7 @@ //waitForThingsToLevelOut(15); } - @Test + @Test @Ignore public void testSplitShardWithRule() throws Exception { waitForThingsToLevelOut(15); @@ -273,7 +275,10 @@ waitForRecoveriesToFinish(false); String url = getUrlFromZk(getCommonCloudSolrClient().getZkStateReader().getClusterState(), collectionName); - +/* +try (CloudSolrClient collectionClient = new CloudSolrClient(zkServer.getZkAddress())) { + collectionClient.setDefaultCollection(collectionName); + */ try (HttpSolrClient collectionClient = new HttpSolrClient(url)) { ClusterState clusterState = cloudClient.getZkStateReader().getClusterState(); @@ -283,7 +288,7 @@ final List ranges = router.partitionRange(2, shard1Range); final int[] docCounts = new int[ranges.size()]; - for (int i = 100; i <= 200; i++) { + for (int i = 100; i < 200; i++) {//100 docs String shardKey = "" + (char) ('a' + (i % 26)); // See comment in ShardRoutingTest for hash distribution collectionClient.add(getDoc(id, i, "n_ti", i, shard_fld, shardKey)); @@ -299,26 +304,38 @@ } collectionClient.commit(); + assertEquals(100, collectionClient.query(new SolrQuery("*:*")).getResults().getNumFound()); - for (int i = 0; i < 3; i++) { - try { - splitShard(collectionName, SHARD1, null, null); - break; - } catch (HttpSolrClient.RemoteSolrException e) { - if (e.code() != 500) { - throw e; - } - log.error("SPLITSHARD failed. " + (i < 2 ? " Retring split" : ""), e); - if (i == 2) { - fail("SPLITSHARD was not successful even after three tries"); - } - } - } + collectionClient.deleteById(Arrays.asList("100", "102", "103")); + collectionClient.commit(); - waitForRecoveriesToFinish(collectionName, false); + long numFoundAfterDelById = collectionClient.query(new SolrQuery("*:*")).getResults().getNumFound(); - assertEquals(docCounts[0], collectionClient.query(new SolrQuery("*:*").setParam("shards", "shard1_0")).getResults().getNumFound()); - assertEquals(docCounts[1], collectionClient.query(new SolrQuery("*:*").setParam("shards", "shard1_1")).getResults().getNumFound()); + collectionClient.deleteByQuery("{!terms f=" + id + "}100,101,102"); + collectionClient.commit(); + + long numFound = collectionClient.query(new SolrQuery("*:*")).getResults().getNumFound(); + assertEquals(100 - 3, numFound); + +// for (int i = 0; i < 3; i++) { +// try { +// splitShard(collectionName, SHARD1, null, null); +// break; +// } catch (HttpSolrClient.RemoteSolrException e) { +// if (e.code() != 500) { +// throw e; +// } +// log.error("SPLITSHARD failed. " + (i < 2 ? " Retring split" : ""), e); +// if (i == 2) { +// fail("SPLITSHARD was not successful even after three tries"); +// } +// } +// } +// +// waitForRecoveriesToFinish(collectionName, false); +// +// assertEquals(docCounts[0], collectionClient.query(new SolrQuery("*:*").setParam("shards", "shard1_0")).getResults().getNumFound()); +// assertEquals(docCounts[1], collectionClient.query(new SolrQuery("*:*").setParam("shards", "shard1_1")).getResults().getNumFound()); } }