You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/03/10 10:09:35 UTC
[lucene] 03/33: SOLR-15004: fix failure in
SamplePluginAffinityReplicaPlacementTest
This is an automated email from the ASF dual-hosted git repository.
dweiss pushed a commit to branch jira/solr-15016
in repository https://gitbox.apache.org/repos/asf/lucene.git
commit 023ebc3b4786de042bdc0fe52db34ef9ca7a1ce9
Author: Ilan Ginzburg <ig...@salesforce.com>
AuthorDate: Thu Nov 19 01:18:32 2020 +0100
SOLR-15004: fix failure in SamplePluginAffinityReplicaPlacementTest
---
.../SamplePluginAffinityReplicaPlacementTest.java | 25 ++++++++++++++++------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/solr/core/src/test/org/apache/solr/cluster/placement/impl/SamplePluginAffinityReplicaPlacementTest.java b/solr/core/src/test/org/apache/solr/cluster/placement/impl/SamplePluginAffinityReplicaPlacementTest.java
index 7c7dee5..e6d7cd4 100644
--- a/solr/core/src/test/org/apache/solr/cluster/placement/impl/SamplePluginAffinityReplicaPlacementTest.java
+++ b/solr/core/src/test/org/apache/solr/cluster/placement/impl/SamplePluginAffinityReplicaPlacementTest.java
@@ -20,6 +20,7 @@ package org.apache.solr.cluster.placement.impl;
import org.apache.solr.cluster.Cluster;
import org.apache.solr.cluster.Node;
import org.apache.solr.cluster.Shard;
+import org.apache.solr.cluster.SolrCollection;
import org.apache.solr.cluster.placement.*;
import org.apache.solr.cluster.placement.plugins.SamplePluginAffinityReplicaPlacement;
import org.junit.Assert;
@@ -37,13 +38,12 @@ public class SamplePluginAffinityReplicaPlacementTest extends Assert {
private static PlacementPlugin plugin;
@BeforeClass
- public static void setupCluster() {
+ public static void setupPlugin() {
PlacementPluginConfig config = PlacementPluginConfigImpl.createConfigFromProperties(
Map.of("minimalFreeDiskGB", 10L, "deprioritizedFreeDiskGB", 50L));
plugin = new SamplePluginAffinityReplicaPlacement.Factory().createPluginInstance(config);
}
- // FIXME IG: this test fails (expecting placement on node1 but placement happens on node2)
@Test
public void testBasicPlacementNewCollection() throws Exception {
testBasicPlacementInternal(false);
@@ -64,14 +64,25 @@ public class SamplePluginAffinityReplicaPlacementTest extends Assert {
Node node1 = new ClusterAbstractionsForTest.NodeImpl("node1");
Node node2 = new ClusterAbstractionsForTest.NodeImpl("node2");
-// Set<Node> liveNodes = ClusterAbstractionsForTest.NodeImpl.getNodes(Set.of("node1", "node2", "node3"));
Set<Node> liveNodes = Set.of(node1, node2);
+
ClusterAbstractionsForTest.SolrCollectionImpl solrCollection = new ClusterAbstractionsForTest.SolrCollectionImpl(collectionName, Map.of());
- // An existing collection with a single replica on node 1
- Map<String, Shard> shards = PluginTestHelper.createShardsAndReplicas(solrCollection, 1, 1, Set.of(node1));
- solrCollection.setShards(shards);
+ // Make sure new collections are not visible in the cluster state and existing ones are
+ final Map<String, SolrCollection> clusterCollections;
+ final Map<String, Shard> shards;
+ if (hasExistingCollection) {
+ // An existing collection with a single replica on node 1. Note that new collections already exist by the time the plugin is called, but are empty
+ shards = PluginTestHelper.createShardsAndReplicas(solrCollection, 1, 1, Set.of(node1));
+ solrCollection.setShards(shards);
+ clusterCollections = Map.of(solrCollection.getName(), solrCollection);
+ } else {
+ // A new collection has the shards defined ok but no replicas
+ shards = PluginTestHelper.createShardsAndReplicas(solrCollection, 1, 0, Set.of());
+ solrCollection.setShards(shards);
+ clusterCollections = Map.of();
+ }
- Cluster cluster = new ClusterAbstractionsForTest.ClusterImpl(liveNodes, hasExistingCollection ? Map.of(solrCollection.getName(), solrCollection) : Map.of());
+ Cluster cluster = new ClusterAbstractionsForTest.ClusterImpl(liveNodes, clusterCollections);
// Place a new replica for the (only) existing shard of the collection
PlacementRequestImpl placementRequest = new PlacementRequestImpl(solrCollection, Set.of(shards.keySet().iterator().next()), liveNodes, 1, 0, 0);
// More cores on node2