You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2017/07/03 08:07:09 UTC
lucene-solr:feature/autoscaling: SOLR-10379: Adding
testMultipleCollections() to TestPolicy
Repository: lucene-solr
Updated Branches:
refs/heads/feature/autoscaling b21b0dcc2 -> 8e0247e94
SOLR-10379: Adding testMultipleCollections() to TestPolicy
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/8e0247e9
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/8e0247e9
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/8e0247e9
Branch: refs/heads/feature/autoscaling
Commit: 8e0247e94ae5dafc2458b7441d2b5090d9dbfd17
Parents: b21b0dc
Author: Cao Manh Dat <da...@apache.org>
Authored: Mon Jul 3 15:06:59 2017 +0700
Committer: Cao Manh Dat <da...@apache.org>
Committed: Mon Jul 3 15:06:59 2017 +0700
----------------------------------------------------------------------
.../solrj/cloud/autoscaling/TestPolicy.java | 80 +++++++++++++++++++-
1 file changed, 79 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8e0247e9/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java b/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
index 98fa83f..1948534 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
@@ -27,7 +27,6 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.function.Predicate;
import com.google.common.collect.ImmutableList;
import org.apache.solr.SolrTestCaseJ4;
@@ -510,6 +509,85 @@ public class TestPolicy extends SolrTestCaseJ4 {
}
+ public void testMultipleCollections() {
+ Map policies = (Map) Utils.fromJSONString("{" +
+ " 'cluster-preferences': [" +
+ " { 'maximize': 'freedisk', 'precision': 50}," +
+ " { 'minimize': 'cores', 'precision': 50}" +
+ " ]," +
+ " 'cluster-policy': [" +
+ " { 'replica': 0, 'nodeRole': 'overseer'}" +
+ " { 'replica': '<2', 'shard': '#EACH', 'node': '#ANY', 'collection':'newColl'}," +
+ " { 'replica': '<2', 'shard': '#EACH', 'node': '#ANY', 'collection':'newColl2', type : PULL}," +
+ " { 'replica': '<3', 'shard': '#EACH', 'node': '#ANY', 'collection':'newColl2'}," +
+ " { 'replica': 0, 'shard': '#EACH', sysprop.fs : '!ssd', type : TLOG }" +
+ " { 'replica': 0, 'shard': '#EACH', sysprop.fs : '!slowdisk' , type : PULL }" +
+ " ]" +
+ "}");
+ Map<String, Map> nodeValues = (Map<String, Map>) Utils.fromJSONString("{" +
+ "node1:{cores:12, freedisk: 334, heapUsage:10480, rack: rack4, sysprop.fs: slowdisk}," +
+ "node2:{cores:4, freedisk: 749, heapUsage:6873, rack: rack3}," +
+ "node3:{cores:7, freedisk: 262, heapUsage:7834, rack: rack2, sysprop.fs : ssd}," +
+ "node4:{cores:8, freedisk: 375, heapUsage:16900, nodeRole:overseer, rack: rack1}" +
+ "}");
+ Policy policy = new Policy(policies);
+ Policy.Suggester suggester = policy.createSession(getClusterDataProvider(nodeValues, clusterState))
+ .getSuggester(ADDREPLICA)
+ .hint(Hint.COLL, "newColl")
+ .hint(Hint.COLL, "newColl2")
+ .hint(Hint.REPLICATYPE, Replica.Type.PULL)
+ .hint(Hint.SHARD, "shard1");
+ SolrRequest op;
+ int countOp = 0;
+ int countNewCollOp = 0;
+ int countNewColl2Op = 0;
+ while ((op = suggester.getOperation()) != null) {
+ countOp++;
+ suggester = suggester.getSession().getSuggester(ADDREPLICA)
+ .hint(Hint.COLL, "newColl")
+ .hint(Hint.COLL, "newColl2")
+ .hint(Hint.REPLICATYPE, Replica.Type.PULL)
+ .hint(Hint.SHARD, "shard1");
+ assertEquals(Replica.Type.PULL.name(), op.getParams().get("type"));
+ String collection = op.getParams().get("collection");
+ assertTrue("Collection for replica is not as expected " + collection, collection.equals("newColl") || collection.equals("newColl2"));
+ if (collection.equals("newColl")) countNewCollOp++;
+ else countNewColl2Op++;
+ assertEquals("PULL type node must be in 'slowdisk' node","node1", op.getParams().get("node"));
+ }
+ assertEquals(2, countOp);
+ assertEquals(1, countNewCollOp);
+ assertEquals(1, countNewColl2Op);
+
+ countOp = 0;
+ countNewCollOp = 0;
+ countNewColl2Op = 0;
+ suggester = suggester.getSession()
+ .getSuggester(ADDREPLICA)
+ .hint(Hint.COLL, "newColl")
+ .hint(Hint.COLL, "newColl2")
+ .hint(Hint.REPLICATYPE, Replica.Type.TLOG)
+ .hint(Hint.SHARD, "shard2");
+ while ((op = suggester.getOperation()) != null) {
+ countOp++;
+ suggester = suggester.getSession()
+ .getSuggester(ADDREPLICA)
+ .hint(Hint.COLL, "newColl")
+ .hint(Hint.COLL, "newColl2")
+ .hint(Hint.REPLICATYPE, Replica.Type.TLOG)
+ .hint(Hint.SHARD, "shard2");
+ assertEquals(Replica.Type.TLOG.name(), op.getParams().get("type"));
+ String collection = op.getParams().get("collection");
+ assertTrue("Collection for replica is not as expected " + collection, collection.equals("newColl") || collection.equals("newColl2"));
+ if (collection.equals("newColl")) countNewCollOp++;
+ else countNewColl2Op++;
+ assertEquals("TLOG type node must be in 'ssd' node","node3", op.getParams().get("node"));
+ }
+ assertEquals(3, countOp);
+ assertEquals(1, countNewCollOp);
+ assertEquals(2, countNewColl2Op);
+ }
+
public void testRow() {
Row row = new Row("nodex", new Cell[]{new Cell(0, "node", "nodex")}, false, new HashMap<>(), new ArrayList<>(), true);
Row r1 = row.addReplica("c1", "s1", null);