You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2013/10/21 20:58:44 UTC
svn commit: r1534320 [34/39] - in /lucene/dev/branches/lucene4956: ./
dev-tools/ dev-tools/idea/.idea/ dev-tools/idea/lucene/expressions/
dev-tools/idea/solr/contrib/velocity/ dev-tools/maven/
dev-tools/maven/lucene/ dev-tools/maven/lucene/expressions/...
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java Mon Oct 21 18:58:24 2013
@@ -38,6 +38,7 @@ import org.apache.solr.update.VersionInf
import org.apache.solr.update.processor.DistributedUpdateProcessor;
import org.apache.zookeeper.CreateMode;
import org.junit.BeforeClass;
+import org.junit.Ignore;
/**
* Super basic testing, no shard restarting or anything.
@@ -240,7 +241,7 @@ public class FullSolrCloudDistribCmdsTes
private long testIndexQueryDeleteHierarchical(long docId) throws Exception {
//index
int topDocsNum = atLeast(10);
- int childsNum = atLeast(10);
+ int childsNum = 5+random().nextInt(5);
for (int i = 0; i < topDocsNum; ++i) {
UpdateRequest uReq = new UpdateRequest();
SolrInputDocument topDocument = new SolrInputDocument();
@@ -309,16 +310,20 @@ public class FullSolrCloudDistribCmdsTes
private void testIndexingWithSuss() throws Exception {
ConcurrentUpdateSolrServer suss = new ConcurrentUpdateSolrServer(
((HttpSolrServer) clients.get(0)).getBaseURL(), 3, 1);
- suss.setConnectionTimeout(15000);
- suss.setSoTimeout(30000);
- for (int i=100; i<150; i++) {
- index_specific(suss, id, i);
+ try {
+ suss.setConnectionTimeout(15000);
+ suss.setSoTimeout(30000);
+ for (int i = 100; i < 150; i++) {
+ index_specific(suss, id, i);
+ }
+ suss.blockUntilFinished();
+
+ commit();
+
+ checkShardConsistency();
+ } finally {
+ suss.shutdown();
}
- suss.blockUntilFinished();
-
- commit();
-
- checkShardConsistency();
}
private void testOptimisticUpdate(QueryResponse results) throws Exception {
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java Mon Oct 21 18:58:24 2013
@@ -21,6 +21,7 @@ import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrResponse;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.cloud.DistributedQueue.QueueEvent;
+import org.apache.solr.cloud.Overseer.LeaderStatus;
import org.apache.solr.common.cloud.ClusterState;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkNodeProps;
@@ -101,8 +102,8 @@ public class OverseerCollectionProcessor
}
@Override
- protected boolean amILeader() {
- return true;
+ protected LeaderStatus amILeader() {
+ return LeaderStatus.YES;
}
}
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java Mon Oct 21 18:58:24 2013
@@ -17,15 +17,6 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-
import org.apache.http.params.CoreConnectionPNames;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrRequest;
@@ -37,11 +28,13 @@ import org.apache.solr.client.solrj.requ
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.cloud.ClusterState;
+import org.apache.solr.common.cloud.CompositeIdRouter;
import org.apache.solr.common.cloud.DocRouter;
import org.apache.solr.common.cloud.HashBasedRouter;
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.ZkCoreNodeProps;
+import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.ModifiableSolrParams;
@@ -50,6 +43,22 @@ import org.apache.solr.update.DirectUpda
import org.junit.After;
import org.junit.Before;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+
+import static org.apache.lucene.util.LuceneTestCase.Slow;
+import static org.apache.solr.cloud.OverseerCollectionProcessor.MAX_SHARDS_PER_NODE;
+import static org.apache.solr.cloud.OverseerCollectionProcessor.NUM_SLICES;
+import static org.apache.solr.cloud.OverseerCollectionProcessor.REPLICATION_FACTOR;
+
+@Slow
public class ShardSplitTest extends BasicDistributedZkTest {
public static final String SHARD1_0 = SHARD1 + "_0";
@@ -100,11 +109,32 @@ public class ShardSplitTest extends Basi
public void doTest() throws Exception {
waitForThingsToLevelOut(15);
+ splitByUniqueKeyTest();
+ splitByRouteFieldTest();
+ splitByRouteKeyTest();
+
+ // todo can't call waitForThingsToLevelOut because it looks for jettys of all shards
+ // and the new sub-shards don't have any.
+ waitForRecoveriesToFinish(true);
+ //waitForThingsToLevelOut(15);
+
+ }
+
+ private void splitByUniqueKeyTest() throws Exception {
ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();
final DocRouter router = clusterState.getCollection(AbstractDistribZkTestBase.DEFAULT_COLLECTION).getRouter();
Slice shard1 = clusterState.getSlice(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1);
DocRouter.Range shard1Range = shard1.getRange() != null ? shard1.getRange() : router.fullRange();
- final List<DocRouter.Range> ranges = router.partitionRange(2, shard1Range);
+ List<DocRouter.Range> subRanges = new ArrayList<DocRouter.Range>();
+ if (usually()) {
+ List<DocRouter.Range> ranges = router.partitionRange(4, shard1Range);
+ // 75% of range goes to shard1_0 and the rest to shard1_1
+ subRanges.add(new DocRouter.Range(ranges.get(0).min, ranges.get(2).max));
+ subRanges.add(ranges.get(3));
+ } else {
+ subRanges = router.partitionRange(2, shard1Range);
+ }
+ final List<DocRouter.Range> ranges = subRanges;
final int[] docCounts = new int[ranges.size()];
int numReplicas = shard1.getReplicas().size();
@@ -148,7 +178,7 @@ public class ShardSplitTest extends Basi
try {
for (int i = 0; i < 3; i++) {
try {
- splitShard(SHARD1);
+ splitShard(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1, subRanges, null);
log.info("Layout after split: \n");
printLayout();
break;
@@ -170,12 +200,177 @@ public class ShardSplitTest extends Basi
}
}
+ waitForRecoveriesToFinish(false);
checkDocCountsAndShardStates(docCounts, numReplicas);
+ }
- // todo can't call waitForThingsToLevelOut because it looks for jettys of all shards
- // and the new sub-shards don't have any.
- waitForRecoveriesToFinish(true);
- //waitForThingsToLevelOut(15);
+
+ public void splitByRouteFieldTest() throws Exception {
+ log.info("Starting testSplitWithRouteField");
+ String collectionName = "routeFieldColl";
+ int numShards = 4;
+ int replicationFactor = 2;
+ int maxShardsPerNode = (((numShards * replicationFactor) / getCommonCloudSolrServer()
+ .getZkStateReader().getClusterState().getLiveNodes().size())) + 1;
+
+ HashMap<String, List<Integer>> collectionInfos = new HashMap<String, List<Integer>>();
+ CloudSolrServer client = null;
+ String shard_fld = "shard_s";
+ try {
+ client = createCloudClient(null);
+ Map<String, Object> props = ZkNodeProps.makeMap(
+ REPLICATION_FACTOR, replicationFactor,
+ MAX_SHARDS_PER_NODE, maxShardsPerNode,
+ NUM_SLICES, numShards,
+ "router.field", shard_fld);
+
+ createCollection(collectionInfos, collectionName,props,client);
+ } finally {
+ if (client != null) client.shutdown();
+ }
+
+ List<Integer> list = collectionInfos.get(collectionName);
+ checkForCollection(collectionName, list, null);
+
+ waitForRecoveriesToFinish(false);
+
+ String url = CustomCollectionTest.getUrlFromZk(getCommonCloudSolrServer().getZkStateReader().getClusterState(), collectionName);
+
+ HttpSolrServer collectionClient = new HttpSolrServer(url);
+
+ ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();
+ final DocRouter router = clusterState.getCollection(collectionName).getRouter();
+ Slice shard1 = clusterState.getSlice(collectionName, SHARD1);
+ DocRouter.Range shard1Range = shard1.getRange() != null ? shard1.getRange() : router.fullRange();
+ final List<DocRouter.Range> ranges = router.partitionRange(2, shard1Range);
+ final int[] docCounts = new int[ranges.size()];
+
+ for (int i = 100; i <= 200; i++) {
+ String shardKey = "" + (char)('a' + (i % 26)); // See comment in ShardRoutingTest for hash distribution
+
+ collectionClient.add(getDoc(id, i, "n_ti", i, shard_fld, shardKey));
+ int idx = getHashRangeIdx(router, ranges, shardKey);
+ if (idx != -1) {
+ docCounts[idx]++;
+ }
+ }
+
+ for (int i = 0; i < docCounts.length; i++) {
+ int docCount = docCounts[i];
+ log.info("Shard {} docCount = {}", "shard1_" + i, docCount);
+ }
+
+ collectionClient.commit();
+
+ for (int i = 0; i < 3; i++) {
+ try {
+ splitShard(collectionName, SHARD1, null, null);
+ break;
+ } catch (HttpSolrServer.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());
+ }
+
+ private void splitByRouteKeyTest() throws Exception {
+ log.info("Starting splitByRouteKeyTest");
+ String collectionName = "splitByRouteKeyTest";
+ int numShards = 4;
+ int replicationFactor = 2;
+ int maxShardsPerNode = (((numShards * replicationFactor) / getCommonCloudSolrServer()
+ .getZkStateReader().getClusterState().getLiveNodes().size())) + 1;
+
+ HashMap<String, List<Integer>> collectionInfos = new HashMap<String, List<Integer>>();
+ CloudSolrServer client = null;
+ try {
+ client = createCloudClient(null);
+ Map<String, Object> props = ZkNodeProps.makeMap(
+ REPLICATION_FACTOR, replicationFactor,
+ MAX_SHARDS_PER_NODE, maxShardsPerNode,
+ NUM_SLICES, numShards);
+
+ createCollection(collectionInfos, collectionName,props,client);
+ } finally {
+ if (client != null) client.shutdown();
+ }
+
+ List<Integer> list = collectionInfos.get(collectionName);
+ checkForCollection(collectionName, list, null);
+
+ waitForRecoveriesToFinish(false);
+
+ String url = CustomCollectionTest.getUrlFromZk(getCommonCloudSolrServer().getZkStateReader().getClusterState(), collectionName);
+
+ HttpSolrServer collectionClient = new HttpSolrServer(url);
+
+ String splitKey = "b!";
+
+ ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();
+ final DocRouter router = clusterState.getCollection(collectionName).getRouter();
+ Slice shard1 = clusterState.getSlice(collectionName, SHARD1);
+ DocRouter.Range shard1Range = shard1.getRange() != null ? shard1.getRange() : router.fullRange();
+ final List<DocRouter.Range> ranges = ((CompositeIdRouter) router).partitionRangeByKey(splitKey, shard1Range);
+ final int[] docCounts = new int[ranges.size()];
+
+ int uniqIdentifier = (1<<12);
+ int splitKeyDocCount = 0;
+ for (int i = 100; i <= 200; i++) {
+ String shardKey = "" + (char)('a' + (i % 26)); // See comment in ShardRoutingTest for hash distribution
+
+ String idStr = shardKey + "!" + i;
+ collectionClient.add(getDoc(id, idStr, "n_ti", (shardKey + "!").equals(splitKey) ? uniqIdentifier : i));
+ int idx = getHashRangeIdx(router, ranges, idStr);
+ if (idx != -1) {
+ docCounts[idx]++;
+ }
+ if (splitKey.equals(shardKey + "!"))
+ splitKeyDocCount++;
+ }
+
+ for (int i = 0; i < docCounts.length; i++) {
+ int docCount = docCounts[i];
+ log.info("Shard {} docCount = {}", "shard1_" + i, docCount);
+ }
+ log.info("Route key doc count = {}", splitKeyDocCount);
+
+ collectionClient.commit();
+
+ for (int i = 0; i < 3; i++) {
+ try {
+ splitShard(collectionName, null, null, splitKey);
+ break;
+ } catch (HttpSolrServer.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);
+ SolrQuery solrQuery = new SolrQuery("*:*");
+ assertEquals("DocCount on shard1_0 does not match", docCounts[0], collectionClient.query(solrQuery.setParam("shards", "shard1_0")).getResults().getNumFound());
+ assertEquals("DocCount on shard1_1 does not match", docCounts[1], collectionClient.query(solrQuery.setParam("shards", "shard1_1")).getResults().getNumFound());
+ assertEquals("DocCount on shard1_2 does not match", docCounts[2], collectionClient.query(solrQuery.setParam("shards", "shard1_2")).getResults().getNumFound());
+
+ solrQuery = new SolrQuery("n_ti:" + uniqIdentifier);
+ assertEquals("shard1_0 must have 0 docs for route key: " + splitKey, 0, collectionClient.query(solrQuery.setParam("shards", "shard1_0")).getResults().getNumFound());
+ assertEquals("Wrong number of docs on shard1_1 for route key: " + splitKey, splitKeyDocCount, collectionClient.query(solrQuery.setParam("shards", "shard1_1")).getResults().getNumFound());
+ assertEquals("shard1_2 must have 0 docs for route key: " + splitKey, 0, collectionClient.query(solrQuery.setParam("shards", "shard1_2")).getResults().getNumFound());
}
protected void checkDocCountsAndShardStates(int[] docCounts, int numReplicas) throws Exception {
@@ -213,12 +408,23 @@ public class ShardSplitTest extends Basi
ZkCoreNodeProps shard1_0 = getLeaderUrlFromZk(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1_0);
HttpSolrServer shard1_0Server = new HttpSolrServer(shard1_0.getCoreUrl());
- QueryResponse response = shard1_0Server.query(query);
+ QueryResponse response;
+ try {
+ response = shard1_0Server.query(query);
+ } finally {
+ shard1_0Server.shutdown();
+ }
long shard10Count = response.getResults().getNumFound();
- ZkCoreNodeProps shard1_1 = getLeaderUrlFromZk(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1_1);
+ ZkCoreNodeProps shard1_1 = getLeaderUrlFromZk(
+ AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1_1);
HttpSolrServer shard1_1Server = new HttpSolrServer(shard1_1.getCoreUrl());
- QueryResponse response2 = shard1_1Server.query(query);
+ QueryResponse response2;
+ try {
+ response2 = shard1_1Server.query(query);
+ } finally {
+ shard1_1Server.shutdown();
+ }
long shard11Count = response2.getResults().getNumFound();
logDebugHelp(docCounts, response, shard10Count, response2, shard11Count);
@@ -238,7 +444,12 @@ public class ShardSplitTest extends Basi
for (Replica replica : slice.getReplicas()) {
String coreUrl = new ZkCoreNodeProps(replica).getCoreUrl();
HttpSolrServer server = new HttpSolrServer(coreUrl);
- QueryResponse response = server.query(query);
+ QueryResponse response;
+ try {
+ response = server.query(query);
+ } finally {
+ server.shutdown();
+ }
numFound[c++] = response.getResults().getNumFound();
log.info("Shard: " + shard + " Replica: {} has {} docs", coreUrl, String.valueOf(response.getResults().getNumFound()));
assertTrue("Shard: " + shard + " Replica: " + coreUrl + " has 0 docs", response.getResults().getNumFound() > 0);
@@ -248,11 +459,26 @@ public class ShardSplitTest extends Basi
}
}
- protected void splitShard(String shardId) throws SolrServerException, IOException {
+ protected void splitShard(String collection, String shardId, List<DocRouter.Range> subRanges, String splitKey) throws SolrServerException, IOException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.SPLITSHARD.toString());
- params.set("collection", "collection1");
- params.set("shard", shardId);
+ params.set("collection", collection);
+ if (shardId != null) {
+ params.set("shard", shardId);
+ }
+ if (subRanges != null) {
+ StringBuilder ranges = new StringBuilder();
+ for (int i = 0; i < subRanges.size(); i++) {
+ DocRouter.Range subRange = subRanges.get(i);
+ ranges.append(subRange.toString());
+ if (i < subRanges.size() - 1)
+ ranges.append(",");
+ }
+ params.set("ranges", ranges.toString());
+ }
+ if (splitKey != null) {
+ params.set("split.key", splitKey);
+ }
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
@@ -262,14 +488,14 @@ public class ShardSplitTest extends Basi
HttpSolrServer baseServer = new HttpSolrServer(baseUrl);
baseServer.setConnectionTimeout(15000);
- baseServer.setSoTimeout((int) (CollectionsHandler.DEFAULT_ZK_TIMEOUT * 5));
+ baseServer.setSoTimeout(60000 * 5);
baseServer.request(request);
}
protected void indexAndUpdateCount(DocRouter router, List<DocRouter.Range> ranges, int[] docCounts, String id, int n) throws Exception {
index("id", id, "n_ti", n);
- int idx = getHashRangeIdx(router, ranges, docCounts, id);
+ int idx = getHashRangeIdx(router, ranges, id);
if (idx != -1) {
docCounts[idx]++;
}
@@ -279,17 +505,17 @@ public class ShardSplitTest extends Basi
controlClient.deleteById(id);
cloudClient.deleteById(id);
- int idx = getHashRangeIdx(router, ranges, docCounts, id);
+ int idx = getHashRangeIdx(router, ranges, id);
if (idx != -1) {
docCounts[idx]--;
}
}
- private int getHashRangeIdx(DocRouter router, List<DocRouter.Range> ranges, int[] docCounts, String id) {
+ public static int getHashRangeIdx(DocRouter router, List<DocRouter.Range> ranges, String id) {
int hash = 0;
if (router instanceof HashBasedRouter) {
HashBasedRouter hashBasedRouter = (HashBasedRouter) router;
- hash = hashBasedRouter.sliceHash(id, null, null);
+ hash = hashBasedRouter.sliceHash(id, null, null,null);
}
for (int i = 0; i < ranges.size(); i++) {
DocRouter.Range range = ranges.get(i);
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/SliceStateUpdateTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/SliceStateUpdateTest.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/SliceStateUpdateTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/SliceStateUpdateTest.java Mon Oct 21 18:58:24 2013
@@ -151,7 +151,7 @@ public class SliceStateUpdateTest extend
prop.put("state", "inactive");
Slice newSlice = new Slice(slice.getName(), slice.getReplicasMap(), prop);
slicesMap.put(newSlice.getName(), newSlice);
- props.put(DocCollection.DOC_ROUTER, ImplicitDocRouter.NAME);
+ props.put(DocCollection.DOC_ROUTER, ZkNodeProps.makeMap("name", ImplicitDocRouter.NAME));
DocCollection coll = new DocCollection("collection1", slicesMap, props, DocRouter.DEFAULT);
collectionStates.put("collection1", coll);
@@ -167,7 +167,7 @@ public class SliceStateUpdateTest extend
ZkController zkController2 = container2.getZkController();
ClusterState clusterState2 = null;
Map<String, Slice> slices = null;
- for (int i = 75; i > 0; i--) {
+ for (int i = 100; i > 0; i--) {
clusterState2 = zkController2.getClusterState();
slices = clusterState2.getSlicesMap("collection1");
if (slices != null && slices.containsKey("shard1")
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java Mon Oct 21 18:58:24 2013
@@ -135,7 +135,7 @@ public class SyncSliceTest extends Abstr
HttpSolrServer baseServer = new HttpSolrServer(baseUrl);
baseServer.setConnectionTimeout(15000);
- baseServer.setSoTimeout(30000);
+ baseServer.setSoTimeout(60000);
baseServer.request(request);
waitForThingsToLevelOut(15);
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java Mon Oct 21 18:58:24 2013
@@ -98,7 +98,7 @@ public class UnloadDistributedZkTest ext
String url1 = getBaseUrl(client);
HttpSolrServer server = new HttpSolrServer(url1);
server.setConnectionTimeout(15000);
- server.setSoTimeout(30000);
+ server.setSoTimeout(60000);
server.request(createCmd);
createCmd = new Create();
@@ -164,7 +164,7 @@ public class UnloadDistributedZkTest ext
String url1 = getBaseUrl(client);
HttpSolrServer server = new HttpSolrServer(url1);
server.setConnectionTimeout(15000);
- server.setSoTimeout(30000);
+ server.setSoTimeout(60000);
Create createCmd = new Create();
createCmd.setCoreName("unloadcollection1");
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java Mon Oct 21 18:58:24 2013
@@ -18,10 +18,14 @@ package org.apache.solr.cloud;
*/
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
import java.util.Collection;
import java.util.List;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.io.filefilter.RegexFileFilter;
import org.apache.commons.io.filefilter.TrueFileFilter;
import org.apache.solr.SolrTestCaseJ4;
@@ -50,7 +54,8 @@ public class ZkCLITest extends SolrTestC
private String solrHome;
private SolrZkClient zkClient;
-
+
+ protected static final String SOLR_HOME = SolrTestCaseJ4.TEST_HOME();
@BeforeClass
public static void beforeClass() {
@@ -141,7 +146,7 @@ public class ZkCLITest extends SolrTestC
@Test
public void testPut() throws Exception {
- // test bootstrap_conf
+ // test put
String data = "my data";
String[] args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd",
"put", "/data.txt", data};
@@ -151,7 +156,41 @@ public class ZkCLITest extends SolrTestC
assertArrayEquals(zkClient.getData("/data.txt", null, null, true), data.getBytes("UTF-8"));
}
-
+
+ @Test
+ public void testPutFile() throws Exception {
+ // test put file
+ String[] args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd",
+ "putfile", "/solr.xml", SOLR_HOME + File.separator + "solr-stress-new.xml"};
+ ZkCLI.main(args);
+
+ String fromZk = new String(zkClient.getData("/solr.xml", null, null, true), "UTF-8");
+ File locFile = new File(SOLR_HOME + File.separator + "solr-stress-new.xml");
+ InputStream is = new FileInputStream(locFile);
+ String fromLoc;
+ try {
+ fromLoc = new String(IOUtils.toByteArray(is), "UTF-8");
+ } finally {
+ IOUtils.closeQuietly(is);
+ }
+ assertEquals("Should get back what we put in ZK", fromZk, fromLoc);
+ }
+
+ @Test
+ public void testPutFileNotExists() throws Exception {
+ // test put file
+ String[] args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd",
+ "putfile", "/solr.xml", SOLR_HOME + File.separator + "not-there.xml"};
+ try {
+ ZkCLI.main(args);
+ fail("Should have had a file not found exception");
+ } catch (FileNotFoundException fne) {
+ String msg = fne.getMessage();
+ assertTrue("Didn't find expected error message containing 'not-there.xml' in " + msg,
+ msg.indexOf("not-there.xml") != -1);
+ }
+ }
+
@Test
public void testList() throws Exception {
zkClient.makePath("/test", true);
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java Mon Oct 21 18:58:24 2013
@@ -17,6 +17,7 @@ package org.apache.solr.cloud;
* the License.
*/
+import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.SolrZkClient;
@@ -26,6 +27,7 @@ import org.apache.solr.core.CoreContaine
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.util.ExternalPaths;
import org.apache.zookeeper.CreateMode;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -42,12 +44,26 @@ public class ZkControllerTest extends So
static final int TIMEOUT = 10000;
private static final boolean DEBUG = false;
-
+
+
+ private static final File solrHomeDirectory = new File(TEMP_DIR, "ZkControllerTest");
+
@BeforeClass
public static void beforeClass() throws Exception {
+ if (solrHomeDirectory.exists()) {
+ FileUtils.deleteDirectory(solrHomeDirectory);
+ }
+ copyMinFullSetup(solrHomeDirectory);
initCore();
}
+ @AfterClass
+ public static void afterClass() throws Exception {
+ if (solrHomeDirectory.exists()) {
+ FileUtils.deleteDirectory(solrHomeDirectory);
+ }
+ }
+
public void testNodeNameUrlConversion() throws Exception {
// nodeName from parts
@@ -240,7 +256,7 @@ public class ZkControllerTest extends So
}
private CoreContainer getCoreContainer() {
- CoreContainer cc = new CoreContainer(TEMP_DIR.getAbsolutePath());
+ CoreContainer cc = new CoreContainer(solrHomeDirectory.getAbsolutePath());
cc.load();
return cc;
}
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsTestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsTestUtil.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsTestUtil.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsTestUtil.java Mon Oct 21 18:58:24 2013
@@ -80,6 +80,9 @@ public class HdfsTestUtil {
public static String getDataDir(MiniDFSCluster dfsCluster, String dataDir)
throws IOException {
+ if (dataDir == null) {
+ return null;
+ }
URI uri = dfsCluster.getURI();
String dir = uri.toString()
+ "/"
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.java Mon Oct 21 18:58:24 2013
@@ -115,26 +115,30 @@ public class StressHdfsTest extends Basi
int i = 0;
for (SolrServer client : clients) {
- HttpSolrServer c = new HttpSolrServer(getBaseUrl(client) + "/delete_data_dir");
- c.add(getDoc("id", i++));
- if (random().nextBoolean()) c.add(getDoc("id", i++));
- if (random().nextBoolean()) c.add(getDoc("id", i++));
- if (random().nextBoolean()) {
- c.commit();
- } else {
- c.commit(true, true, true);
+ HttpSolrServer c = new HttpSolrServer(getBaseUrl(client)
+ + "/delete_data_dir");
+ try {
+ c.add(getDoc("id", i++));
+ if (random().nextBoolean()) c.add(getDoc("id", i++));
+ if (random().nextBoolean()) c.add(getDoc("id", i++));
+ if (random().nextBoolean()) {
+ c.commit();
+ } else {
+ c.commit(true, true, true);
+ }
+
+ c.query(new SolrQuery("id:" + i));
+ c.setSoTimeout(60000);
+ c.setConnectionTimeout(30000);
+ NamedList<Object> response = c.query(
+ new SolrQuery().setRequestHandler("/admin/system")).getResponse();
+ NamedList<Object> coreInfo = (NamedList<Object>) response.get("core");
+ String dataDir = (String) ((NamedList<Object>) coreInfo
+ .get("directory")).get("data");
+ dataDirs.add(dataDir);
+ } finally {
+ c.shutdown();
}
-
- c.query(new SolrQuery("id:" + i));
- c.setSoTimeout(30000);
- c.setConnectionTimeout(30000);
- NamedList<Object> response = c.query(
- new SolrQuery().setRequestHandler("/admin/system")).getResponse();
- NamedList<Object> coreInfo = (NamedList<Object>) response.get("core");
- String dataDir = (String) ((NamedList<Object>) coreInfo.get("directory"))
- .get("data");
- dataDirs.add(dataDir);
- c.shutdown();
}
if (random().nextBoolean()) {
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/AlternateDirectoryTest.java Mon Oct 21 18:58:24 2013
@@ -20,6 +20,7 @@ import java.io.File;
import java.io.IOException;
import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.Directory;
import org.apache.solr.SolrTestCaseJ4;
import org.junit.BeforeClass;
@@ -71,6 +72,12 @@ public class AlternateDirectoryTest exte
TestIndexReaderFactory.newReaderCalled = true;
return DirectoryReader.open(indexDir);
}
+
+ @Override
+ public DirectoryReader newReader(IndexWriter writer, SolrCore core) throws IOException {
+ TestIndexReaderFactory.newReaderCalled = true;
+ return DirectoryReader.open(writer, true);
+ }
}
}
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java Mon Oct 21 18:58:24 2013
@@ -52,14 +52,14 @@ public class OpenCloseCoreStressTest ext
private final Object locker = new Object();
- private int numCores = 20;
+ private int numCores = TEST_NIGHTLY ? 7 : 5;
private Map<String, Long> coreCounts;
private List<String> coreNames;
static final int COMMIT_WITHIN = 5000;
- final int indexingThreads = 15;
- final int queryThreads = 15;
+ final int indexingThreads = TEST_NIGHTLY ? 9 : 5;
+ final int queryThreads = TEST_NIGHTLY ? 9 : 5;
final int resetInterval = 30 * 60; // minutes to report then delete everything
long cumulativeDocs = 0;
@@ -75,22 +75,6 @@ public class OpenCloseCoreStressTest ext
static String savedFactory;
- // Keep the indexes from being randomly generated.
- @BeforeClass
- public static void beforeClass() {
- savedFactory = System.getProperty("solr.DirectoryFactory");
- System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory");
- }
-
- @AfterClass
- public static void afterClass() {
- if (savedFactory == null) {
- System.clearProperty("solr.directoryFactory");
- } else {
- System.setProperty("solr.directoryFactory", savedFactory);
- }
- }
-
@Before
public void setupServer() throws Exception {
coreCounts = new TreeMap<String, Long>();
@@ -98,7 +82,7 @@ public class OpenCloseCoreStressTest ext
cumulativeDocs = 0;
solrHomeDirectory = new File(TEMP_DIR, "OpenCloseCoreStressTest_");
- FileUtils.deleteDirectory(solrHomeDirectory); // Insure that a failed test didn't leave something lying around.
+ FileUtils.deleteDirectory(solrHomeDirectory); // Ensure that a failed test didn't leave something lying around.
jetty = new JettySolrRunner(solrHomeDirectory.getAbsolutePath(), "/solr", 0);
}
@@ -111,14 +95,14 @@ public class OpenCloseCoreStressTest ext
@Test
@Slow
- public void test30SecondsOld() throws Exception {
- doStress(30, true);
+ public void test15SecondsOld() throws Exception {
+ doStress(15, true);
}
@Test
@Slow
- public void test30SecondsNew() throws Exception {
- doStress(30, false);
+ public void test15SecondsNew() throws Exception {
+ doStress(15, false);
}
@Test
@@ -156,7 +140,7 @@ public class OpenCloseCoreStressTest ext
HttpSolrServer server = new HttpSolrServer(url);
server.setDefaultMaxConnectionsPerHost(25);
server.setConnectionTimeout(30000);
- server.setSoTimeout(30000);
+ server.setSoTimeout(60000);
indexingServers.add(server);
}
for (int idx = 0; idx < queryThreads; ++idx) {
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/QueryResultKeyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/QueryResultKeyTest.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/QueryResultKeyTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/QueryResultKeyTest.java Mon Oct 21 18:58:24 2013
@@ -56,4 +56,24 @@ public class QueryResultKeyTest extends
assertEquals(qrk1.hashCode(), qrk2.hashCode());
}
+ @Test
+ public void testQueryResultKeySortedFilters() {
+ Query fq1 = new TermQuery(new Term("test1", "field1"));
+ Query fq2 = new TermQuery(new Term("test2", "field2"));
+
+ Query query = new TermQuery(new Term("test3", "field3"));
+ List<Query> filters = new ArrayList<Query>();
+ filters.add(fq1);
+ filters.add(fq2);
+
+ QueryResultKey key = new QueryResultKey(query, filters, null, 0);
+
+ List<Query> newFilters = new ArrayList<Query>();
+ newFilters.add(fq2);
+ newFilters.add(fq1);
+ QueryResultKey newKey = new QueryResultKey(query, newFilters, null, 0);
+
+ assertEquals(key, newKey);
+ }
+
}
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java Mon Oct 21 18:58:24 2013
@@ -19,10 +19,10 @@ package org.apache.solr.core;
import junit.framework.Assert;
-import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.analysis.core.KeywordTokenizerFactory;
import org.apache.lucene.analysis.ngram.NGramFilterFactory;
import org.apache.lucene.util._TestUtil;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.handler.admin.LukeRequestHandler;
import org.apache.solr.handler.component.FacetComponent;
@@ -33,6 +33,7 @@ import org.apache.solr.util.plugin.SolrC
import java.io.File;
import java.io.FileFilter;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.CharacterCodingException;
import java.util.Arrays;
@@ -41,23 +42,46 @@ import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
-public class ResourceLoaderTest extends LuceneTestCase
+public class ResourceLoaderTest extends SolrTestCaseJ4
{
public void testInstanceDir() throws Exception {
SolrResourceLoader loader = new SolrResourceLoader(null);
String instDir = loader.getInstanceDir();
assertTrue(instDir + " is not equal to " + "solr/", instDir.equals("solr/") == true);
+ loader.close();
loader = new SolrResourceLoader("solr");
instDir = loader.getInstanceDir();
assertTrue(instDir + " is not equal to " + "solr/", instDir.equals("solr" + File.separator) == true);
+ loader.close();
+ }
+
+ public void testEscapeInstanceDir() throws Exception {
+ File temp = _TestUtil.getTempDir("testEscapeInstanceDir");
+ try {
+ temp.mkdirs();
+ new File(temp, "dummy.txt").createNewFile();
+ File instanceDir = new File(temp, "instance");
+ instanceDir.mkdir();
+ new File(instanceDir, "conf").mkdir();
+ SolrResourceLoader loader = new SolrResourceLoader(instanceDir.getAbsolutePath());
+ try {
+ loader.openResource("../../dummy.txt").close();
+ fail();
+ } catch (IOException ioe) {
+ assertTrue(ioe.getMessage().startsWith("For security reasons, SolrResourceLoader"));
+ }
+ loader.close();
+ } finally {
+ _TestUtil.rmDir(temp);
+ }
}
- public void testAwareCompatibility()
+ public void testAwareCompatibility() throws Exception
{
SolrResourceLoader loader = new SolrResourceLoader( "." );
- Class clazz = ResourceLoaderAware.class;
+ Class<?> clazz = ResourceLoaderAware.class;
// Check ResourceLoaderAware valid objects
loader.assertAwareCompatibility( clazz, new NGramFilterFactory(new HashMap<String,String>()) );
loader.assertAwareCompatibility( clazz, new KeywordTokenizerFactory(new HashMap<String,String>()) );
@@ -97,6 +121,8 @@ public class ResourceLoaderTest extends
}
catch( SolrException ex ) { } // OK
}
+
+ loader.close();
}
public void testBOMMarkers() throws Exception {
@@ -123,6 +149,8 @@ public class ResourceLoaderTest extends
List<String> lines = loader.getLines(fileWithBom);
assertEquals(1, lines.size());
assertEquals("BOMsAreEvil", lines.get(0));
+
+ loader.close();
}
public void testWrongEncoding() throws Exception {
@@ -130,11 +158,12 @@ public class ResourceLoaderTest extends
SolrResourceLoader loader = new SolrResourceLoader("solr/collection1");
// ensure we get our exception
try {
- List<String> lines = loader.getLines(wrongEncoding);
+ loader.getLines(wrongEncoding);
fail();
} catch (SolrException expected) {
assertTrue(expected.getCause() instanceof CharacterCodingException);
}
+ loader.close();
}
public void testClassLoaderLibs() throws Exception {
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestArbitraryIndexDir.java Mon Oct 21 18:58:24 2013
@@ -53,12 +53,15 @@ public class TestArbitraryIndexDir exten
static String savedFactory;
@BeforeClass
public static void beforeClass() {
+ // this test wants to start solr, and then open a separate indexwriter of its own on the same dir.
+ System.setProperty("solr.tests.nrtMode", "false");
System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
savedFactory = System.getProperty("solr.DirectoryFactory");
System.setProperty("solr.directoryFactory", "org.apache.solr.core.MockFSDirectoryFactory");
}
@AfterClass
public static void afterClass() {
+ System.clearProperty("solr.tests.nrtMode");
if (savedFactory == null) {
System.clearProperty("solr.directoryFactory");
} else {
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestBadConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestBadConfig.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestBadConfig.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestBadConfig.java Mon Oct 21 18:58:24 2013
@@ -27,6 +27,14 @@ public class TestBadConfig extends Abstr
assertConfigs("bad_solrconfig.xml","schema.xml","unset.sys.property");
}
+ public void testSegmentMergerWithoutReopen() throws Exception {
+ assertConfigs("bad-solrconfig-warmer-no-reopen.xml", "schema12.xml",
+ "mergedSegmentWarmer");
+ }
+ public void testMultipleDirectoryFactories() throws Exception {
+ assertConfigs("bad-solrconfig-multiple-dirfactory.xml", "schema12.xml",
+ "directoryFactory");
+ }
public void testMultipleIndexConfigs() throws Exception {
assertConfigs("bad-solrconfig-multiple-indexconfigs.xml", "schema12.xml",
"indexConfig");
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestCodecSupport.java Mon Oct 21 18:58:24 2013
@@ -55,10 +55,10 @@ public class TestCodecSupport extends So
PerFieldDocValuesFormat format = (PerFieldDocValuesFormat) codec.docValuesFormat();
assertEquals("Disk", format.getDocValuesFormatForField(schemaField.getName()).getName());
schemaField = fields.get("string_memory_f");
- assertEquals("Lucene42",
+ assertEquals("Lucene45",
format.getDocValuesFormatForField(schemaField.getName()).getName());
schemaField = fields.get("string_f");
- assertEquals("Lucene42",
+ assertEquals("Lucene45",
format.getDocValuesFormatForField(schemaField.getName()).getName());
}
@@ -80,8 +80,8 @@ public class TestCodecSupport extends So
assertEquals("Disk", format.getDocValuesFormatForField("foo_disk").getName());
assertEquals("Disk", format.getDocValuesFormatForField("bar_disk").getName());
- assertEquals("Lucene42", format.getDocValuesFormatForField("foo_memory").getName());
- assertEquals("Lucene42", format.getDocValuesFormatForField("bar_memory").getName());
+ assertEquals("Lucene45", format.getDocValuesFormatForField("foo_memory").getName());
+ assertEquals("Lucene45", format.getDocValuesFormatForField("bar_memory").getName());
}
public void testUnknownField() {
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestConfig.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestConfig.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestConfig.java Mon Oct 21 18:58:24 2013
@@ -70,6 +70,11 @@ public class TestConfig extends SolrTest
assertNull("should not have been able to find " + f, data);
}
}
+ @Test
+ public void testDisableRequetsHandler() throws Exception {
+ assertNull(h.getCore().getRequestHandler("disabled"));
+ assertNotNull(h.getCore().getRequestHandler("enabled"));
+ }
@Test
public void testJavaProperty() {
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java Mon Oct 21 18:58:24 2013
@@ -181,6 +181,11 @@ public class TestCoreContainer extends S
}
+ @Test
+ public void testLogWatcherEnabledByDefault() {
+ assertNotNull(h.getCoreContainer().getLogging());
+ }
+
private void SetUpHome(File solrHomeDirectory, String xmlFile) throws IOException {
if (solrHomeDirectory.exists()) {
FileUtils.deleteDirectory(solrHomeDirectory);
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestLazyCores.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestLazyCores.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestLazyCores.java Mon Oct 21 18:58:24 2013
@@ -17,8 +17,8 @@ package org.apache.solr.core;
* limitations under the License.
*/
+import org.apache.commons.codec.Charsets;
import org.apache.commons.io.FileUtils;
-import org.apache.lucene.util.IOUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CoreAdminParams;
@@ -40,9 +40,12 @@ import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
public class TestLazyCores extends SolrTestCaseJ4 {
@@ -51,7 +54,7 @@ public class TestLazyCores extends SolrT
initCore("solrconfig-minimal.xml", "schema-tiny.xml");
}
- private final File solrHomeDirectory = new File(TEMP_DIR, "org.apache.solr.core.TestLazyCores_testlazy");
+ private final File solrHomeDirectory = new File(TEMP_DIR, TestLazyCores.getSimpleClassName());
private CoreContainer init() throws Exception {
@@ -66,10 +69,10 @@ public class TestLazyCores extends SolrT
SolrResourceLoader loader = new SolrResourceLoader(solrHomeDirectory.getAbsolutePath());
File solrXml = new File(solrHomeDirectory, "solr.xml");
- FileUtils.write(solrXml, LOTS_SOLR_XML, IOUtils.CHARSET_UTF_8.toString());
+ FileUtils.write(solrXml, LOTS_SOLR_XML, Charsets.UTF_8.toString());
ConfigSolrXmlOld config = (ConfigSolrXmlOld) ConfigSolr.fromFile(loader, solrXml);
- CoresLocator locator = new SolrXMLCoresLocator.NonPersistingLocator(solrXml, LOTS_SOLR_XML, config);
+ CoresLocator locator = new SolrXMLCoresLocator.NonPersistingLocator(LOTS_SOLR_XML, config);
final CoreContainer cores = new CoreContainer(loader, config, locator);
@@ -127,6 +130,40 @@ public class TestLazyCores extends SolrT
// This is a little weak. I'm not sure how to test that lazy core2 is loaded automagically. The getCore
// will, of course, load it.
+ private void checkSearch(SolrCore core) throws IOException {
+ addLazy(core, "id", "0");
+ addLazy(core, "id", "1", "v_t", "Hello Dude");
+ addLazy(core, "id", "2", "v_t", "Hello Yonik");
+ addLazy(core, "id", "3", "v_s", "{!literal}");
+ addLazy(core, "id", "4", "v_s", "other stuff");
+ addLazy(core, "id", "5", "v_f", "3.14159");
+ addLazy(core, "id", "6", "v_f", "8983");
+
+ SolrQueryRequest req = makeReq(core);
+ CommitUpdateCommand cmtCmd = new CommitUpdateCommand(req, false);
+ core.getUpdateHandler().commit(cmtCmd);
+
+ // Just get a couple of searches to work!
+ assertQ("test prefix query",
+ makeReq(core, "q", "{!prefix f=v_t}hel", "wt", "xml")
+ , "//result[@numFound='2']"
+ );
+
+ assertQ("test raw query",
+ makeReq(core, "q", "{!raw f=v_t}hello", "wt", "xml")
+ , "//result[@numFound='2']"
+ );
+
+ // no analysis is done, so these should match nothing
+ assertQ("test raw query",
+ makeReq(core, "q", "{!raw f=v_t}Hello", "wt", "xml")
+ , "//result[@numFound='0']"
+ );
+ assertQ("test raw query",
+ makeReq(core, "q", "{!raw f=v_f}1.5", "wt", "xml")
+ , "//result[@numFound='0']"
+ );
+ }
@Test
public void testLazySearch() throws Exception {
CoreContainer cc = init();
@@ -135,31 +172,7 @@ public class TestLazyCores extends SolrT
checkNotInCores(cc, "collectionLazy4");
SolrCore core4 = cc.getCore("collectionLazy4");
- addLazy(core4, "id", "0");
- addLazy(core4, "id", "1", "v_t", "Hello Dude");
- addLazy(core4, "id", "2", "v_t", "Hello Yonik");
- addLazy(core4, "id", "3", "v_s", "{!literal}");
- addLazy(core4, "id", "4", "v_s", "other stuff");
- addLazy(core4, "id", "5", "v_f", "3.14159");
- addLazy(core4, "id", "6", "v_f", "8983");
-
- SolrQueryRequest req = makeReq(core4);
- CommitUpdateCommand cmtCmd = new CommitUpdateCommand(req, false);
- core4.getUpdateHandler().commit(cmtCmd);
-
- RefCounted<SolrIndexSearcher> holder = core4.getSearcher();
- SolrIndexSearcher searcher = holder.get();
-
- // Just get a couple of searches to work!
- assertQ("test prefix query",
- makeReq(core4, "q", "{!prefix f=v_t}hel", "wt", "xml")
- , "//result[@numFound='2']"
- );
-
- assertQ("test raw query",
- makeReq(core4, "q", "{!raw f=v_t}hello", "wt", "xml")
- , "//result[@numFound='2']"
- );
+ checkSearch(core4);
// Now just insure that the normal searching on "collection1" finds _0_ on the same query that found _2_ above.
// Use of makeReq above and req below is tricky, very tricky.
@@ -168,19 +181,8 @@ public class TestLazyCores extends SolrT
, "//result[@numFound='0']"
);
- // no analysis is done, so these should match nothing
- assertQ("test raw query",
- makeReq(core4, "q", "{!raw f=v_t}Hello", "wt", "xml")
- , "//result[@numFound='0']"
- );
- assertQ("test raw query",
- makeReq(core4, "q", "{!raw f=v_f}1.5", "wt", "xml")
- , "//result[@numFound='0']"
- );
-
checkInCores(cc, "collectionLazy4");
- searcher.close();
core4.close();
} finally {
cc.shutdown();
@@ -400,6 +402,204 @@ public class TestLazyCores extends SolrT
}
}
+
+ // Test that transient cores
+ // 1> produce errors as appropriate when the config or schema files are foo'd
+ // 2> "self heal". That is, if the problem is corrected can the core be reloaded and used?
+ // 3> that OK cores can be searched even when some cores failed to load.
+ @Test
+ public void testBadConfigsGenerateErrors() throws Exception {
+ final CoreContainer cc = initGoodAndBad(Arrays.asList("core1", "core2"),
+ Arrays.asList("badSchema1", "badSchema2"),
+ Arrays.asList("badConfig1", "badConfig2"));
+ try {
+ // first, did the two good cores load successfully?
+ checkInCores(cc, "core1", "core2");
+
+ // Did the bad cores fail to load?
+ checkNotInCores(cc, "badSchema1", "badSchema2", "badConfig1", "badConfig2");
+
+ // Can we still search the "good" cores even though there were core init failures?
+ SolrCore core1 = cc.getCore("core1");
+ checkSearch(core1);
+
+ // Did we get the expected message for each of the cores that failed to load? Make sure we don't run afoul of
+ // the dreaded slash/backslash difference on Windows and *nix machines.
+ testMessage(cc.getCoreInitFailures(),
+ "TestLazyCores" + File.separator + "badConfig1" + File.separator + "solrconfig.xml");
+ testMessage(cc.getCoreInitFailures(),
+ "TestLazyCores" + File.separator + "badConfig2" + File.separator + "solrconfig.xml");
+ testMessage(cc.getCoreInitFailures(),
+ "TestLazyCores" + File.separator + "badSchema1" + File.separator + "schema.xml");
+ testMessage(cc.getCoreInitFailures(),
+ "TestLazyCores" + File.separator + "badSchema2" + File.separator + "schema.xml");
+
+ // Status should report that there are failure messages for the bad cores and none for the good cores.
+ checkStatus(cc, true, "core1");
+ checkStatus(cc, true, "core2");
+ checkStatus(cc, false, "badSchema1");
+ checkStatus(cc, false, "badSchema2");
+ checkStatus(cc, false, "badConfig1");
+ checkStatus(cc, false, "badConfig2");
+
+ // Copy good config and schema files in and see if you can then load them (they are transient after all)
+ copyGoodConf("badConfig1", "solrconfig-minimal.xml", "solrconfig.xml");
+ copyGoodConf("badConfig2", "solrconfig-minimal.xml", "solrconfig.xml");
+ copyGoodConf("badSchema1", "schema-tiny.xml", "schema.xml");
+ copyGoodConf("badSchema2", "schema-tiny.xml", "schema.xml");
+
+ // This should force a reload of the cores.
+ SolrCore bc1 = cc.getCore("badConfig1");
+ SolrCore bc2 = cc.getCore("badConfig2");
+ SolrCore bs1 = cc.getCore("badSchema1");
+ SolrCore bs2 = cc.getCore("badSchema2");
+
+ // all the cores should be found in the list now.
+ checkInCores(cc, "core1", "core2", "badSchema1", "badSchema2", "badConfig1", "badConfig2");
+
+ // Did we clear out the errors by putting good files in place? And the cores that never were bad should be OK too.
+ checkStatus(cc, true, "core1");
+ checkStatus(cc, true, "core2");
+ checkStatus(cc, true, "badSchema1");
+ checkStatus(cc, true, "badSchema2");
+ checkStatus(cc, true, "badConfig1");
+ checkStatus(cc, true, "badConfig2");
+
+ // Are the formerly bad cores now searchable? Testing one of each should do.
+ checkSearch(core1);
+ checkSearch(bc1);
+ checkSearch(bs1);
+
+ core1.close();
+ bc1.close();
+ bc2.close();
+ bs1.close();
+ bs2.close();
+ } finally {
+ cc.shutdown();
+ }
+ }
+
+ // See fi the message you expect is in the list of failures
+ private void testMessage(Map<String, Exception> failures, String lookFor) {
+ for (Exception e : failures.values()) {
+ if (e.getMessage().indexOf(lookFor) != -1) return;
+ }
+ fail("Should have found message containing these tokens " + lookFor + " in the failure messages");
+ }
+
+ // Just localizes writing a configuration rather than repeating it for good and bad files.
+ private void writeCustomConfig(String coreName, String config, String schema, String rand_snip) throws IOException {
+
+ File coreRoot = new File(solrHomeDirectory, coreName);
+ File subHome = new File(coreRoot, "conf");
+ if (!coreRoot.exists()) {
+ assertTrue("Failed to make subdirectory ", coreRoot.mkdirs());
+ }
+ // Write the file for core discovery
+ FileUtils.writeStringToFile(new File(coreRoot, "core.properties"), "name=" + coreName +
+ System.getProperty("line.separator") + "transient=true" +
+ System.getProperty("line.separator") + "loadOnStartup=true", Charsets.UTF_8.toString());
+
+ FileUtils.writeStringToFile(new File(subHome, "solrconfig.snippet.randomindexconfig.xml"), rand_snip);
+
+ FileUtils.writeStringToFile(new File(subHome, "solrconfig.xml"), config, Charsets.UTF_8.toString());
+
+ FileUtils.writeStringToFile(new File(subHome, "schema.xml"), schema, Charsets.UTF_8.toString());
+ }
+
+ // Write out the cores' config files, both bad schema files, bad config files as well as some good cores.
+ private CoreContainer initGoodAndBad(List<String> goodCores,
+ List<String> badSchemaCores,
+ List<String> badConfigCores) throws Exception {
+
+ // Don't pollute the log with exception traces when they're expected.
+ ignoreException(Pattern.quote("SAXParseException"));
+
+ if (solrHomeDirectory.exists()) {
+ FileUtils.deleteDirectory(solrHomeDirectory);
+ }
+ assertTrue("Failed to mkdirs workDir", solrHomeDirectory.mkdirs());
+
+ // Create the cores that should be fine.
+ for (String coreName : goodCores) {
+ File coreRoot = new File(solrHomeDirectory, coreName);
+ copyMinConf(coreRoot, "name=" + coreName);
+
+ }
+
+ // Collect the files that we'll write to the config directories.
+ String top = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf";
+ String min_schema = FileUtils.readFileToString(new File(top, "schema-tiny.xml"),
+ Charsets.UTF_8.toString());
+ String min_config = FileUtils.readFileToString(new File(top, "solrconfig-minimal.xml"),
+ Charsets.UTF_8.toString());
+ String rand_snip = FileUtils.readFileToString(new File(top, "solrconfig.snippet.randomindexconfig.xml"),
+ Charsets.UTF_8.toString());
+
+ // Now purposely mess up the config files, introducing stupid syntax errors.
+ String bad_config = min_config.replace("<requestHandler", "<reqsthalr");
+ String bad_schema = min_schema.replace("<field", "<filed");
+
+ // Create the cores with bad configs
+ for (String coreName : badConfigCores) {
+ writeCustomConfig(coreName, bad_config, min_schema, rand_snip);
+ }
+
+ // Create the cores with bad schemas.
+ for (String coreName : badSchemaCores) {
+ writeCustomConfig(coreName, min_config, bad_schema, rand_snip);
+ }
+
+ // Write the solr.xml file. Cute how minimal it can be now....
+ File solrXml = new File(solrHomeDirectory, "solr.xml");
+ FileUtils.write(solrXml, "<solr/>", Charsets.UTF_8.toString());
+
+ SolrResourceLoader loader = new SolrResourceLoader(solrHomeDirectory.getAbsolutePath());
+ ConfigSolrXml config = (ConfigSolrXml) ConfigSolr.fromFile(loader, solrXml);
+
+ CoresLocator locator = new CorePropertiesLocator(solrHomeDirectory.getAbsolutePath());
+
+ // OK this should succeed, but at the end we should have recorded a series of errors.
+ final CoreContainer cores = new CoreContainer(loader, config, locator);
+ cores.load();
+ return cores;
+ }
+
+ // We want to see that the core "heals itself" if an un-corrupted file is written to the directory.
+ private void copyGoodConf(String coreName, String srcName, String dstName) throws IOException {
+ File coreRoot = new File(solrHomeDirectory, coreName);
+ File subHome = new File(coreRoot, "conf");
+ String top = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf";
+ FileUtils.copyFile(new File(top, srcName), new File(subHome, dstName));
+
+ }
+
+ // If ok==true, we shouldn't be seeing any failure cases.
+ // if ok==false, the core being examined should have a failure in the list.
+ private void checkStatus(CoreContainer cc, Boolean ok, String core) throws Exception {
+ SolrQueryResponse resp = new SolrQueryResponse();
+ final CoreAdminHandler admin = new CoreAdminHandler(cc);
+ admin.handleRequestBody
+ (req(CoreAdminParams.ACTION,
+ CoreAdminParams.CoreAdminAction.STATUS.toString(),
+ CoreAdminParams.CORE, core),
+ resp);
+
+ Map<String, Exception> failures =
+ (Map<String, Exception>) resp.getValues().get("initFailures");
+
+ if (ok) {
+ if (failures.size() != 0) {
+ fail("Should have cleared the error, but there are failues " + failures.toString());
+ }
+ } else {
+ if (failures.size() == 0) {
+ fail("Should have had errors here but the status return has no failures!");
+ }
+ }
+ }
+
private void removeOne(CoreContainer cc, String coreName) {
SolrCore tmp = cc.remove(coreName);
if (tmp != null) tmp.close();
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java Mon Oct 21 18:58:24 2013
@@ -27,6 +27,9 @@ import org.apache.lucene.index.SegmentIn
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.MergePolicy;
import org.apache.lucene.index.TieredMergePolicy;
+import org.apache.lucene.index.LogMergePolicy;
+import org.apache.lucene.index.LogByteSizeMergePolicy;
+import org.apache.lucene.index.LogDocMergePolicy;
import org.apache.lucene.index.ConcurrentMergeScheduler;
import org.apache.solr.core.SolrCore;
import org.apache.solr.util.RefCounted;
@@ -82,7 +85,7 @@ public class TestMergePolicyConfig exten
final boolean expectCFS
= Boolean.parseBoolean(System.getProperty("useCompoundFile"));
- initCore("solrconfig-mergepolicy.xml","schema-minimal.xml");
+ initCore("solrconfig-tieredmergepolicy.xml","schema-minimal.xml");
IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());
assertEquals(expectCFS, iwc.getUseCompoundFile());
@@ -116,6 +119,37 @@ public class TestMergePolicyConfig exten
assertCompoundSegments(h.getCore(), false);
}
+ public void testLogMergePolicyConfig() throws Exception {
+
+ final Class<? extends LogMergePolicy> mpClass = random().nextBoolean()
+ ? LogByteSizeMergePolicy.class : LogDocMergePolicy.class;
+
+ System.setProperty("solr.test.log.merge.policy", mpClass.getName());
+
+ initCore("solrconfig-logmergepolicy.xml","schema-minimal.xml");
+ IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());
+
+ // verify some props set to -1 get lucene internal defaults
+ assertEquals(-1, solrConfig.indexConfig.maxBufferedDocs);
+ assertEquals(IndexWriterConfig.DISABLE_AUTO_FLUSH,
+ iwc.getMaxBufferedDocs());
+ assertEquals(-1, solrConfig.indexConfig.maxIndexingThreads);
+ assertEquals(IndexWriterConfig.DEFAULT_MAX_THREAD_STATES,
+ iwc.getMaxThreadStates());
+ assertEquals(-1, solrConfig.indexConfig.ramBufferSizeMB, 0.0D);
+ assertEquals(IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB,
+ iwc.getRAMBufferSizeMB(), 0.0D);
+
+
+ LogMergePolicy logMP = assertAndCast(mpClass, iwc.getMergePolicy());
+
+ // set by legacy <mergeFactor> setting
+ assertEquals(11, logMP.getMergeFactor());
+ // set by legacy <maxMergeDocs> setting
+ assertEquals(456, logMP.getMaxMergeDocs());
+
+ }
+
/**
* Given a Type and an object asserts that the object is non-null and an
* instance of the specified Type. The object is then cast to that type and
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistence.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistence.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistence.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistence.java Mon Oct 21 18:58:24 2013
@@ -382,7 +382,10 @@ public class TestSolrXmlPersistence exte
@Test
public void testPersist() throws Exception {
- final CoreContainer cores = init(ConfigSolrXmlOld.DEF_SOLR_XML, "collection1");
+ String defXml = FileUtils.readFileToString(
+ new File(SolrTestCaseJ4.TEST_HOME(), "solr.xml"),
+ Charsets.UTF_8.toString());
+ final CoreContainer cores = init(defXml, "collection1");
SolrXMLCoresLocator.NonPersistingLocator locator
= (SolrXMLCoresLocator.NonPersistingLocator) cores.getCoresLocator();
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistor.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistor.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistor.java Mon Oct 21 18:58:24 2013
@@ -18,15 +18,18 @@ package org.apache.solr.core;
*/
import com.google.common.collect.ImmutableList;
+import org.apache.commons.io.FileUtils;
+import org.apache.solr.SolrTestCaseJ4;
import org.junit.Test;
import java.io.File;
+import java.io.IOException;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-public class TestSolrXmlPersistor {
+public class TestSolrXmlPersistor extends SolrTestCaseJ4 {
private static final List<CoreDescriptor> EMPTY_CD_LIST = ImmutableList.<CoreDescriptor>builder().build();
@@ -35,7 +38,7 @@ public class TestSolrXmlPersistor {
final String solrxml = "<solr><cores adminHandler=\"/admin\"/></solr>";
- SolrXMLCoresLocator persistor = new SolrXMLCoresLocator(new File("testfile.xml"), solrxml, null);
+ SolrXMLCoresLocator persistor = new SolrXMLCoresLocator(solrxml, null);
assertEquals(persistor.buildSolrXML(EMPTY_CD_LIST),
"<solr><cores adminHandler=\"/admin\"></cores></solr>");
@@ -45,7 +48,7 @@ public class TestSolrXmlPersistor {
public void emptyCoresTagIsPersisted() {
final String solrxml = "<solr><cores adminHandler=\"/admin\"></cores></solr>";
- SolrXMLCoresLocator persistor = new SolrXMLCoresLocator(new File("testfile.xml"), solrxml, null);
+ SolrXMLCoresLocator persistor = new SolrXMLCoresLocator(solrxml, null);
assertEquals(persistor.buildSolrXML(EMPTY_CD_LIST), "<solr><cores adminHandler=\"/admin\"></cores></solr>");
}
@@ -53,26 +56,38 @@ public class TestSolrXmlPersistor {
public void emptySolrXmlIsPersisted() {
final String solrxml = "<solr></solr>";
- SolrXMLCoresLocator persistor = new SolrXMLCoresLocator(new File("testfile.xml"), solrxml, null);
+ SolrXMLCoresLocator persistor = new SolrXMLCoresLocator(solrxml, null);
assertEquals(persistor.buildSolrXML(EMPTY_CD_LIST), "<solr><cores></cores></solr>");
}
@Test
- public void simpleCoreDescriptorIsPersisted() {
+ public void simpleCoreDescriptorIsPersisted() throws IOException {
final String solrxml = "<solr><cores></cores></solr>";
- SolrResourceLoader loader = new SolrResourceLoader("solr/example/solr");
- CoreContainer cc = new CoreContainer(loader);
+ final File solrHomeDirectory = new File(TEMP_DIR, "ZkControllerTest");
+ try {
+ if (solrHomeDirectory.exists()) {
+ FileUtils.deleteDirectory(solrHomeDirectory);
+ }
+ copyMinFullSetup(solrHomeDirectory);
- final CoreDescriptor cd = new CoreDescriptor(cc, "testcore", "instance/dir/");
- List<CoreDescriptor> cds = ImmutableList.of(cd);
+ CoreContainer cc = new CoreContainer(solrHomeDirectory.getAbsolutePath());
- SolrXMLCoresLocator persistor = new SolrXMLCoresLocator(new File("testfile.xml"), solrxml, null);
- assertEquals(persistor.buildSolrXML(cds),
+ final CoreDescriptor cd = new CoreDescriptor(cc, "testcore", "instance/dir/");
+ List<CoreDescriptor> cds = ImmutableList.of(cd);
+
+ SolrXMLCoresLocator persistor = new SolrXMLCoresLocator(solrxml, null);
+ assertEquals(persistor.buildSolrXML(cds),
"<solr><cores>" + SolrXMLCoresLocator.NEWLINE
- + " <core name=\"testcore\" instanceDir=\"instance/dir/\"/>" + SolrXMLCoresLocator.NEWLINE
- + "</cores></solr>");
+ + " <core name=\"testcore\" instanceDir=\"instance/dir/\"/>" + SolrXMLCoresLocator.NEWLINE
+ + "</cores></solr>");
+ } finally {
+ if (solrHomeDirectory.exists()) {
+ FileUtils.deleteDirectory(solrHomeDirectory);
+ }
+
+ }
}
@Test
@@ -89,7 +104,7 @@ public class TestSolrXmlPersistor {
"</cores>" +
"</solr>";
- SolrXMLCoresLocator locator = new SolrXMLCoresLocator(new File("testfile.xml"), solrxml, null);
+ SolrXMLCoresLocator locator = new SolrXMLCoresLocator(solrxml, null);
assertTrue(locator.getTemplate().contains("{{CORES_PLACEHOLDER}}"));
assertTrue(locator.getTemplate().contains("<shardHandlerFactory "));
assertTrue(locator.getTemplate().contains("${socketTimeout:500}"));
@@ -107,15 +122,14 @@ public class TestSolrXmlPersistor {
"</cores>" +
"</solr>";
- SolrXMLCoresLocator locator = new SolrXMLCoresLocator(new File("testfile.xml"), solrxml, null);
+ SolrXMLCoresLocator locator = new SolrXMLCoresLocator(solrxml, null);
assertTrue(locator.getTemplate().contains("{{CORES_PLACEHOLDER}}"));
assertTrue(locator.getTemplate().contains("<shardHandlerFactory "));
}
@Test
public void complexXmlIsParsed() {
- SolrXMLCoresLocator locator = new SolrXMLCoresLocator(new File("testfile.xml"),
- TestSolrXmlPersistence.SOLR_XML_LOTS_SYSVARS, null);
+ SolrXMLCoresLocator locator = new SolrXMLCoresLocator(TestSolrXmlPersistence.SOLR_XML_LOTS_SYSVARS, null);
assertTrue(locator.getTemplate().contains("{{CORES_PLACEHOLDER}}"));
}
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java Mon Oct 21 18:58:24 2013
@@ -69,8 +69,10 @@ import org.apache.solr.core.SolrCore;
import org.apache.solr.core.StandardDirectoryFactory;
import org.apache.solr.servlet.SolrDispatchFilter;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.apache.solr.util.FileUtils;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -139,7 +141,7 @@ public class TestReplicationHandler exte
private static JettySolrRunner createJetty(SolrInstance instance) throws Exception {
System.setProperty("solr.data.dir", instance.getDataDir());
-
+ FileUtils.copyFile(new File(SolrTestCaseJ4.TEST_HOME(), "solr.xml"), new File(instance.getHomeDir(), "solr.xml"));
JettySolrRunner jetty = new JettySolrRunner(instance.getHomeDir(), "/solr", 0);
jetty.start();
@@ -346,6 +348,9 @@ public class TestReplicationHandler exte
public void testNoWriter() throws Exception {
useFactory(null); // force a persistent directory
+ // read-only setting (no opening from indexwriter)
+ System.setProperty("solr.tests.nrtMode", "false");
+ try {
// stop and start so they see the new directory setting
slaveJetty.stop();
masterJetty.stop();
@@ -356,6 +361,9 @@ public class TestReplicationHandler exte
slaveClient.commit();
slaveJetty.stop();
slaveJetty.start(true);
+ } finally {
+ System.clearProperty("solr.tests.nrtMode"); // dont mess with other tests
+ }
// Currently we open a writer on-demand. This is to test that we are correctly testing
// the code path when SolrDeletionPolicy.getLatestCommit() returns null.
@@ -743,7 +751,7 @@ public class TestReplicationHandler exte
}
- @Test
+ @Test @Ignore("https://issues.apache.org/jira/browse/SOLR-5343")
public void doTestStressReplication() throws Exception {
// change solrconfig on slave
// this has no entry for pollinginterval
Modified: lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java?rev=1534320&r1=1534319&r2=1534320&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java Mon Oct 21 18:58:24 2013
@@ -22,6 +22,7 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.GroupParams;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.QueryElevationParams;
import org.apache.solr.util.FileUtils;
@@ -106,6 +107,208 @@ public class QueryElevationComponentTest
}
@Test
+ public void testGroupedQuery() throws Exception {
+ try {
+ init("schema11.xml");
+ clearIndex();
+ assertU(commit());
+ assertU(adoc("id", "1", "text", "XXXX XXXX", "str_s", "a"));
+ assertU(adoc("id", "2", "text", "XXXX AAAA", "str_s", "b"));
+ assertU(adoc("id", "3", "text", "ZZZZ", "str_s", "c"));
+ assertU(adoc("id", "4", "text", "XXXX ZZZZ", "str_s", "d"));
+ assertU(adoc("id", "5", "text", "ZZZZ ZZZZ", "str_s", "e"));
+ assertU(adoc("id", "6", "text", "AAAA AAAA AAAA", "str_s", "f"));
+ assertU(adoc("id", "7", "text", "AAAA AAAA ZZZZ", "str_s", "g"));
+ assertU(adoc("id", "8", "text", "XXXX", "str_s", "h"));
+ assertU(adoc("id", "9", "text", "YYYY ZZZZ", "str_s", "i"));
+
+ assertU(adoc("id", "22", "text", "XXXX ZZZZ AAAA", "str_s", "b"));
+ assertU(adoc("id", "66", "text", "XXXX ZZZZ AAAA", "str_s", "f"));
+ assertU(adoc("id", "77", "text", "XXXX ZZZZ AAAA", "str_s", "g"));
+
+ assertU(commit());
+
+ final String groups = "//arr[@name='groups']";
+
+ assertQ("non-elevated group query",
+ req(CommonParams.Q, "AAAA",
+ CommonParams.QT, "/elevate",
+ GroupParams.GROUP_FIELD, "str_s",
+ GroupParams.GROUP, "true",
+ GroupParams.GROUP_TOTAL_COUNT, "true",
+ GroupParams.GROUP_LIMIT, "100",
+ QueryElevationParams.ENABLE, "false",
+ CommonParams.FL, "id, score, [elevated]")
+ , "//*[@name='ngroups'][.='3']"
+ , "//*[@name='matches'][.='6']"
+
+ , groups +"/lst[1]//doc[1]/float[@name='id'][.='6.0']"
+ , groups +"/lst[1]//doc[1]/bool[@name='[elevated]'][.='false']"
+ , groups +"/lst[1]//doc[2]/float[@name='id'][.='66.0']"
+ , groups +"/lst[1]//doc[2]/bool[@name='[elevated]'][.='false']"
+
+ , groups +"/lst[2]//doc[1]/float[@name='id'][.='7.0']"
+ , groups +"/lst[2]//doc[1]/bool[@name='[elevated]'][.='false']"
+ , groups +"/lst[2]//doc[2]/float[@name='id'][.='77.0']"
+ , groups +"/lst[2]//doc[2]/bool[@name='[elevated]'][.='false']"
+
+ , groups +"/lst[3]//doc[1]/float[@name='id'][.='2.0']"
+ , groups +"/lst[3]//doc[1]/bool[@name='[elevated]'][.='false']"
+ , groups +"/lst[3]//doc[2]/float[@name='id'][.='22.0']"
+ , groups +"/lst[3]//doc[2]/bool[@name='[elevated]'][.='false']"
+ );
+
+ assertQ("elevated group query",
+ req(CommonParams.Q, "AAAA",
+ CommonParams.QT, "/elevate",
+ GroupParams.GROUP_FIELD, "str_s",
+ GroupParams.GROUP, "true",
+ GroupParams.GROUP_TOTAL_COUNT, "true",
+ GroupParams.GROUP_LIMIT, "100",
+ CommonParams.FL, "id, score, [elevated]")
+ , "//*[@name='ngroups'][.='3']"
+ , "//*[@name='matches'][.='6']"
+
+ , groups +"/lst[1]//doc[1]/float[@name='id'][.='7.0']"
+ , groups +"/lst[1]//doc[1]/bool[@name='[elevated]'][.='true']"
+ , groups +"/lst[1]//doc[2]/float[@name='id'][.='77.0']"
+ , groups +"/lst[1]//doc[2]/bool[@name='[elevated]'][.='false']"
+
+ , groups +"/lst[2]//doc[1]/float[@name='id'][.='6.0']"
+ , groups +"/lst[2]//doc[1]/bool[@name='[elevated]'][.='false']"
+ , groups +"/lst[2]//doc[2]/float[@name='id'][.='66.0']"
+ , groups +"/lst[2]//doc[2]/bool[@name='[elevated]'][.='false']"
+
+ , groups +"/lst[3]//doc[1]/float[@name='id'][.='2.0']"
+ , groups +"/lst[3]//doc[1]/bool[@name='[elevated]'][.='false']"
+ , groups +"/lst[3]//doc[2]/float[@name='id'][.='22.0']"
+ , groups +"/lst[3]//doc[2]/bool[@name='[elevated]'][.='false']"
+ );
+
+ assertQ("non-elevated because sorted group query",
+ req(CommonParams.Q, "AAAA",
+ CommonParams.QT, "/elevate",
+ CommonParams.SORT, "id asc",
+ GroupParams.GROUP_FIELD, "str_s",
+ GroupParams.GROUP, "true",
+ GroupParams.GROUP_TOTAL_COUNT, "true",
+ GroupParams.GROUP_LIMIT, "100",
+ CommonParams.FL, "id, score, [elevated]")
+ , "//*[@name='ngroups'][.='3']"
+ , "//*[@name='matches'][.='6']"
+
+ , groups +"/lst[1]//doc[1]/float[@name='id'][.='2.0']"
+ , groups +"/lst[1]//doc[1]/bool[@name='[elevated]'][.='false']"
+ , groups +"/lst[1]//doc[2]/float[@name='id'][.='22.0']"
+ , groups +"/lst[1]//doc[2]/bool[@name='[elevated]'][.='false']"
+
+ , groups +"/lst[2]//doc[1]/float[@name='id'][.='6.0']"
+ , groups +"/lst[2]//doc[1]/bool[@name='[elevated]'][.='false']"
+ , groups +"/lst[2]//doc[2]/float[@name='id'][.='66.0']"
+ , groups +"/lst[2]//doc[2]/bool[@name='[elevated]'][.='false']"
+
+ , groups +"/lst[3]//doc[1]/float[@name='id'][.='7.0']"
+ , groups +"/lst[3]//doc[1]/bool[@name='[elevated]'][.='true']"
+ , groups +"/lst[3]//doc[2]/float[@name='id'][.='77.0']"
+ , groups +"/lst[3]//doc[2]/bool[@name='[elevated]'][.='false']"
+ );
+
+ assertQ("force-elevated sorted group query",
+ req(CommonParams.Q, "AAAA",
+ CommonParams.QT, "/elevate",
+ CommonParams.SORT, "id asc",
+ QueryElevationParams.FORCE_ELEVATION, "true",
+ GroupParams.GROUP_FIELD, "str_s",
+ GroupParams.GROUP, "true",
+ GroupParams.GROUP_TOTAL_COUNT, "true",
+ GroupParams.GROUP_LIMIT, "100",
+ CommonParams.FL, "id, score, [elevated]")
+ , "//*[@name='ngroups'][.='3']"
+ , "//*[@name='matches'][.='6']"
+
+ , groups +"/lst[1]//doc[1]/float[@name='id'][.='7.0']"
+ , groups +"/lst[1]//doc[1]/bool[@name='[elevated]'][.='true']"
+ , groups +"/lst[1]//doc[2]/float[@name='id'][.='77.0']"
+ , groups +"/lst[1]//doc[2]/bool[@name='[elevated]'][.='false']"
+
+ , groups +"/lst[2]//doc[1]/float[@name='id'][.='2.0']"
+ , groups +"/lst[2]//doc[1]/bool[@name='[elevated]'][.='false']"
+ , groups +"/lst[2]//doc[2]/float[@name='id'][.='22.0']"
+ , groups +"/lst[2]//doc[2]/bool[@name='[elevated]'][.='false']"
+
+ , groups +"/lst[3]//doc[1]/float[@name='id'][.='6.0']"
+ , groups +"/lst[3]//doc[1]/bool[@name='[elevated]'][.='false']"
+ , groups +"/lst[3]//doc[2]/float[@name='id'][.='66.0']"
+ , groups +"/lst[3]//doc[2]/bool[@name='[elevated]'][.='false']"
+ );
+
+
+ assertQ("non-elevated because of sort within group query",
+ req(CommonParams.Q, "AAAA",
+ CommonParams.QT, "/elevate",
+ CommonParams.SORT, "id asc",
+ GroupParams.GROUP_SORT, "id desc",
+ GroupParams.GROUP_FIELD, "str_s",
+ GroupParams.GROUP, "true",
+ GroupParams.GROUP_TOTAL_COUNT, "true",
+ GroupParams.GROUP_LIMIT, "100",
+ CommonParams.FL, "id, score, [elevated]")
+ , "//*[@name='ngroups'][.='3']"
+ , "//*[@name='matches'][.='6']"
+
+ , groups +"/lst[1]//doc[1]/float[@name='id'][.='22.0']"
+ , groups +"/lst[1]//doc[1]/bool[@name='[elevated]'][.='false']"
+ , groups +"/lst[1]//doc[2]/float[@name='id'][.='2.0']"
+ , groups +"/lst[1]//doc[2]/bool[@name='[elevated]'][.='false']"
+
+ , groups +"/lst[2]//doc[1]/float[@name='id'][.='66.0']"
+ , groups +"/lst[2]//doc[1]/bool[@name='[elevated]'][.='false']"
+ , groups +"/lst[2]//doc[2]/float[@name='id'][.='6.0']"
+ , groups +"/lst[2]//doc[2]/bool[@name='[elevated]'][.='false']"
+
+ , groups +"/lst[3]//doc[1]/float[@name='id'][.='77.0']"
+ , groups +"/lst[3]//doc[1]/bool[@name='[elevated]'][.='false']"
+ , groups +"/lst[3]//doc[2]/float[@name='id'][.='7.0']"
+ , groups +"/lst[3]//doc[2]/bool[@name='[elevated]'][.='true']"
+ );
+
+
+ assertQ("force elevated sort within sorted group query",
+ req(CommonParams.Q, "AAAA",
+ CommonParams.QT, "/elevate",
+ CommonParams.SORT, "id asc",
+ GroupParams.GROUP_SORT, "id desc",
+ QueryElevationParams.FORCE_ELEVATION, "true",
+ GroupParams.GROUP_FIELD, "str_s",
+ GroupParams.GROUP, "true",
+ GroupParams.GROUP_TOTAL_COUNT, "true",
+ GroupParams.GROUP_LIMIT, "100",
+ CommonParams.FL, "id, score, [elevated]")
+ , "//*[@name='ngroups'][.='3']"
+ , "//*[@name='matches'][.='6']"
+
+ , groups +"/lst[1]//doc[1]/float[@name='id'][.='7.0']"
+ , groups +"/lst[1]//doc[1]/bool[@name='[elevated]'][.='true']"
+ , groups +"/lst[1]//doc[2]/float[@name='id'][.='77.0']"
+ , groups +"/lst[1]//doc[2]/bool[@name='[elevated]'][.='false']"
+
+ , groups +"/lst[2]//doc[1]/float[@name='id'][.='22.0']"
+ , groups +"/lst[2]//doc[1]/bool[@name='[elevated]'][.='false']"
+ , groups +"/lst[2]//doc[2]/float[@name='id'][.='2.0']"
+ , groups +"/lst[2]//doc[2]/bool[@name='[elevated]'][.='false']"
+
+ , groups +"/lst[3]//doc[1]/float[@name='id'][.='66.0']"
+ , groups +"/lst[3]//doc[1]/bool[@name='[elevated]'][.='false']"
+ , groups +"/lst[3]//doc[2]/float[@name='id'][.='6.0']"
+ , groups +"/lst[3]//doc[2]/bool[@name='[elevated]'][.='false']"
+ );
+
+ } finally {
+ delete();
+ }
+ }
+
+ @Test
public void testTrieFieldType() throws Exception {
try {
init("schema.xml");