mirror of https://github.com/apache/lucene.git
SOLR-12739: Fix failures in AutoAddReplicasIntegrationTest and its sub-class.
This test too makes assumptions about how replicas are placed. In the legacy assignment strategy, the replica of a given collection are spread equally across all nodes but with the new policy based strategy, all cores across collections are spread out. Therefore the assumptions in this test were wrong. I've changed this test to use the legacy assignment policy because testing the autoAddReplicas feature doesn't have to depend on new replica assignment strategies. This change also fixes a bug in Assign which used "collection" key instead of "cluster" to figure out which strategy to use.
This commit is contained in:
parent
a66a7f3197
commit
9f34a7c776
|
@ -269,7 +269,7 @@ public class Assign {
|
|||
Map<String, Object> clusterProperties = cloudManager.getClusterStateProvider().getClusterProperties();
|
||||
if (clusterProperties.containsKey(CollectionAdminParams.DEFAULTS)) {
|
||||
Map<String, Object> defaults = (Map<String, Object>) clusterProperties.get(CollectionAdminParams.DEFAULTS);
|
||||
Map<String, Object> collectionDefaults = (Map<String, Object>) defaults.getOrDefault(CollectionAdminParams.COLLECTION, Collections.emptyMap());
|
||||
Map<String, Object> collectionDefaults = (Map<String, Object>) defaults.getOrDefault(CollectionAdminParams.CLUSTER, Collections.emptyMap());
|
||||
useLegacyAssignment = (boolean) collectionDefaults.getOrDefault(CollectionAdminParams.USE_LEGACY_REPLICA_ASSIGNMENT, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -169,13 +169,13 @@ public class AssignTest extends SolrTestCaseJ4 {
|
|||
ClusterStateProvider clusterStateProvider = mock(ClusterStateProvider.class);
|
||||
when(solrCloudManager.getClusterStateProvider()).thenReturn(clusterStateProvider);
|
||||
// first we set useLegacyReplicaAssignment=false, so autoscaling should always be used
|
||||
when(clusterStateProvider.getClusterProperties()).thenReturn(Utils.makeMap("defaults", Utils.makeMap("collection", Utils.makeMap("useLegacyReplicaAssignment", false))));
|
||||
when(clusterStateProvider.getClusterProperties()).thenReturn(Utils.makeMap("defaults", Utils.makeMap("cluster", Utils.makeMap("useLegacyReplicaAssignment", false))));
|
||||
// verify
|
||||
boolean usePolicyFramework = Assign.usePolicyFramework(solrCloudManager);
|
||||
assertTrue(usePolicyFramework);
|
||||
|
||||
// now we set useLegacyReplicaAssignment=true, so autoscaling can only be used if an explicit policy or preference exists
|
||||
when(clusterStateProvider.getClusterProperties()).thenReturn(Utils.makeMap("defaults", Utils.makeMap("collection", Utils.makeMap("useLegacyReplicaAssignment", true))));
|
||||
when(clusterStateProvider.getClusterProperties()).thenReturn(Utils.makeMap("defaults", Utils.makeMap("cluster", Utils.makeMap("useLegacyReplicaAssignment", true))));
|
||||
DistribStateManager distribStateManager = mock(DistribStateManager.class);
|
||||
when(solrCloudManager.getDistribStateManager()).thenReturn(distribStateManager);
|
||||
when(distribStateManager.getAutoScalingConfig()).thenReturn(new AutoScalingConfig(Collections.emptyMap()));
|
||||
|
|
|
@ -23,10 +23,12 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
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.V2Request;
|
||||
import org.apache.solr.cloud.SolrCloudTestCase;
|
||||
import org.apache.solr.common.cloud.ClusterStateUtil;
|
||||
import org.apache.solr.common.cloud.DocCollection;
|
||||
|
@ -44,7 +46,7 @@ import org.junit.Test;
|
|||
|
||||
import static org.apache.solr.common.util.Utils.makeMap;
|
||||
|
||||
@LogLevel("org.apache.solr.cloud.autoscaling=DEBUG;org.apache.solr.client.solrj.cloud.autoscaling=DEBUG")
|
||||
@LogLevel("org.apache.solr.cloud.autoscaling=DEBUG;org.apache.solr.client.solrj.cloud.autoscaling=DEBUG;org.apache.solr.cloud=DEBUG;org.apache.solr.cloud.Overseer=DEBUG;org.apache.solr.cloud.overseer=DEBUG;")
|
||||
public class AutoAddReplicasIntegrationTest extends SolrCloudTestCase {
|
||||
private static final String COLLECTION1 = "testSimple1";
|
||||
private static final String COLLECTION2 = "testSimple2";
|
||||
|
@ -55,6 +57,12 @@ public class AutoAddReplicasIntegrationTest extends SolrCloudTestCase {
|
|||
.addConfig("conf", configset("cloud-minimal"))
|
||||
.withSolrXml(TEST_PATH().resolve("solr.xml"))
|
||||
.configure();
|
||||
|
||||
new V2Request.Builder("/cluster")
|
||||
.withMethod(SolrRequest.METHOD.POST)
|
||||
.withPayload("{set-obj-property:{defaults : {cluster: {useLegacyReplicaAssignment:true}}}}}")
|
||||
.build()
|
||||
.process(cluster.getSolrClient());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -94,10 +94,16 @@ public interface CollectionAdminParams {
|
|||
/**
|
||||
* Used by cluster properties API as a wrapper key to provide defaults for collection, cluster etc.
|
||||
*
|
||||
* e.g. {defaults:{collection:{useLegacyReplicaAssignment:false}}}
|
||||
* e.g. {defaults:{collection:{replicationFactor:2}}}
|
||||
*/
|
||||
String DEFAULTS = "defaults";
|
||||
|
||||
/**
|
||||
* Cluster wide defaults can be nested under this key e.g.
|
||||
* {defaults: {cluster:{useLegacyReplicaAssignment:false}}}
|
||||
*/
|
||||
String CLUSTER = "cluster";
|
||||
|
||||
/**
|
||||
* This cluster property decides whether Solr should use the legacy round-robin replica placement strategy
|
||||
* or the autoscaling policy based strategy to assign replicas to nodes. The default is false.
|
||||
|
|
Loading…
Reference in New Issue