You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2012/08/13 15:53:27 UTC
svn commit: r1372423 [44/45] - in /lucene/dev/branches/LUCENE-2878: ./
dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/libraries/
dev-tools/maven/ dev-tools/maven/lucene/
dev-tools/maven/lucene/analysis/common/
dev-tools/maven/lucene/analysis/icu/ d...
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java Mon Aug 13 13:52:46 2012
@@ -36,13 +36,14 @@ import javax.xml.parsers.ParserConfigura
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.common.cloud.CloudState;
+import org.apache.solr.common.cloud.ClusterState;
import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.handler.component.HttpShardHandlerFactory;
+import org.apache.solr.util.DefaultSolrThreadFactory;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.NodeExistsException;
@@ -153,7 +154,7 @@ public class OverseerTest extends SolrTe
}
private String getShardId(final String coreName) {
- Map<String,Slice> slices = zkStateReader.getCloudState().getSlices(
+ Map<String,Slice> slices = zkStateReader.getClusterState().getSlices(
collection);
if (slices != null) {
for (Slice slice : slices.values()) {
@@ -298,7 +299,7 @@ public class OverseerTest extends SolrTe
for (int i = 0; i < nodeCount; i++) {
- nodeExecutors[i] = Executors.newFixedThreadPool(1);
+ nodeExecutors[i] = Executors.newFixedThreadPool(1, new DefaultSolrThreadFactory("testShardAssignment"));
}
final String[] ids = new String[coreCount];
@@ -340,8 +341,8 @@ public class OverseerTest extends SolrTe
// make sure all cores have been assigned a id in cloudstate
for (int i = 0; i < 40; i++) {
- reader.updateCloudState(true);
- CloudState state = reader.getCloudState();
+ reader.updateClusterState(true);
+ ClusterState state = reader.getClusterState();
Map<String,Slice> slices = state.getSlices("collection1");
int count = 0;
for (String name : slices.keySet()) {
@@ -419,8 +420,8 @@ public class OverseerTest extends SolrTe
private void waitForCollections(ZkStateReader stateReader, String... collections) throws InterruptedException, KeeperException {
int maxIterations = 100;
while (0 < maxIterations--) {
- stateReader.updateCloudState(true);
- final CloudState state = stateReader.getCloudState();
+ stateReader.updateClusterState(true);
+ final ClusterState state = stateReader.getClusterState();
Set<String> availableCollections = state.getCollections();
int availableCount = 0;
for(String requiredCollection: collections) {
@@ -431,7 +432,7 @@ public class OverseerTest extends SolrTe
Thread.sleep(50);
}
}
- log.warn("Timeout waiting for collections: " + Arrays.asList(collections) + " state:" + stateReader.getCloudState());
+ log.warn("Timeout waiting for collections: " + Arrays.asList(collections) + " state:" + stateReader.getClusterState());
}
@Test
@@ -472,8 +473,8 @@ public class OverseerTest extends SolrTe
waitForCollections(reader, "collection1");
- assertEquals(reader.getCloudState().toString(), ZkStateReader.RECOVERING,
- reader.getCloudState().getSlice("collection1", "shard1").getShards()
+ assertEquals(reader.getClusterState().toString(), ZkStateReader.RECOVERING,
+ reader.getClusterState().getSlice("collection1", "shard1").getShards()
.get("node1_core1").get(ZkStateReader.STATE_PROP));
//publish node state (active)
@@ -503,7 +504,7 @@ public class OverseerTest extends SolrTe
int maxIterations = 100;
String coreState = null;
while(maxIterations-->0) {
- Slice slice = reader.getCloudState().getSlice("collection1", "shard1");
+ Slice slice = reader.getClusterState().getSlice("collection1", "shard1");
if(slice!=null) {
coreState = slice.getShards().get("node1_core1").get(ZkStateReader.STATE_PROP);
if(coreState.equals(expectedState)) {
@@ -512,14 +513,14 @@ public class OverseerTest extends SolrTe
}
Thread.sleep(50);
}
- fail("Illegal state, was:" + coreState + " expected:" + expectedState + "cloudState:" + reader.getCloudState());
+ fail("Illegal state, was:" + coreState + " expected:" + expectedState + "clusterState:" + reader.getClusterState());
}
private void verifyShardLeader(ZkStateReader reader, String collection, String shard, String expectedCore) throws InterruptedException, KeeperException {
int maxIterations = 100;
while(maxIterations-->0) {
- reader.updateCloudState(true); // poll state
- ZkNodeProps props = reader.getCloudState().getLeader(collection, shard);
+ reader.updateClusterState(true); // poll state
+ ZkNodeProps props = reader.getClusterState().getLeader(collection, shard);
if(props!=null) {
if(expectedCore.equals(props.get(ZkStateReader.CORE_NAME_PROP))) {
return;
@@ -528,7 +529,7 @@ public class OverseerTest extends SolrTe
Thread.sleep(100);
}
- assertEquals("Unexpected shard leader coll:" + collection + " shard:" + shard, expectedCore, (reader.getCloudState().getLeader(collection, shard)!=null)?reader.getCloudState().getLeader(collection, shard).get(ZkStateReader.CORE_NAME_PROP):null);
+ assertEquals("Unexpected shard leader coll:" + collection + " shard:" + shard, expectedCore, (reader.getClusterState().getLeader(collection, shard)!=null)?reader.getClusterState().getLeader(collection, shard).get(ZkStateReader.CORE_NAME_PROP):null);
}
@Test
@@ -562,35 +563,35 @@ public class OverseerTest extends SolrTe
waitForCollections(reader, "collection1");
verifyStatus(reader, ZkStateReader.RECOVERING);
- int version = getCloudStateVersion(controllerClient);
+ int version = getClusterStateVersion(controllerClient);
mockController.publishState("core1", ZkStateReader.ACTIVE, 1);
- while(version == getCloudStateVersion(controllerClient));
+ while(version == getClusterStateVersion(controllerClient));
verifyStatus(reader, ZkStateReader.ACTIVE);
- version = getCloudStateVersion(controllerClient);
+ version = getClusterStateVersion(controllerClient);
overseerClient.close();
Thread.sleep(1000); //wait for overseer to get killed
mockController.publishState("core1", ZkStateReader.RECOVERING, 1);
- version = getCloudStateVersion(controllerClient);
+ version = getClusterStateVersion(controllerClient);
overseerClient = electNewOverseer(server.getZkAddress());
- while(version == getCloudStateVersion(controllerClient));
+ while(version == getClusterStateVersion(controllerClient));
verifyStatus(reader, ZkStateReader.RECOVERING);
- assertEquals("Live nodes count does not match", 1, reader.getCloudState()
+ assertEquals("Live nodes count does not match", 1, reader.getClusterState()
.getLiveNodes().size());
- assertEquals("Shard count does not match", 1, reader.getCloudState()
+ assertEquals("Shard count does not match", 1, reader.getClusterState()
.getSlice("collection1", "shard1").getShards().size());
- version = getCloudStateVersion(controllerClient);
+ version = getClusterStateVersion(controllerClient);
mockController.publishState("core1", null,1);
- while(version == getCloudStateVersion(controllerClient));
+ while(version == getClusterStateVersion(controllerClient));
Thread.sleep(500);
- assertFalse("collection1 should be gone after publishing the null state", reader.getCloudState().getCollections().contains("collection1"));
+ assertFalse("collection1 should be gone after publishing the null state", reader.getClusterState().getCollections().contains("collection1"));
} finally {
close(mockController);
@@ -740,15 +741,15 @@ public class OverseerTest extends SolrTe
mockController.close();
- int version = getCloudStateVersion(controllerClient);
+ int version = getClusterStateVersion(controllerClient);
mockController = new MockZKController(server.getZkAddress(), "node1", "collection1");
mockController.publishState("core1", ZkStateReader.RECOVERING, 1);
- while (version == getCloudStateVersion(controllerClient));
+ while (version == getClusterStateVersion(controllerClient));
- reader.updateCloudState(true);
- CloudState state = reader.getCloudState();
+ reader.updateClusterState(true);
+ ClusterState state = reader.getClusterState();
int numFound = 0;
for (Map<String,Slice> collection : state.getCollectionStates().values()) {
@@ -758,7 +759,7 @@ public class OverseerTest extends SolrTe
}
}
}
- assertEquals("Shard was found in more than 1 times in CloudState", 1,
+ assertEquals("Shard was found more than once in ClusterState", 1,
numFound);
} finally {
close(overseerClient);
@@ -800,7 +801,7 @@ public class OverseerTest extends SolrTe
waitForCollections(reader, "collection1");
- assertEquals("Slicecount does not match", 12, reader.getCloudState().getSlices("collection1").size());
+ assertEquals("Slicecount does not match", 12, reader.getClusterState().getSlices("collection1").size());
} finally {
close(overseerClient);
@@ -872,12 +873,12 @@ public class OverseerTest extends SolrTe
queue.offer(ZkStateReader.toJSON(m));
for(int i=0;i<100;i++) {
- Slice s = reader.getCloudState().getSlice("collection1", "s1");
+ Slice s = reader.getClusterState().getSlice("collection1", "s1");
if(s!=null && s.getShards().size()==3) break;
Thread.sleep(100);
}
- assertNotNull(reader.getCloudState().getSlice("collection1", "s1"));
- assertEquals(3, reader.getCloudState().getSlice("collection1", "s1").getShards().size());
+ assertNotNull(reader.getClusterState().getSlice("collection1", "s1"));
+ assertEquals(3, reader.getClusterState().getSlice("collection1", "s1").getShards().size());
} finally {
close(overseerClient);
close(zkClient);
@@ -898,18 +899,22 @@ public class OverseerTest extends SolrTe
}
}
- private int getCloudStateVersion(SolrZkClient controllerClient)
+ private int getClusterStateVersion(SolrZkClient controllerClient)
throws KeeperException, InterruptedException {
return controllerClient.exists(ZkStateReader.CLUSTER_STATE, null, false).getVersion();
}
private SolrZkClient electNewOverseer(String address) throws InterruptedException,
- TimeoutException, IOException, KeeperException, ParserConfigurationException, SAXException {
- SolrZkClient zkClient = new SolrZkClient(address, TIMEOUT);
+ TimeoutException, IOException,
+ KeeperException, ParserConfigurationException, SAXException {
+ SolrZkClient zkClient = new SolrZkClient(address, TIMEOUT);
ZkStateReader reader = new ZkStateReader(zkClient);
LeaderElector overseerElector = new LeaderElector(zkClient);
- ElectionContext ec = new OverseerElectionContext(new HttpShardHandlerFactory().getShardHandler(), "/admin/cores", address.replaceAll("/", "_"), reader);
+ // TODO: close Overseer
+ Overseer overseer = new Overseer(
+ new HttpShardHandlerFactory().getShardHandler(), "/admin/cores", reader);
+ ElectionContext ec = new OverseerElectionContext(zkClient, overseer, address.replaceAll("/", "_"));
overseerElector.setup(ec);
overseerElector.joinElection(ec);
return zkClient;
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java Mon Aug 13 13:52:46 2012
@@ -24,28 +24,17 @@ import org.apache.solr.client.solrj.Solr
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.common.SolrInputDocument;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Slow
-public class RecoveryZkTest extends FullSolrCloudTest {
+public class RecoveryZkTest extends AbstractFullDistribZkTestBase {
//private static final String DISTRIB_UPDATE_CHAIN = "distrib-update-chain";
private static Logger log = LoggerFactory.getLogger(RecoveryZkTest.class);
private StopableIndexingThread indexThread;
private StopableIndexingThread indexThread2;
- @BeforeClass
- public static void beforeSuperClass() {
- }
-
- @AfterClass
- public static void afterSuperClass() {
-
- }
-
public RecoveryZkTest() {
super();
sliceCount = 1;
@@ -71,7 +60,7 @@ public class RecoveryZkTest extends Full
Thread.sleep(atLeast(2000));
// bring shard replica down
- JettySolrRunner replica = chaosMonkey.stopShard("shard1", 1);
+ JettySolrRunner replica = chaosMonkey.stopShard("shard1", 1).jetty;
// wait a moment - lets allow some docs to be indexed so replication time is non 0
@@ -99,8 +88,8 @@ public class RecoveryZkTest extends Full
checkShardConsistency("shard1", false);
SolrQuery query = new SolrQuery("*:*");
query.setParam("distrib", "false");
- long client1Docs = shardToClient.get("shard1").get(0).query(query).getResults().getNumFound();
- long client2Docs = shardToClient.get("shard1").get(1).query(query).getResults().getNumFound();
+ long client1Docs = shardToJetty.get("shard1").get(0).client.solrClient.query(query).getResults().getNumFound();
+ long client2Docs = shardToJetty.get("shard1").get(1).client.solrClient.query(query).getResults().getNumFound();
assertTrue(client1Docs > 0);
assertEquals(client1Docs, client2Docs);
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/TestMultiCoreConfBootstrap.java Mon Aug 13 13:52:46 2012
@@ -37,7 +37,6 @@ public class TestMultiCoreConfBootstrap
protected CoreContainer cores = null;
private String home;
-
protected static ZkTestServer zkServer;
protected static String zkDir;
@@ -48,7 +47,8 @@ public class TestMultiCoreConfBootstrap
@AfterClass
public static void afterClass() {
-
+ zkServer = null;
+ zkDir = null;
}
@Override
@@ -100,7 +100,6 @@ public class TestMultiCoreConfBootstrap
super.tearDown();
}
-
@Test
public void testMultiCoreConfBootstrap() throws Exception {
System.setProperty("bootstrap_conf", "true");
@@ -112,6 +111,7 @@ public class TestMultiCoreConfBootstrap
assertTrue(zkclient.exists("/configs/core1/schema.xml", true));
assertTrue(zkclient.exists("/configs/core0/solrconfig.xml", true));
assertTrue(zkclient.exists("/configs/core1/schema.xml", true));
+
+ zkclient.close();
}
-
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java Mon Aug 13 13:52:46 2012
@@ -25,13 +25,13 @@ import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.util.ExternalPaths;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Slow
// TODO: This test would be a lot faster if it used a solrhome with fewer config
// files - there are a lot of them to upload
public class ZkCLITest extends SolrTestCaseJ4 {
@@ -65,32 +65,38 @@ public class ZkCLITest extends SolrTestC
zkDir = dataDir.getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
+ log.info("ZooKeeper dataDir:" + zkDir);
zkServer = new ZkTestServer(zkDir);
zkServer.run();
System.setProperty("zkHost", zkServer.getZkAddress());
- AbstractZkTestCase.buildZooKeeper(zkServer.getZkHost(),
- zkServer.getZkAddress(), "solrconfig.xml", "schema.xml");
+ SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(), AbstractZkTestCase.TIMEOUT);
+ zkClient.makePath("/solr", false, true);
+ zkClient.close();
- zkClient = new SolrZkClient(zkServer.getZkAddress(),
+ this.zkClient = new SolrZkClient(zkServer.getZkAddress(),
AbstractZkTestCase.TIMEOUT);
log.info("####SETUP_END " + getTestName());
-
}
@Test
public void testBootstrap() throws Exception {
// test bootstrap_conf
String[] args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd",
- "bootstrap", "-solrhome", TEST_HOME()};
+ "bootstrap", "-solrhome", ExternalPaths.EXAMPLE_HOME};
ZkCLI.main(args);
-
-
- assertTrue(zkClient.exists(ZkStateReader.COLLECTIONS_ZKNODE + "/collection1", true));
assertTrue(zkClient.exists(ZkController.CONFIGS_ZKNODE + "/collection1", true));
+ args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd",
+ "bootstrap", "-solrhome", ExternalPaths.EXAMPLE_MULTICORE_HOME};
+ ZkCLI.main(args);
+
+ assertTrue(zkClient.exists(ZkController.CONFIGS_ZKNODE + "/core0", true));
+ assertTrue(zkClient.exists(ZkController.CONFIGS_ZKNODE + "/core1", true));
+
+
}
@Test
@@ -114,14 +120,14 @@ public class ZkCLITest extends SolrTestC
"-cmd",
"upconfig",
"-confdir",
- TEST_HOME() + File.separator + "collection1"
+ ExternalPaths.EXAMPLE_HOME + File.separator + "collection1"
+ File.separator + "conf", "-confname", confsetname};
ZkCLI.main(args);
assertTrue(zkClient.exists(ZkController.CONFIGS_ZKNODE + "/" + confsetname, true));
// print help
- ZkCLI.main(new String[0]);
+ // ZkCLI.main(new String[0]);
// test linkconfig
args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd",
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java Mon Aug 13 13:52:46 2012
@@ -202,7 +202,7 @@ public class ZkControllerTest extends So
assertNotNull(reader.getLeaderUrl("collection1", "shard1", 15000));
- assertEquals("Shard(s) missing from cloudstate", 2, zkController.getZkStateReader().getCloudState().getSlice("collection1", "shard1").getShards().size());
+ assertEquals("Shard(s) missing from cloudstate", 2, zkController.getZkStateReader().getClusterState().getSlice("collection1", "shard1").getShards().size());
// unregister current leader
final ZkNodeProps shard1LeaderProps = reader.getLeaderProps(
@@ -224,10 +224,10 @@ public class ZkControllerTest extends So
reader.getLeaderUrl("collection1", "shard1", 15000));
for(int i=0;i<30;i++) {
- if(zkController.getZkStateReader().getCloudState().getSlice("collection1", "shard1").getShards().size()==1) break;
+ if(zkController.getZkStateReader().getClusterState().getSlice("collection1", "shard1").getShards().size()==1) break;
Thread.sleep(500);
}
- assertEquals("shard was not unregistered", 1, zkController.getZkStateReader().getCloudState().getSlice("collection1", "shard1").getShards().size());
+ assertEquals("shard was not unregistered", 1, zkController.getZkStateReader().getClusterState().getSlice("collection1", "shard1").getShards().size());
} finally {
System.clearProperty("solrcloud.skip.autorecovery");
System.clearProperty(ZkStateReader.NUM_SHARDS_PROP);
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java Mon Aug 13 13:52:46 2012
@@ -20,8 +20,8 @@ package org.apache.solr.core;
import junit.framework.Assert;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.solr.analysis.KeywordTokenizerFactory;
-import org.apache.solr.analysis.NGramFilterFactory;
+import org.apache.lucene.analysis.core.KeywordTokenizerFactory;
+import org.apache.lucene.analysis.ngram.NGramFilterFactory;
import org.apache.solr.common.SolrException;
import org.apache.solr.handler.admin.LukeRequestHandler;
import org.apache.solr.handler.component.FacetComponent;
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java Mon Aug 13 13:52:46 2012
@@ -24,6 +24,8 @@ import org.apache.solr.handler.component
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.util.DefaultSolrThreadFactory;
import org.apache.solr.util.plugin.SolrCoreAware;
import org.junit.Test;
@@ -49,6 +51,8 @@ public class SolrCoreTest extends SolrTe
public void testRemoveThenAddDefaultCore() throws Exception {
final CoreContainer cores = h.getCoreContainer();
SolrCore core = cores.getCore("");
+
+ IndexSchema schema = h.getCore().getSchema();
assertEquals(COLLECTION1, cores.getDefaultCoreName());
cores.remove("");
@@ -57,7 +61,7 @@ public class SolrCoreTest extends SolrTe
SolrCore newCore = new SolrCore(COLLECTION1, dataDir + File.separator
- + "datadir2", new SolrConfig("solr/collection1", "solrconfig.xml", null), h.getCore().getSchema(),
+ + "datadir2", new SolrConfig("solr/collection1", "solrconfig.xml", null), schema,
new CoreDescriptor(cores, COLLECTION1, "solr/collection1"));
cores.register(newCore, false);
@@ -160,7 +164,7 @@ public class SolrCoreTest extends SolrTe
final int LOOP = 100;
final int MT = 16;
- ExecutorService service = Executors.newFixedThreadPool(MT);
+ ExecutorService service = Executors.newFixedThreadPool(MT, new DefaultSolrThreadFactory("refCountMT"));
List<Callable<Integer>> callees = new ArrayList<Callable<Integer>>(MT);
final CoreContainer cores = h.getCoreContainer();
for (int i = 0; i < MT; ++i) {
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java Mon Aug 13 13:52:46 2012
@@ -57,6 +57,7 @@ import org.apache.solr.common.util.Simpl
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
/**
* Test for ReplicationHandler
@@ -116,6 +117,9 @@ public class TestReplicationHandler exte
slaveJetty.stop();
master.tearDown();
slave.tearDown();
+ masterJetty = slaveJetty = null;
+ master = slave = null;
+ masterClient = slaveClient = null;
}
private static JettySolrRunner createJetty(SolrInstance instance) throws Exception {
@@ -884,7 +888,7 @@ public class TestReplicationHandler exte
break;
}
Thread.sleep(200);
- if(waitCnt == 10) {
+ if(waitCnt == 20) {
fail("Backup success not detected:" + checkStatus.response);
}
waitCnt++;
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java Mon Aug 13 13:52:46 2012
@@ -20,16 +20,20 @@ package org.apache.solr.handler.admin;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.admin.CoreAdminHandler;
+import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CoreAdminParams;
+import org.apache.solr.common.util.NamedList;
import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.SolrTestCaseJ4;
+import java.util.Map;
import java.io.File;
import java.io.IOException;
import javax.xml.xpath.XPathExpressionException;
import org.apache.commons.io.FileUtils;
-import org.apache.solr.SolrTestCaseJ4;
+
import org.junit.BeforeClass;
import org.junit.Test;
import org.xml.sax.SAXException;
@@ -94,7 +98,49 @@ public class CoreAdminHandlerTest extend
,"/solr/cores/core[@name='props']/property[@name='hoss' and @value='man']"
,"/solr/cores/core[@name='props']/property[@name='foo' and @value='baz']"
);
-
+
+ // attempt to create a bogus core and confirm failure
+ try {
+ resp = new SolrQueryResponse();
+ admin.handleRequestBody
+ (req(CoreAdminParams.ACTION,
+ CoreAdminParams.CoreAdminAction.CREATE.toString(),
+ CoreAdminParams.NAME, "bogus_dir_core",
+ CoreAdminParams.INSTANCE_DIR, "dir_does_not_exist_127896"),
+ resp);
+ fail("bogus collection created ok");
+ } catch (SolrException e) {
+ // :NOOP:
+ // :TODO: CoreAdminHandler's exception messages are terrible, otherwise we could asert something useful here
+ }
+
+ // check specificly for status of the failed core name
+ resp = new SolrQueryResponse();
+ admin.handleRequestBody
+ (req(CoreAdminParams.ACTION,
+ CoreAdminParams.CoreAdminAction.STATUS.toString(),
+ CoreAdminParams.CORE, "bogus_dir_core"),
+ resp);
+ Map<String,Exception> failures =
+ (Map<String,Exception>) resp.getValues().get("initFailures");
+ assertNotNull("core failures is null", failures);
+
+ NamedList<Object> status =
+ (NamedList<Object>)resp.getValues().get("status");
+ assertNotNull("core status is null", status);
+
+ assertEquals("wrong number of core failures", 1, failures.size());
+ Exception fail = failures.get("bogus_dir_core");
+ assertNotNull("null failure for test core", fail);
+ assertTrue("init failure doesn't mention problem: " + fail.getMessage(),
+ 0 < fail.getMessage().indexOf("dir_does_not_exist"));
+
+ assertEquals("bogus_dir_core status isn't empty",
+ 0, ((NamedList)status.get("bogus_dir_core")).size());
+
+
+ // :TODO: because of SOLR-3665 we can't ask for status from all cores
+
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/DummyCustomParamSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/DummyCustomParamSpellChecker.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/DummyCustomParamSpellChecker.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/DummyCustomParamSpellChecker.java Mon Aug 13 13:52:46 2012
@@ -8,8 +8,10 @@ import org.apache.solr.spelling.Spelling
import org.apache.solr.spelling.SpellingResult;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -40,7 +42,7 @@ public class DummyCustomParamSpellChecke
}
@Override
- public void build(SolrCore core, SolrIndexSearcher searcher) {
+ public void build(SolrCore core, SolrIndexSearcher searcher) throws IOException {
}
@@ -49,12 +51,20 @@ public class DummyCustomParamSpellChecke
SpellingResult result = new SpellingResult();
//just spit back out the results
+
+ // sort the keys to make ordering predictable
Iterator<String> iterator = options.customParams.getParameterNamesIterator();
+ List<String> lst = new ArrayList<String>();
+ while (iterator.hasNext()) {
+ lst.add(iterator.next());
+ }
+ Collections.sort(lst);
+
int i = 0;
- while (iterator.hasNext()){
- String name = iterator.next();
+ for (String name : lst) {
String value = options.customParams.get(name);
- result.add(new Token(name, i++, i++), Collections.singletonList(value));
+ result.add(new Token(name, i, i+1), Collections.singletonList(value));
+ i += 2;
}
return result;
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java Mon Aug 13 13:52:46 2012
@@ -20,6 +20,7 @@ package org.apache.solr.handler.componen
import java.io.File;
import java.util.*;
+import org.apache.lucene.util.Constants;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CommonParams;
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java Mon Aug 13 13:52:46 2012
@@ -27,6 +27,10 @@ import java.text.SimpleDateFormat;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.StatsParams;
+
+import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.schema.SchemaField;
+
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
@@ -340,4 +344,25 @@ public class StatsComponentTest extends
assertQ("test string statistics values", req,
"//null[@name='active_dt'][.='']");
}
+
+ public void testStatsFacetMultivaluedErrorHandling() throws Exception {
+ SolrCore core = h.getCore();
+ SchemaField foo_ss = core.getSchema().getField("foo_ss");
+
+ assertU(adoc("id", "1", "active_i", "1", "foo_ss", "aa" ));
+ assertU(adoc("id", "2", "active_i", "1", "foo_ss", "bb" ));
+ assertU(adoc("id", "3", "active_i", "5", "foo_ss", "aa" ));
+ assertU(commit());
+
+ assertTrue("schema no longer satisfies test requirements: foo_ss no longer multivalued", foo_ss.multiValued());
+ assertTrue("schema no longer satisfies test requirements: foo_ss's fieldtype no longer single valued", ! foo_ss.getType().isMultiValued());
+
+ assertQEx("no failure trying to get stats facet on foo_ss",
+ req("q", "*:*",
+ "stats", "true",
+ "stats.field", "active_i",
+ "stats.facet", "foo_ss"),
+ 400);
+
+ }
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java Mon Aug 13 13:52:46 2012
@@ -121,7 +121,7 @@ public class TermVectorComponentTest ext
@Test
public void testBasics() throws Exception {
assertJQ(req("json.nl","map", "qt",tv, "q", "id:0", TermVectorComponent.COMPONENT_NAME, "true", TermVectorParams.TF, "true")
- ,"/termVectors=={'doc-0':{'uniqueKey':'0'," +
+ ,"/termVectors=={'0':{'uniqueKey':'0'," +
" 'test_basictv':{'anoth':{'tf':1},'titl':{'tf':2}}," +
" 'test_offtv':{'anoth':{'tf':1},'titl':{'tf':2}}," +
" 'test_posofftv':{'anoth':{'tf':1},'titl':{'tf':2}}," +
@@ -136,7 +136,7 @@ public class TermVectorComponentTest ext
"tv.fl", "test_basictv,test_offtv",
TermVectorComponent.COMPONENT_NAME, "true",
TermVectorParams.TF, "true")
- ,"/termVectors=={'doc-0':{'uniqueKey':'0'," +
+ ,"/termVectors=={'0':{'uniqueKey':'0'," +
" 'test_basictv':{'anoth':{'tf':1},'titl':{'tf':2}}," +
" 'test_offtv':{'anoth':{'tf':1},'titl':{'tf':2}}}," +
" 'uniqueKeyFieldName':'id'}"
@@ -150,7 +150,7 @@ public class TermVectorComponentTest ext
"tv.fl","test_offtv",
TermVectorComponent.COMPONENT_NAME, "true",
TermVectorParams.TF, "true")
- ,"/termVectors=={'doc-0':{'uniqueKey':'0'," +
+ ,"/termVectors=={'0':{'uniqueKey':'0'," +
" 'test_basictv':{'anoth':{'tf':1},'titl':{'tf':2}}," +
" 'test_offtv':{'anoth':{'tf':1},'titl':{'tf':2}}}," +
" 'uniqueKeyFieldName':'id'}"
@@ -162,7 +162,7 @@ public class TermVectorComponentTest ext
"fl", "*,score",
TermVectorComponent.COMPONENT_NAME, "true",
TermVectorParams.TF, "true")
- ,"/termVectors=={'doc-0':{'uniqueKey':'0'," +
+ ,"/termVectors=={'0':{'uniqueKey':'0'," +
" 'test_basictv':{'anoth':{'tf':1},'titl':{'tf':2}}," +
" 'test_offtv':{'anoth':{'tf':1},'titl':{'tf':2}}," +
" 'test_posofftv':{'anoth':{'tf':1},'titl':{'tf':2}}," +
@@ -176,7 +176,7 @@ public class TermVectorComponentTest ext
"fl", "score,test_basictv,[docid],test_postv,val:sum(3,4)",
TermVectorComponent.COMPONENT_NAME, "true",
TermVectorParams.TF, "true")
- ,"/termVectors=={'doc-0':{'uniqueKey':'0'," +
+ ,"/termVectors=={'0':{'uniqueKey':'0'," +
" 'test_basictv':{'anoth':{'tf':1},'titl':{'tf':2}}," +
" 'test_postv':{'anoth':{'tf':1},'titl':{'tf':2}}}," +
" 'uniqueKeyFieldName':'id'}"
@@ -189,7 +189,7 @@ public class TermVectorComponentTest ext
"fl", "[docid],test_postv,val:sum(3,4)",
TermVectorComponent.COMPONENT_NAME, "true",
TermVectorParams.TF, "true")
- ,"/termVectors=={'doc-0':{'uniqueKey':'0'," +
+ ,"/termVectors=={'0':{'uniqueKey':'0'," +
" 'test_basictv':{'anoth':{'tf':1},'titl':{'tf':2}}," +
" 'test_postv':{'anoth':{'tf':1},'titl':{'tf':2}}}," +
" 'uniqueKeyFieldName':'id'}"
@@ -201,12 +201,12 @@ public class TermVectorComponentTest ext
public void testOptions() throws Exception {
assertJQ(req("json.nl","map", "qt",tv, "q", "id:0", TermVectorComponent.COMPONENT_NAME, "true"
, TermVectorParams.TF, "true", TermVectorParams.DF, "true", TermVectorParams.OFFSETS, "true", TermVectorParams.POSITIONS, "true", TermVectorParams.TF_IDF, "true")
- ,"/termVectors/doc-0/test_posofftv/anoth=={'tf':1, 'offsets':{'start':20, 'end':27}, 'positions':{'position':1}, 'df':2, 'tf-idf':0.5}"
+ ,"/termVectors/0/test_posofftv/anoth=={'tf':1, 'offsets':{'start':20, 'end':27}, 'positions':{'position':1}, 'df':2, 'tf-idf':0.5}"
);
assertJQ(req("json.nl","map", "qt",tv, "q", "id:0", TermVectorComponent.COMPONENT_NAME, "true"
, TermVectorParams.ALL, "true")
- ,"/termVectors/doc-0/test_posofftv/anoth=={'tf':1, 'offsets':{'start':20, 'end':27}, 'positions':{'position':1}, 'df':2, 'tf-idf':0.5}"
+ ,"/termVectors/0/test_posofftv/anoth=={'tf':1, 'offsets':{'start':20, 'end':27}, 'positions':{'position':1}, 'df':2, 'tf-idf':0.5}"
);
// test each combination at random
@@ -217,7 +217,7 @@ public class TermVectorComponentTest ext
{ TermVectorParams.POSITIONS, "'positions':{'position':1}" },
{ TermVectorParams.DF, "'df':2" },
{ TermVectorParams.TF_IDF, "'tf-idf':0.5" } };
- StringBuilder expected = new StringBuilder("/termVectors/doc-0/test_posofftv/anoth=={");
+ StringBuilder expected = new StringBuilder("/termVectors/0/test_posofftv/anoth=={");
boolean first = true;
for (int i = 0; i < options.length; i++) {
final boolean use = random().nextBoolean();
@@ -248,59 +248,13 @@ public class TermVectorComponentTest ext
,"f.test_basictv." + TermVectorParams.TF, "false"
,"f.test_basictv." + TermVectorParams.TF_IDF, "false"
)
- ,"/termVectors/doc-0/test_basictv=={'anoth':{},'titl':{}}"
- ,"/termVectors/doc-0/test_postv/anoth=={'tf':1, 'positions':{'position':1}, 'df':2, 'tf-idf':0.5}"
- ,"/termVectors/doc-0/test_offtv/anoth=={'tf':1, 'df':2, 'tf-idf':0.5}"
+ ,"/termVectors/0/test_basictv=={'anoth':{},'titl':{}}"
+ ,"/termVectors/0/test_postv/anoth=={'tf':1, 'positions':{'position':1}, 'df':2, 'tf-idf':0.5}"
+ ,"/termVectors/0/test_offtv/anoth=={'tf':1, 'df':2, 'tf-idf':0.5}"
,"/termVectors/warnings=={ 'noTermVectors':['test_notv'], 'noPositions':['test_basictv', 'test_offtv'], 'noOffsets':['test_basictv', 'test_postv']}"
);
}
-
- // TODO: this test is really fragile since it pokes around in solr's guts and makes many assumptions.
- // it should be rewritten to use the real distributed interface
- @Test
- public void testDistributed() throws Exception {
- SolrCore core = h.getCore();
- TermVectorComponent tvComp = (TermVectorComponent) core.getSearchComponent("tvComponent");
- assertTrue("tvComp is null and it shouldn't be", tvComp != null);
- ModifiableSolrParams params = new ModifiableSolrParams();
- params.add(CommonParams.Q, "id:0");
- params.add(CommonParams.QT, "tvrh");
- params.add(TermVectorParams.TF, "true");
- params.add(TermVectorParams.DF, "true");
- params.add(TermVectorParams.OFFSETS, "true");
- params.add(TermVectorParams.POSITIONS, "true");
- params.add(TermVectorComponent.COMPONENT_NAME, "true");
-
- ResponseBuilder rb = new ResponseBuilder(new LocalSolrQueryRequest(core, params), new SolrQueryResponse(), (List)Arrays.asList(tvComp));
- rb.stage = ResponseBuilder.STAGE_GET_FIELDS;
- rb.shards = new String[]{"localhost:0", "localhost:1", "localhost:2", "localhost:3"};//we don't actually call these, since we are going to invoke distributedProcess directly
- rb.resultIds = new HashMap<Object, ShardDoc>();
-
- rb.outgoing = new ArrayList<ShardRequest>();
- //one doc per shard, but make sure there are enough docs to go around
- for (int i = 0; i < rb.shards.length; i++){
- ShardDoc doc = new ShardDoc();
- doc.id = i; //must be a valid doc that was indexed.
- doc.score = 1 - (i / (float)rb.shards.length);
- doc.positionInResponse = i;
- doc.shard = rb.shards[i];
- doc.orderInShard = 0;
- rb.resultIds.put(doc.id, doc);
- }
-
- int result = tvComp.distributedProcess(rb);
- assertTrue(result + " does not equal: " + ResponseBuilder.STAGE_DONE, result == ResponseBuilder.STAGE_DONE);
- //one outgoing per shard
- assertTrue("rb.outgoing Size: " + rb.outgoing.size() + " is not: " + rb.shards.length, rb.outgoing.size() == rb.shards.length);
- for (ShardRequest request : rb.outgoing) {
- ModifiableSolrParams solrParams = request.params;
- log.info("Shard: " + Arrays.asList(request.shards) + " Params: " + solrParams);
- }
-
- rb.req.close();
- }
-
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java Mon Aug 13 13:52:46 2012
@@ -2004,4 +2004,61 @@ public class SimpleFacetsTest extends So
,"*[count(//lst[@name='facet_fields']/lst/int)=0]"
);
}
+
+ /**
+ * kind of an absurd tests because if there is an inifnite loop, it
+ * would ver finish -- but at least it ensures that <i>if</i> one of
+ * these requests return, they return an error
+ */
+ public void testRangeFacetInfiniteLoopDetection() {
+
+ for (String field : new String[] {"foo_f", "foo_sf",
+ "foo_d", "foo_sd",
+ "foo_i", "foo_si"}) {
+ assertQEx("no zero gap error: " + field,
+ req("q", "*:*",
+ "facet", "true",
+ "facet.range", field,
+ "facet.range.start", "23",
+ "facet.range.gap", "0",
+ "facet.range.end", "100"),
+ 400);
+ }
+ for (String field : new String[] {"foo_pdt", "foo_dt"}) {
+ for (String type : new String[] {"date", "range"}) {
+ assertQEx("no zero gap error for facet." + type + ": " + field,
+ req("q", "*:*",
+ "facet", "true",
+ "facet." + type, field,
+ "facet."+type+".start", "NOW",
+ "facet."+type+".gap", "+0DAYS",
+ "facet."+type+".end", "NOW+10DAY"),
+ 400);
+ }
+ }
+
+ for (String field : new String[] {"foo_f", "foo_sf"}) {
+ assertQEx("no float underflow error: " + field,
+ req("q", "*:*",
+ "facet", "true",
+ "facet.range", field,
+ "facet.range.start", "100000000000",
+ "facet.range.end", "100000086200",
+ "facet.range.gap", "2160"),
+ 400);
+ }
+
+ for (String field : new String[] {"foo_d", "foo_sd"}) {
+ assertQEx("no double underflow error: " + field,
+ req("q", "*:*",
+ "facet", "true",
+ "facet.range", field,
+ "facet.range.start", "9900000000000",
+ "facet.range.end", "9900000086200",
+ "facet.range.gap", "0.0003"),
+ 400);
+ }
+
+ }
+
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/schema/BadIndexSchemaTest.java Mon Aug 13 13:52:46 2012
@@ -49,6 +49,7 @@ public class BadIndexSchemaTest extends
public void testSevereErrorsForUnexpectedAnalyzer() throws Exception {
doTest("bad-schema-nontext-analyzer.xml", "StrField (bad_type)");
+ doTest("bad-schema-analyzer-class-and-nested.xml", "bad_type");
}
public void testBadExternalFileField() throws Exception {
@@ -61,6 +62,8 @@ public class BadIndexSchemaTest extends
"can not be the dest of a copyField");
doTest("bad-schema-uniquekey-uses-default.xml",
"can not be configured with a default value");
+ doTest("bad-schema-uniquekey-multivalued.xml",
+ "can not be configured to be multivalued");
}
public void testPerFieldtypeSimButNoSchemaSimFactory() throws Exception {
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/schema/MultiTermTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/schema/MultiTermTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/schema/MultiTermTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/schema/MultiTermTest.java Mon Aug 13 13:52:46 2012
@@ -18,6 +18,12 @@ package org.apache.solr.schema;
*/
import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.charfilter.MappingCharFilterFactory;
+import org.apache.lucene.analysis.core.KeywordTokenizerFactory;
+import org.apache.lucene.analysis.core.LowerCaseFilterFactory;
+import org.apache.lucene.analysis.core.WhitespaceTokenizerFactory;
+import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilterFactory;
+import org.apache.lucene.analysis.miscellaneous.TrimFilterFactory;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.analysis.*;
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java Mon Aug 13 13:52:46 2012
@@ -648,6 +648,11 @@ public class QueryEqualityTest extends S
"foo_i");
}
+ public void testTestFuncs() throws Exception {
+ assertFuncEquals("sleep(1,5)", "sleep(1,5)");
+ assertFuncEquals("threadid()", "threadid()");
+ }
+
/**
* this test does not assert anything itself, it simply toggles a static
* boolean informing an @AfterClass method to assert that every default
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRTGBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRTGBase.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRTGBase.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRTGBase.java Mon Aug 13 13:52:46 2012
@@ -134,7 +134,7 @@ public class TestRTGBase extends SolrTes
if (!termsEnum.seekExact(termBytes, false)) {
return -1;
}
- DocsEnum docs = termsEnum.docs(MultiFields.getLiveDocs(r), null, false);
+ DocsEnum docs = termsEnum.docs(MultiFields.getLiveDocs(r), null, 0);
int id = docs.nextDoc();
if (id != DocIdSetIterator.NO_MORE_DOCS) {
int next = docs.nextDoc();
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRecovery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRecovery.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRecovery.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRecovery.java Mon Aug 13 13:52:46 2012
@@ -559,7 +559,22 @@ public class TestRecovery extends SolrTe
assertTrue((ulog.getStartingOperation() & UpdateLog.FLAG_GAP) == 0);
+ ulog.bufferUpdates();
+ // simulate receiving no updates
+ ulog.applyBufferedUpdates();
+ updateJ(jsonAdd(sdoc("id","Q7", "_version_","117")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER)); // do another add to make sure flags are back to normal
+ req.close();
+ h.close();
+ createCore();
+
+ req = req();
+ uhandler = req.getCore().getUpdateHandler();
+ ulog = uhandler.getUpdateLog();
+
+ assertTrue((ulog.getStartingOperation() & UpdateLog.FLAG_GAP) == 0); // check flags on Q7
+
+ logReplayFinish.acquire();
assertEquals(UpdateLog.State.ACTIVE, ulog.getState()); // leave each test method in a good state
} finally {
DirectUpdateHandler2.commitOnClose = true;
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestReload.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestReload.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestReload.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestReload.java Mon Aug 13 13:52:46 2012
@@ -22,12 +22,11 @@ import org.junit.Ignore;
import java.util.Random;
-@Ignore
public class TestReload extends TestRTGBase {
@BeforeClass
public static void beforeClass() throws Exception {
- useFactory(null); // force FS directory
+ // useFactory(null); // force FS directory
initCore("solrconfig-tlog.xml","schema15.xml");
}
@@ -37,36 +36,48 @@ public class TestReload extends TestRTGB
assertU(commit());
long version = addAndGetVersion(sdoc("id","1") , null);
- // h.getCoreContainer().reload(h.getCore().getName());
+ assertU(commit("softCommit","true")); // should cause a RTG searcher to be opened
- assertU(commit("openSearcher","false")); // should cause a RTG searcher to be opened
+ assertJQ(req("qt","/get","id","1")
+ ,"=={'doc':{'id':'1','_version_':" + version + "}}"
+ );
+
+ h.reload();
- // should also use the RTG searcher (commit should have cleared the translog cache)
assertJQ(req("qt","/get","id","1")
,"=={'doc':{'id':'1','_version_':" + version + "}}"
);
assertU(commit("softCommit","true")); // open a normal (caching) NRT searcher
- h.getCoreContainer().reload(h.getCore().getName());
+ assertJQ(req("q","id:1")
+ ,"/response/numFound==1"
+ );
+
Random rand = random();
int iter = atLeast(20);
+
for (int i=0; i<iter; i++) {
if (rand.nextBoolean()) {
+ // System.out.println("!!! add");
version = addAndGetVersion(sdoc("id","1") , null);
}
if (rand.nextBoolean()) {
if (rand.nextBoolean()) {
+ // System.out.println("!!! flush");
assertU(commit("openSearcher","false")); // should cause a RTG searcher to be opened as well
} else {
- assertU(commit("softCommit", ""+rand.nextBoolean()));
+ boolean softCommit = rand.nextBoolean();
+ System.out.println("!!! softCommit" + softCommit);
+ // assertU(commit("softCommit", ""+softCommit));
}
}
if (rand.nextBoolean()) {
// RTG should always be able to see the last version
+ // System.out.println("!!! rtg");
assertJQ(req("qt","/get","id","1")
,"=={'doc':{'id':'1','_version_':" + version + "}}"
);
@@ -74,13 +85,16 @@ public class TestReload extends TestRTGB
if (rand.nextBoolean()) {
// a normal search should always find 1 doc
+ // System.out.println("!!! q");
assertJQ(req("q","id:1")
,"/response/numFound==1"
);
}
- // TODO: randomly do a reload
- // but the test currently fails without this!
+ if (rand.nextBoolean()) {
+ // System.out.println("!!! reload");
+ h.reload();
+ }
}
// test framework should ensure that all searchers opened have been closed.
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestSolrJ.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestSolrJ.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestSolrJ.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestSolrJ.java Mon Aug 13 13:52:46 2012
@@ -18,24 +18,149 @@
package org.apache.solr.search;
-import org.apache.lucene.util.OpenBitSet;
import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrServer;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
-import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
-import org.apache.solr.request.SolrQueryRequest;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import java.io.IOException;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
+import java.util.Random;
+
public class TestSolrJ extends SolrTestCaseJ4 {
- public void testSolrJ() {
+ public void testSolrJ() throws Exception {
+ // docs, producers, connections, sleep_time
+ // main(new String[] {"1000000","4", "1", "0"});
+
// doCommitPerf();
}
+ public static SolrServer server;
+ public static String idField = "id";
+ public static Exception ex;
+
+ public static void main(String[] args) throws Exception {
+ // String addr = "http://odin.local:80/solr";
+ // String addr = "http://odin.local:8983/solr";
+ String addr = "http://localhost:8983/solr";
+
+ int i = 0;
+ final int nDocs = Integer.parseInt(args[i++]);
+ final int nProducers = Integer.parseInt(args[i++]);
+ final int nConnections = Integer.parseInt(args[i++]);
+ final int maxSleep = Integer.parseInt(args[i++]);
+
+ ConcurrentUpdateSolrServer sserver = null;
+
+ // server = sserver = new ConcurrentUpdateSolrServer(addr,32,8);
+ server = sserver = new ConcurrentUpdateSolrServer(addr,64,nConnections);
+
+ server.deleteByQuery("*:*");
+ server.commit();
+
+ long start = System.currentTimeMillis();
+
+ final int docsPerThread = nDocs / nProducers;
+
+ Thread[] threads = new Thread[nProducers];
+
+ for (int threadNum = 0; threadNum<nProducers; threadNum++) {
+ final int base = threadNum * docsPerThread;
+
+ threads[threadNum] = new Thread("add-thread"+i) {
+ public void run(){
+ try {
+ indexDocs(base, docsPerThread, maxSleep);
+ } catch (Exception e) {
+ System.out.println("###############################CAUGHT EXCEPTION");
+ e.printStackTrace();
+ ex = e;
+ }
+ }
+ };
+ threads[threadNum].start();
+ }
+
+ // optional: wait for commit?
+
+ for (int threadNum = 0; threadNum<nProducers; threadNum++) {
+ threads[threadNum].join();
+ }
+
+ if (sserver != null) {
+ sserver.blockUntilFinished();
+ }
+
+ long end = System.currentTimeMillis();
+ System.out.println("time="+(end-start) + " throughput="+(nDocs*1000/(end-start)) + " Exception="+ex);
+
+ // should server threads be marked as daemon?
+ // need a server.close()!!!
+ }
+
+ public static SolrInputDocument getDocument(int docnum) {
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.setField(idField, docnum );
+ doc.setField("cat", Integer.toString(docnum&0x0f) );
+ doc.setField("name", "my name is " + Integer.toString(docnum&0xff) );
+ doc.setField("foo_t", "now is the time for all good men to come to the aid of their country" );
+ doc.setField("foo_i", Integer.toString(docnum&0x0f) );
+ doc.setField("foo_s", Integer.toString(docnum&0xff) );
+ doc.setField("foo_b", Boolean.toString( (docnum&0x01) == 1) );
+ doc.setField("parent_s", Integer.toString(docnum-1) );
+ doc.setField("price", Integer.toString(docnum >> 4));
+
+ int golden = (int)2654435761L;
+ int h = docnum * golden;
+ int n = (h & 0xff) + 1;
+ List lst = new ArrayList(n);
+ for (int i=0; i<n; i++) {
+ h = (h+i) * golden;
+ lst.add(h & 0xfff);
+ }
+
+ doc.setField("num_is", lst);
+ return doc;
+ }
+
+ public static void indexDocs(int base, int count, int maxSleep) throws IOException, SolrServerException {
+ Random r = new Random(base);
+
+ for (int i=base; i<count+base; i++) {
+ if ((i & 0xfffff) == 0) {
+ System.out.print("\n% " + new Date()+ "\t" + i + "\t");
+ System.out.flush();
+ }
+
+ if ((i & 0xffff) == 0) {
+ System.out.print(".");
+ System.out.flush();
+ }
+
+ SolrInputDocument doc = getDocument(i);
+ server.add(doc);
+
+ if (maxSleep > 0) {
+ int sleep = r.nextInt(maxSleep);
+ try {
+ Thread.sleep(sleep);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ }
+ }
+
+
public void doCommitPerf() throws Exception {
HttpSolrServer client = new HttpSolrServer("http://localhost:8983/solr");
@@ -55,4 +180,7 @@ public class TestSolrJ extends SolrTestC
System.out.println("TIME: " + (end-start));
}
+
+
+
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestValueSourceCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestValueSourceCache.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestValueSourceCache.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestValueSourceCache.java Mon Aug 13 13:52:46 2012
@@ -21,6 +21,7 @@ import org.apache.lucene.queryparser.cla
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryUtils;
import org.apache.solr.SolrTestCaseJ4;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -34,6 +35,11 @@ public class TestValueSourceCache extend
}
static QParser _func;
+
+ @AfterClass
+ public static void afterClass() throws Exception {
+ _func = null;
+ }
Query getQuery(String query) throws ParseException {
_func.setString(query);
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java Mon Aug 13 13:52:46 2012
@@ -21,6 +21,8 @@ import static org.easymock.EasyMock.crea
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
+import java.net.HttpURLConnection;
+import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
@@ -114,10 +116,13 @@ public class SolrRequestParserTest exten
String url = "http://www.apache.org/dist/lucene/solr/";
byte[] bytes = null;
try {
- URLConnection connection = new URL(url).openConnection();
+ URL u = new URL(url);
+ HttpURLConnection connection = (HttpURLConnection)u.openConnection();
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
connection.connect();
+ int code = connection.getResponseCode();
+ assumeTrue("wrong response code from server: " + code, 200 == code);
bytes = IOUtils.toByteArray( connection.getInputStream());
}
catch( Exception ex ) {
@@ -134,8 +139,13 @@ public class SolrRequestParserTest exten
List<ContentStream> streams = new ArrayList<ContentStream>();
SolrQueryRequest req = parser.buildRequestFrom( core, new MultiMapSolrParams( args ), streams );
assertEquals( 1, streams.size() );
- assertArrayEquals( bytes, IOUtils.toByteArray( streams.get(0).getStream() ) );
- req.close();
+ try {
+ assertArrayEquals( bytes, IOUtils.toByteArray( streams.get(0).getStream() ) );
+ } catch (SocketTimeoutException ex) {
+ assumeNoException("Problems retrieving from " + url + " to run the test.", ex);
+ } finally {
+ req.close();
+ }
}
@Test
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java Mon Aug 13 13:52:46 2012
@@ -24,13 +24,16 @@ import java.util.List;
import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.client.solrj.request.LukeRequest;
import org.apache.solr.common.SolrDocumentList;
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.ModifiableSolrParams;
+import org.apache.solr.common.util.NamedList;
import org.apache.solr.update.SolrCmdDistributor.Node;
import org.apache.solr.update.SolrCmdDistributor.Response;
import org.apache.solr.update.SolrCmdDistributor.StdNode;
@@ -40,7 +43,7 @@ public class SolrCmdDistributorTest exte
public SolrCmdDistributorTest() {
fixShardCount = true;
- shardCount = 1;
+ shardCount = 4;
stress = 0;
}
@@ -80,9 +83,9 @@ public class SolrCmdDistributorTest exte
@Override
public void doTest() throws Exception {
- //del("*:*");
+ del("*:*");
- SolrCmdDistributor cmdDistrib = new SolrCmdDistributor();
+ SolrCmdDistributor cmdDistrib = new SolrCmdDistributor(8);
ModifiableSolrParams params = new ModifiableSolrParams();
List<Node> nodes = new ArrayList<Node>();
@@ -116,7 +119,7 @@ public class SolrCmdDistributorTest exte
nodes.add(new StdNode(new ZkCoreNodeProps(nodeProps)));
// add another 2 docs to control and 3 to client
- cmdDistrib = new SolrCmdDistributor();
+ cmdDistrib = new SolrCmdDistributor(8);
cmd.solrDoc = sdoc("id", 2);
cmdDistrib.distribAdd(cmd, nodes, params);
@@ -149,7 +152,7 @@ public class SolrCmdDistributorTest exte
DeleteUpdateCommand dcmd = new DeleteUpdateCommand(null);
dcmd.id = "2";
- cmdDistrib = new SolrCmdDistributor();
+ cmdDistrib = new SolrCmdDistributor(8);
cmdDistrib.distribDelete(dcmd, nodes, params);
cmdDistrib.distribCommit(ccmd, nodes, params);
@@ -159,6 +162,7 @@ public class SolrCmdDistributorTest exte
assertEquals(response.errors.toString(), 0, response.errors.size());
+
results = controlClient.query(new SolrQuery("*:*")).getResults();
numFound = results.getNumFound();
assertEquals(results.toString(), 2, numFound);
@@ -166,5 +170,48 @@ public class SolrCmdDistributorTest exte
numFound = client.query(new SolrQuery("*:*")).getResults()
.getNumFound();
assertEquals(results.toString(), 2, numFound);
+
+ // debug stuff
+ for (SolrServer c : clients) {
+ c.optimize();
+ // distrib optimize is not working right yet, so call it on each client
+ //System.out.println(clients.get(0).request(new LukeRequest()));
+ }
+
+ int id = 5;
+
+ cmdDistrib = new SolrCmdDistributor(8);
+
+ nodes.clear();
+ int cnt = atLeast(200);
+ for (int i = 0; i < cnt; i++) {
+ nodes.clear();
+ for (SolrServer c : clients) {
+ if (random().nextBoolean()) {
+ continue;
+ }
+ HttpSolrServer httpClient = (HttpSolrServer) c;
+ nodeProps = new ZkNodeProps(ZkStateReader.BASE_URL_PROP,
+ httpClient.getBaseURL(), ZkStateReader.CORE_NAME_PROP, "");
+ nodes.add(new StdNode(new ZkCoreNodeProps(nodeProps)));
+
+ }
+
+ cmd.solrDoc = sdoc("id", id++);
+ cmdDistrib.distribAdd(cmd, nodes, params);
+ }
+
+ cmdDistrib.finish();
+
+ cmdDistrib.distribCommit(ccmd, nodes, params);
+
+ for (SolrServer c : clients) {
+ NamedList<Object> resp = c.request(new LukeRequest());
+ System.out.println(resp);
+ assertEquals("SOLR-3428: We only did adds - there should be no deletes",
+ ((NamedList<Object>) resp.get("index")).get("numDocs"),
+ ((NamedList<Object>) resp.get("index")).get("maxDoc"));
+ }
+
}
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/ScriptEngineTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/ScriptEngineTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/ScriptEngineTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/ScriptEngineTest.java Mon Aug 13 13:52:46 2012
@@ -25,6 +25,9 @@ import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.StringReader;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+
/**
* Sanity tests basic functionality of {@link ScriptEngineManager} and
* {@link ScriptEngine} w/o excercising any Lucene specific code.
@@ -33,6 +36,12 @@ public class ScriptEngineTest extends Lu
private ScriptEngineManager manager;
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ Assume.assumeNotNull((new ScriptEngineManager()).getEngineByExtension("js"));
+ Assume.assumeNotNull((new ScriptEngineManager()).getEngineByName("JavaScript"));
+ }
+
@Override
public void setUp() throws Exception {
super.setUp();
@@ -83,13 +92,17 @@ public class ScriptEngineTest extends Lu
assertEquals(3, result.intValue());
}
-// public void testJRuby() throws ScriptException, NoSuchMethodException { // Simply adding jruby.jar to Solr's lib/ directory gets this test passing
-// ScriptEngine engine = manager.getEngineByName("jruby");
-// assertNotNull(engine);
-// engine.eval("def add(a,b); a + b; end");
-// Long result = (Long) ((Invocable)engine).invokeFunction("add", 1, 2);
-// assertNotNull(result);
-// assertEquals(3, result.intValue());
-// }
+ public void testJRuby() throws ScriptException, NoSuchMethodException {
+ // Simply adding jruby.jar to Solr's lib/ directory gets this test passing
+ ScriptEngine engine = manager.getEngineByName("jruby");
+
+ Assume.assumeNotNull(engine);
+
+ assertNotNull(engine);
+ engine.eval("def add(a,b); a + b; end");
+ Long result = (Long) ((Invocable)engine).invokeFunction("add", 1, 2);
+ assertNotNull(result);
+ assertEquals(3, result.intValue());
+ }
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactoryTest.java?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactoryTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactoryTest.java Mon Aug 13 13:52:46 2012
@@ -45,9 +45,8 @@ public class StatelessScriptUpdateProces
@BeforeClass
public static void beforeClass() throws Exception {
- initCore("solrconfig-script-updateprocessor.xml", "schema12.xml");
-
Assume.assumeNotNull((new ScriptEngineManager()).getEngineByExtension("js"));
+ initCore("solrconfig-script-updateprocessor.xml", "schema12.xml");
}
/**
Modified: lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/db/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/db/conf/schema.xml?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/db/conf/schema.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/db/conf/schema.xml Mon Aug 13 13:52:46 2012
@@ -259,7 +259,7 @@
best performance.
-->
- <field name="id" type="string" indexed="true" stored="true" required="true" />
+ <field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="sku" type="textTight" indexed="true" stored="true" omitNorms="true"/>
<field name="name" type="text" indexed="true" stored="true"/>
<field name="nameSort" type="string" indexed="true" stored="false"/>
Modified: lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/rss/conf/rss-data-config.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/rss/conf/rss-data-config.xml?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/rss/conf/rss-data-config.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/rss/conf/rss-data-config.xml Mon Aug 13 13:52:46 2012
@@ -17,7 +17,7 @@
<field column="description" xpath="/RDF/item/description" />
<field column="creator" xpath="/RDF/item/creator" />
<field column="item-subject" xpath="/RDF/item/subject" />
- <field column="date" xpath="/RDF/item/date" dateTimeFormat="yyyy-MM-dd'T'hh:mm:ss" />
+ <field column="date" xpath="/RDF/item/date" dateTimeFormat="yyyy-MM-dd'T'HH:mm:ss" />
<field column="slash-department" xpath="/RDF/item/department" />
<field column="slash-section" xpath="/RDF/item/section" />
<field column="slash-comments" xpath="/RDF/item/comments" />
Modified: lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/rss/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/rss/conf/schema.xml?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/rss/conf/schema.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/rss/conf/schema.xml Mon Aug 13 13:52:46 2012
@@ -291,7 +291,7 @@
<field name="subject" type="text" indexed="true" stored="true" />
<field name="title" type="text" indexed="true" stored="true" />
- <field name="link" type="string" indexed="true" stored="true" />
+ <field name="link" type="string" indexed="true" stored="true" multiValued="false" />
<field name="description" type="html" indexed="true" stored="true" />
<field name="creator" type="string" indexed="false" stored="true" />
<field name="item-subject" type="string" indexed="true" stored="false" />
Modified: lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/solr/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/solr/conf/schema.xml?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/solr/conf/schema.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/solr/conf/schema.xml Mon Aug 13 13:52:46 2012
@@ -259,7 +259,7 @@
best performance.
-->
- <field name="id" type="string" indexed="true" stored="true" required="true" />
+ <field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="sku" type="textTight" indexed="true" stored="true" omitNorms="true"/>
<field name="name" type="text" indexed="true" stored="true"/>
<field name="nameSort" type="string" indexed="true" stored="false"/>
Modified: lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/schema.xml?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/schema.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/schema.xml Mon Aug 13 13:52:46 2012
@@ -91,7 +91,7 @@
trailing underscores (e.g. _version_) are reserved.
-->
- <field name="id" type="string" indexed="true" stored="true" required="true" />
+ <field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="sku" type="text_en_splitting_tight" indexed="true" stored="true" omitNorms="true"/>
<field name="name" type="text_general" indexed="true" stored="true"/>
<field name="manu" type="text_general" indexed="true" stored="true" omitNorms="true"/>
@@ -109,7 +109,10 @@
<!-- Common metadata fields, named specifically to match up with
SolrCell metadata when parsing rich documents such as Word, PDF.
Some fields are multiValued only because Tika currently may return
- multiple values for them.
+ multiple values for them. Some metadata is parsed from the documents,
+ but there are some which come from the client context:
+ "content_type": From the HTTP headers of incoming stream
+ "resourcename": From SolrCell request param resource.name
-->
<field name="title" type="text_general" indexed="true" stored="true" multiValued="true"/>
<field name="subject" type="text_general" indexed="true" stored="true"/>
@@ -118,10 +121,18 @@
<field name="author" type="text_general" indexed="true" stored="true"/>
<field name="keywords" type="text_general" indexed="true" stored="true"/>
<field name="category" type="text_general" indexed="true" stored="true"/>
+ <field name="resourcename" type="text_general" indexed="true" stored="true"/>
+ <field name="url" type="text_general" indexed="true" stored="true"/>
<field name="content_type" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="last_modified" type="date" indexed="true" stored="true"/>
<field name="links" type="string" indexed="true" stored="true" multiValued="true"/>
+ <!-- Main body of document extracted by SolrCell.
+ NOTE: This field is not indexed by default, since it is also copied to "text"
+ using copyField below. This is to save space. Use this field for returning and
+ highlighting document content. Use the "text" field to search the content. -->
+ <field name="content" type="text_general" indexed="false" stored="true" multiValued="true"/>
+
<!-- catchall field, containing all other searchable text fields (implemented
via copyField further on in this schema -->
@@ -137,7 +148,6 @@
<field name="payloads" type="payloads" indexed="true" stored="true"/>
-
<field name="_version_" type="long" indexed="true" stored="true"/>
<!-- Uncommenting the following will create a "timestamp" field using
@@ -233,6 +243,19 @@
<!-- Copy the price into a currency enabled field (default USD) -->
<copyField source="price" dest="price_c"/>
+
+ <!-- Text fields from SolrCell to search by default in our catch-all field -->
+ <copyField source="title" dest="text"/>
+ <copyField source="author" dest="text"/>
+ <copyField source="description" dest="text"/>
+ <copyField source="keywords" dest="text"/>
+ <copyField source="content" dest="text"/>
+ <copyField source="content_type" dest="text"/>
+ <copyField source="resourcename" dest="text"/>
+ <copyField source="url" dest="text"/>
+
+ <!-- Create a string version of author for faceting -->
+ <copyField source="author" dest="author_s"/>
<!-- Above, multiple source fields are copied to the [text] field.
Another way to map multiple source fields to the same
@@ -607,12 +630,30 @@
</analyzer>
</fieldType>
- <fieldType name="text_path" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
- <tokenizer class="solr.PathHierarchyTokenizerFactory"/>
+ <!--
+ Example of using PathHierarchyTokenizerFactory at index time, so
+ queries for paths match documents at that path, or in descendent paths
+ -->
+ <fieldType name="descendent_path" class="solr.TextField">
+ <analyzer type="index">
+ <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
+ </analyzer>
+ <analyzer type="query">
+ <tokenizer class="solr.KeywordTokenizerFactory" />
+ </analyzer>
+ </fieldType>
+ <!--
+ Example of using PathHierarchyTokenizerFactory at query time, so
+ queries for paths match documents at that path, or in ancestor paths
+ -->
+ <fieldType name="ancestor_path" class="solr.TextField">
+ <analyzer type="index">
+ <tokenizer class="solr.KeywordTokenizerFactory" />
+ </analyzer>
+ <analyzer type="query">
+ <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
</analyzer>
</fieldType>
-
<!-- since fields of this type are by default not stored or indexed,
any data added to them will be ignored outright. -->
@@ -1041,6 +1082,7 @@
<filter class="solr.SnowballPorterFilterFactory" language="Turkish"/>
</analyzer>
</fieldType>
+
</types>
<!-- Similarity is the scoring routine for each document vs. a query.
Modified: lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/solrconfig.xml?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/solrconfig.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/solrconfig.xml Mon Aug 13 13:52:46 2012
@@ -821,6 +821,8 @@
<requestHandler name="/get" class="solr.RealTimeGetHandler">
<lst name="defaults">
<str name="omitHeader">true</str>
+ <str name="wt">json</str>
+ <str name="indent">true</str>
</lst>
</requestHandler>
@@ -848,7 +850,9 @@
<str name="defType">edismax</str>
<str name="qf">
text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
+ title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0
</str>
+ <str name="df">text</str>
<str name="mm">100%</str>
<str name="q.alt">*:*</str>
<str name="rows">10</str>
@@ -856,14 +860,17 @@
<str name="mlt.qf">
text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
+ title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0
</str>
- <str name="mlt.fl">text,features,name,sku,id,manu,cat</str>
+ <str name="mlt.fl">text,features,name,sku,id,manu,cat,title,description,keywords,author,resourcename</str>
<int name="mlt.count">3</int>
<!-- Faceting defaults -->
<str name="facet">on</str>
<str name="facet.field">cat</str>
<str name="facet.field">manu_exact</str>
+ <str name="facet.field">content_type</str>
+ <str name="facet.field">author_s</str>
<str name="facet.query">ipod</str>
<str name="facet.query">GB</str>
<str name="facet.mincount">1</str>
@@ -886,9 +893,18 @@
<!-- Highlighting defaults -->
<str name="hl">on</str>
- <str name="hl.fl">text features name</str>
+ <str name="hl.fl">content features title name</str>
+ <str name="hl.encoder">html</str>
+ <str name="hl.simple.pre"><b></str>
+ <str name="hl.simple.post"></b></str>
+ <str name="f.title.hl.fragsize">0</str>
+ <str name="f.title.hl.alternateField">title</str>
<str name="f.name.hl.fragsize">0</str>
<str name="f.name.hl.alternateField">name</str>
+ <str name="f.content.hl.snippets">3</str>
+ <str name="f.content.hl.fragsize">200</str>
+ <str name="f.content.hl.alternateField">content</str>
+ <str name="f.content.hl.maxAlternateFieldLength">750</str>
<!-- Spell checking defaults -->
<str name="spellcheck">on</str>
@@ -949,9 +965,6 @@
startup="lazy"
class="solr.extraction.ExtractingRequestHandler" >
<lst name="defaults">
- <!-- All the main content goes into "text"... if you need to return
- the extracted text or do highlighting, use a stored field. -->
- <str name="fmap.content">text</str>
<str name="lowernames">true</str>
<str name="uprefix">ignored_</str>
@@ -1608,6 +1621,24 @@
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
-->
+
+ <!-- Script update processor
+
+ This example hooks in an update processor implemented using JavaScript.
+
+ See more about the script update processor at http://wiki.apache.org/solr/ScriptUpdateProcessor
+ -->
+ <!--
+ <updateRequestProcessorChain name="script">
+ <processor class="solr.StatelessScriptUpdateProcessorFactory">
+ <str name="script">update-script.js</str>
+ <lst name="params">
+ <str name="config_param">example config parameter</str>
+ </lst>
+ </processor>
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+ -->
<!-- Response Writers
Modified: lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/velocity/VM_global_library.vm
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/velocity/VM_global_library.vm?rev=1372423&r1=1372422&r2=1372423&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/velocity/VM_global_library.vm (original)
+++ lucene/dev/branches/LUCENE-2878/solr/example/solr/collection1/conf/velocity/VM_global_library.vm Mon Aug 13 13:52:46 2012
@@ -4,6 +4,7 @@
#macro(url_root)/solr#end
## TODO: s/url_for_solr/url_for_core/ and s/url_root/url_for_solr/
+#macro(core_name)$request.core.name#end
#macro(url_for_solr)#{url_root}#if($request.core.name != "")/$request.core.name#end#end
#macro(url_for_home)#url_for_solr/browse#end
@@ -132,10 +133,14 @@
#macro(field $f)
#if($response.response.highlighting.get($docId).get($f).get(0))
- $!response.response.highlighting.get($docId).get($f).get(0)
+ #set($pad = "")
+ #foreach($v in $response.response.highlighting.get($docId).get($f))
+$pad$v##
+ #set($pad = " ... ")
+ #end
#else
#foreach($v in $doc.getFieldValues($f))
- $v
+$v##
#end
#end
#end