lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [22/45] lucene-solr:jira/solr-11285-sim: SOLR-11285: Return real path from createData (which may include sequential suffix). Fix mocks in a test.
Date Wed, 04 Oct 2017 14:43:18 GMT
SOLR-11285: Return real path from createData (which may include sequential suffix).
Fix mocks in a test.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d52ca53d
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d52ca53d
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d52ca53d

Branch: refs/heads/jira/solr-11285-sim
Commit: d52ca53d229510f8b9793bc465214b8817f78dea
Parents: a907d5b
Author: Andrzej Bialecki <ab@apache.org>
Authored: Thu Sep 21 17:27:04 2017 +0200
Committer: Andrzej Bialecki <ab@apache.org>
Committed: Thu Sep 21 17:27:04 2017 +0200

----------------------------------------------------------------------
 ...verseerCollectionConfigSetProcessorTest.java | 32 ++++++++++++++++++--
 .../cloud/autoscaling/DistribStateManager.java  |  2 +-
 .../solrj/impl/ZkDistribStateManager.java       |  4 +--
 3 files changed, 32 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d52ca53d/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
b/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
index 217359e..f90eacb 100644
--- a/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
@@ -25,6 +25,8 @@ import java.util.concurrent.TimeUnit;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.SolrResponse;
 import org.apache.solr.client.solrj.cloud.autoscaling.AutoScalingConfig;
+import org.apache.solr.client.solrj.cloud.autoscaling.ClusterDataProvider;
+import org.apache.solr.client.solrj.cloud.autoscaling.SolrCloudDataProvider;
 import org.apache.solr.cloud.Overseer.LeaderStatus;
 import org.apache.solr.cloud.OverseerTaskQueue.QueueEvent;
 import org.apache.solr.common.cloud.ClusterState;
@@ -65,6 +67,10 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4
{
   private static final String CONFIG_NAME = "myconfig";
   
   private static OverseerTaskQueue workQueueMock;
+  private static Overseer overseerMock;
+  private static ZkController zkControllerMock;
+  private static SolrCloudDataProvider cloudDataProviderMock;
+  private static ClusterDataProvider clusterDataProviderMock;
   private static DistributedMap runningMapMock;
   private static DistributedMap completedMapMock;
   private static DistributedMap failureMapMock;
@@ -93,9 +99,10 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4
{
         String myId, ShardHandlerFactory shardHandlerFactory,
         String adminPath,
         OverseerTaskQueue workQueue, DistributedMap runningMap,
+        Overseer overseer,
         DistributedMap completedMap,
         DistributedMap failureMap) {
-      super(zkStateReader, myId, shardHandlerFactory, adminPath, new Overseer.Stats(), null,
new OverseerNodePrioritizer(zkStateReader, adminPath, shardHandlerFactory), workQueue, runningMap,
completedMap, failureMap);
+      super(zkStateReader, myId, shardHandlerFactory, adminPath, new Overseer.Stats(), overseer,
new OverseerNodePrioritizer(zkStateReader, adminPath, shardHandlerFactory), workQueue, runningMap,
completedMap, failureMap);
     }
     
     @Override
@@ -116,6 +123,10 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4
{
     zkStateReaderMock = mock(ZkStateReader.class);
     clusterStateMock = mock(ClusterState.class);
     solrZkClientMock = mock(SolrZkClient.class);
+    overseerMock = mock(Overseer.class);
+    zkControllerMock = mock(ZkController.class);
+    cloudDataProviderMock = mock(SolrCloudDataProvider.class);
+    clusterDataProviderMock = mock(ClusterDataProvider.class);
   }
   
   @AfterClass
@@ -129,6 +140,10 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4
{
     zkStateReaderMock = null;
     clusterStateMock = null;
     solrZkClientMock = null;
+    overseerMock = null;
+    zkControllerMock = null;
+    cloudDataProviderMock = null;
+    clusterDataProviderMock = null;
   }
   
   @Before
@@ -144,6 +159,10 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4
{
     reset(zkStateReaderMock);
     reset(clusterStateMock);
     reset(solrZkClientMock);
+    reset(overseerMock);
+    reset(zkControllerMock);
+    reset(cloudDataProviderMock);
+    reset(clusterDataProviderMock);
 
     zkMap.clear();
     collectionsSet.clear();
@@ -259,7 +278,14 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4
{
       String key = invocation.getArgument(0);
       return zkMap.containsKey(key);
     });
-    
+
+    when(overseerMock.getZkController()).thenReturn(zkControllerMock);
+    when(overseerMock.getSolrCloudDataProvider()).thenReturn(cloudDataProviderMock);
+    when(zkControllerMock.getSolrCloudDataProvider()).thenReturn(cloudDataProviderMock);
+    when(cloudDataProviderMock.getClusterDataProvider()).thenReturn(clusterDataProviderMock);
+    when(clusterDataProviderMock.getClusterState()).thenReturn(clusterStateMock);
+    when(clusterDataProviderMock.getAutoScalingConfig()).thenReturn(autoScalingConfig);
+
     zkMap.put("/configs/myconfig", null);
     
     return liveNodes;
@@ -490,7 +516,7 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4
{
 
     underTest = new OverseerCollectionConfigSetProcessorToBeTested(zkStateReaderMock,
         "1234", shardHandlerFactoryMock, ADMIN_PATH, workQueueMock, runningMapMock,
-        completedMapMock, failureMapMock);
+        overseerMock, completedMapMock, failureMapMock);
 
 
     log.info("clusterstate " + clusterStateMock.hashCode());

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d52ca53d/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/DistribStateManager.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/DistribStateManager.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/DistribStateManager.java
index 7bab4e2..5ad8345 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/DistribStateManager.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/DistribStateManager.java
@@ -56,7 +56,7 @@ public interface DistribStateManager {
 
   void makePath(String path) throws IOException;
 
-  void createData(String path, byte[] data, CreateMode mode) throws IOException;
+  String createData(String path, byte[] data, CreateMode mode) throws IOException;
 
   void removeData(String path, int version) throws NoSuchElementException, IOException;
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d52ca53d/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java
index 3459a49..5fe4dbc 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java
@@ -84,9 +84,9 @@ public class ZkDistribStateManager implements DistribStateManager {
   }
 
   @Override
-  public void createData(String path, byte[] data, CreateMode mode) throws IOException {
+  public String createData(String path, byte[] data, CreateMode mode) throws IOException
{
     try {
-      zkClient.create(path, data, mode, true);
+      return zkClient.create(path, data, mode, true);
     } catch (KeeperException | InterruptedException e) {
       throw new IOException(e);
     }


Mime
View raw message