You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2014/11/01 10:32:12 UTC
svn commit: r1635908 [7/7] - in /lucene/dev/branches/lucene6005: ./
dev-tools/ dev-tools/idea/.idea/libraries/ dev-tools/scripts/ lucene/
lucene/backward-codecs/
lucene/backward-codecs/src/test/org/apache/lucene/index/ lucene/codecs/
lucene/codecs/src/...
Modified: lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SolrCLI.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SolrCLI.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SolrCLI.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SolrCLI.java Sat Nov 1 09:32:06 2014
@@ -17,6 +17,9 @@ package org.apache.solr.util;
* limitations under the License.
*/
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.PrintStream;
import java.net.ConnectException;
import java.net.SocketException;
@@ -40,12 +43,19 @@ import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
import org.apache.http.NoHttpResponseException;
+import org.apache.http.StatusLine;
+import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
+import org.apache.http.client.HttpResponseException;
+import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.impl.client.BasicResponseHandler;
+import org.apache.http.util.EntityUtils;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
@@ -55,6 +65,7 @@ import org.apache.solr.client.solrj.impl
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.cloud.ZkController;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.cloud.ClusterState;
import org.apache.solr.common.cloud.Replica;
@@ -191,7 +202,9 @@ public class SolrCLI {
return new StatusTool();
else if ("api".equals(toolType))
return new ApiTool();
-
+ else if ("create_collection".equals(toolType))
+ return new CreateCollectionTool();
+
// If you add a built-in tool to this class, add it here to avoid
// classpath scanning
@@ -209,7 +222,8 @@ public class SolrCLI {
formatter.printHelp("healthcheck", getToolOptions(new HealthcheckTool()));
formatter.printHelp("status", getToolOptions(new StatusTool()));
formatter.printHelp("api", getToolOptions(new ApiTool()));
-
+ formatter.printHelp("create_collection", getToolOptions(new CreateCollectionTool()));
+
List<Class<Tool>> toolClasses = findToolClassesInPackage("org.apache.solr.util");
for (Class<Tool> next : toolClasses) {
Tool tool = next.newInstance();
@@ -416,6 +430,23 @@ public class SolrCLI {
return json;
}
+
+ private static class SolrResponseHandler implements ResponseHandler<Map<String,Object>> {
+ public Map<String,Object> handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
+ HttpEntity entity = response.getEntity();
+ if (entity != null) {
+ Object resp = ObjectBuilder.getVal(new JSONParser(EntityUtils.toString(entity)));
+ if (resp != null && resp instanceof Map) {
+ return (Map<String,Object>)resp;
+ } else {
+ throw new ClientProtocolException("Expected JSON object in response but received "+ resp);
+ }
+ } else {
+ StatusLine statusLine = response.getStatusLine();
+ throw new HttpResponseException(statusLine.getStatusCode(), statusLine.getReasonPhrase());
+ }
+ }
+ }
/**
* Utility function for sending HTTP GET request to Solr and then doing some
@@ -423,35 +454,21 @@ public class SolrCLI {
*/
@SuppressWarnings({"unchecked"})
public static Map<String,Object> getJson(HttpClient httpClient, String getUrl) throws Exception {
- Map<String,Object> json = null;
-
// ensure we're requesting JSON back from Solr
HttpGet httpGet = new HttpGet(new URIBuilder(getUrl).setParameter("wt", "json").build());
-
- //Will throw HttpResponseException if a non-ok response
- String content = httpClient.execute(httpGet, new BasicResponseHandler());
-
- Object resp = ObjectBuilder.getVal(new JSONParser(content));
- if (resp != null && resp instanceof Map) {
- json = (Map<String,Object>)resp;
- } else {
- throw new SolrServerException("Expected JSON object in response from "+
- getUrl+" but received "+ resp);
- }
-
- // lastly check the response JSON from Solr to see if it is an error
+ // make the request and get back a parsed JSON object
+ Map<String,Object> json = httpClient.execute(httpGet, new SolrResponseHandler());
+ // check the response JSON from Solr to see if it is an error
Long statusCode = asLong("/responseHeader/status", json);
-
if (statusCode == -1) {
throw new SolrServerException("Unable to determine outcome of GET request to: "+
getUrl+"! Response: "+json);
} else if (statusCode != 0) {
String errMsg = asString("/error/msg", json);
-
- errMsg = errMsg == null ? String.valueOf(json) : errMsg;
+ if (errMsg == null)
+ errMsg = String.valueOf(json);
throw new SolrServerException("Request to "+getUrl+" failed due to: "+errMsg);
}
-
return json;
}
@@ -566,40 +583,40 @@ public class SolrCLI {
String solrUrl = cli.getOptionValue("solr", DEFAULT_SOLR_URL);
if (!solrUrl.endsWith("/"))
solrUrl += "/";
-
+
int exitCode = 0;
String systemInfoUrl = solrUrl+"admin/info/system";
HttpClient httpClient = getHttpClient();
- try {
+ try {
// hit Solr to get system info
Map<String,Object> systemInfo = getJson(httpClient, systemInfoUrl, 2);
-
+
// convert raw JSON into user-friendly output
- Map<String,Object> status =
+ Map<String,Object> status =
reportStatus(solrUrl, systemInfo, httpClient);
-
+
// pretty-print the status to stdout
CharArr arr = new CharArr();
new JSONWriter(arr, 2).write(status);
System.out.println(arr.toString());
-
+
} catch (Exception exc) {
if (checkCommunicationError(exc)) {
// this is not actually an error from the tool as it's ok if Solr is not online.
System.err.println("Solr at "+solrUrl+" not online.");
} else {
System.err.print("Failed to get system information from "+solrUrl+" due to: ");
- exc.printStackTrace(System.err);
+ exc.printStackTrace(System.err);
exitCode = 1;
}
} finally {
- closeHttpClient(httpClient);
+ closeHttpClient(httpClient);
}
-
+
return exitCode;
- }
+ }
- protected Map<String,Object> reportStatus(String solrUrl, Map<String,Object> info, HttpClient httpClient)
+ public Map<String,Object> reportStatus(String solrUrl, Map<String,Object> info, HttpClient httpClient)
throws Exception
{
Map<String,Object> status = new LinkedHashMap<String,Object>();
@@ -614,26 +631,7 @@ public class SolrCLI {
// if this is a Solr in solrcloud mode, gather some basic cluster info
if ("solrcloud".equals(info.get("mode"))) {
-
- // TODO: Need a better way to get the zkHost from a running server
- // as it can be set from solr.xml vs. on the command-line
- String zkHost = null;
- List<String> args = asList("/jvm/jmx/commandLineArgs", info);
- if (args != null) {
- for (String arg : args) {
- if (arg.startsWith("-DzkHost=")) {
- zkHost = arg.substring("-DzkHost=".length());
- break;
- } else if (arg.startsWith("-DzkRun")) {
- URL serverUrl = new URL(solrUrl);
- String host = serverUrl.getHost();
- int port = serverUrl.getPort();
- zkHost = host+":"+(port+1000)+" (embedded)";
- break;
- }
- }
- }
-
+ String zkHost = (String)info.get("zkHost");
status.put("cloud", getCloudStatus(httpClient, solrUrl, zkHost));
}
@@ -703,6 +701,195 @@ public class SolrCLI {
}
} // end ApiTool class
+ /**
+ * Supports create_collection command in the bin/solr script.
+ */
+ public static class CreateCollectionTool implements Tool {
+
+ private static final String DEFAULT_CONFIG_SET = "data_driven_schema_configs";
+
+ @Override
+ public String getName() {
+ return "create_collection";
+ }
+
+ @SuppressWarnings("static-access")
+ @Override
+ public Option[] getOptions() {
+ return new Option[] {
+ OptionBuilder
+ .withArgName("HOST")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Address of the Zookeeper ensemble; defaults to: "+ZK_HOST)
+ .create("zkHost"),
+ OptionBuilder
+ .withArgName("HOST")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Base Solr URL, which can be used to determine the zkHost if that's not known")
+ .create("solrUrl"),
+ OptionBuilder
+ .withArgName("NAME")
+ .hasArg()
+ .isRequired(true)
+ .withDescription("Name of collection to create.")
+ .create("name"),
+ OptionBuilder
+ .withArgName("#")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Number of shards; default is 1")
+ .create("shards"),
+ OptionBuilder
+ .withArgName("#")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Number of copies of each document across the collection (replicas per shard); default is 1")
+ .create("replicationFactor"),
+ OptionBuilder
+ .withArgName("#")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Maximum number of shards per Solr node; default is determined based on the number of shards, replication factor, and live nodes.")
+ .create("maxShardsPerNode"),
+ OptionBuilder
+ .withArgName("NAME")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Name of the configuration for this collection; default is "+DEFAULT_CONFIG_SET)
+ .create("config"),
+ OptionBuilder
+ .withArgName("DIR")
+ .hasArg()
+ .isRequired(true)
+ .withDescription("Path to configsets directory on the local system.")
+ .create("configsetsDir")
+ };
+ }
+
+ public int runTool(CommandLine cli) throws Exception {
+
+ // quiet down the ZK logging for cli tools
+ LogManager.getLogger("org.apache.zookeeper").setLevel(Level.ERROR);
+ LogManager.getLogger("org.apache.solr.common.cloud").setLevel(Level.WARN);
+
+ String zkHost = cli.getOptionValue("zkHost");
+ if (zkHost == null) {
+ // find it using the localPort
+ String solrUrl = cli.getOptionValue("solrUrl");
+ if (solrUrl == null)
+ throw new IllegalStateException(
+ "Must provide either the -zkHost or -solrUrl parameters to use the create_collection command!");
+
+ if (!solrUrl.endsWith("/"))
+ solrUrl += "/";
+
+ String systemInfoUrl = solrUrl+"admin/info/system";
+ HttpClient httpClient = getHttpClient();
+ try {
+ // hit Solr to get system info
+ Map<String,Object> systemInfo = getJson(httpClient, systemInfoUrl, 2);
+
+ // convert raw JSON into user-friendly output
+ StatusTool statusTool = new StatusTool();
+ Map<String,Object> status = statusTool.reportStatus(solrUrl, systemInfo, httpClient);
+
+ Map<String,Object> cloud = (Map<String, Object>)status.get("cloud");
+ if (cloud == null)
+ throw new IllegalArgumentException("Solr server at "+solrUrl+" not running in SolrCloud mode!");
+
+ String zookeeper = (String) cloud.get("ZooKeeper");
+ if (zookeeper.endsWith("(embedded)")) {
+ zookeeper = zookeeper.substring(0,zookeeper.length()-"(embedded)".length());
+ }
+ zkHost = zookeeper;
+ } finally {
+ closeHttpClient(httpClient);
+ }
+ }
+
+ CloudSolrServer cloudSolrServer = null;
+ try {
+ cloudSolrServer = new CloudSolrServer(zkHost);
+ System.out.println("Connecting to ZooKeeper at "+zkHost);
+ cloudSolrServer.connect();
+ runCloudTool(cloudSolrServer, cli);
+ } finally {
+ if (cloudSolrServer != null) {
+ try {
+ cloudSolrServer.shutdown();
+ } catch (Exception ignore) {}
+ }
+ }
+
+ return 0;
+ }
+
+ protected void runCloudTool(CloudSolrServer cloudSolrServer, CommandLine cli) throws Exception {
+ Set<String> liveNodes = cloudSolrServer.getZkStateReader().getClusterState().getLiveNodes();
+ if (liveNodes.isEmpty())
+ throw new IllegalStateException("No live nodes found! Cannot create a collection until " +
+ "there is at least 1 live node in the cluster.");
+ String firstLiveNode = liveNodes.iterator().next();
+
+ // build a URL to create the collection
+ int numShards = optionAsInt(cli, "shards", 1);
+ int replicationFactor = optionAsInt(cli, "replicationFactor", 1);
+ int maxShardsPerNode = -1;
+
+ if (cli.hasOption("maxShardsPerNode")) {
+ maxShardsPerNode = Integer.parseInt(cli.getOptionValue("maxShardsPerNode"));
+ } else {
+ // need number of live nodes to determine maxShardsPerNode if it is not set
+ int numNodes = liveNodes.size();
+ maxShardsPerNode = ((numShards*replicationFactor)+numNodes-1)/numNodes;
+ }
+
+ String configSet = cli.getOptionValue("config", DEFAULT_CONFIG_SET);
+ // first, test to see if that config exists in ZK
+ if (!cloudSolrServer.getZkStateReader().getZkClient().exists("/configs/"+configSet, true)) {
+ File configsetsDir = new File(cli.getOptionValue("configsetsDir"));
+ if (!configsetsDir.isDirectory())
+ throw new FileNotFoundException(configsetsDir.getAbsolutePath()+" not found!");
+
+ // upload the configset if it exists
+ File configSetDir = new File(configsetsDir, configSet);
+ if (!configSetDir.isDirectory())
+ throw new FileNotFoundException("Specified config "+configSet+
+ " not found in "+configsetsDir.getAbsolutePath());
+
+ File confDir = new File(configSetDir,"conf");
+ System.out.println("Uploading "+confDir.getAbsolutePath()+
+ " for config "+configSet+" to ZooKeeper at "+cloudSolrServer.getZkHost());
+ ZkController.uploadConfigDir(cloudSolrServer.getZkStateReader().getZkClient(), confDir, configSet);
+ }
+
+ String baseUrl = cloudSolrServer.getZkStateReader().getBaseUrlForNodeName(firstLiveNode);
+ String collectionName = cli.getOptionValue("name");
+ String createCollectionUrl =
+ String.format(Locale.ROOT,
+ "%s/admin/collections?action=CREATE&name=%s&numShards=%d&replicationFactor=%d&maxShardsPerNode=%d&configSet=%s",
+ baseUrl,
+ collectionName,
+ numShards,
+ replicationFactor,
+ maxShardsPerNode,
+ configSet);
+
+ System.out.println("Creating new collection '"+collectionName+"' using command:\n\n"+createCollectionUrl+"\n");
+
+ Map<String,Object> json = getJson(createCollectionUrl);
+ CharArr arr = new CharArr();
+ new JSONWriter(arr, 2).write(json);
+ System.out.println(arr.toString());
+ }
+
+ protected int optionAsInt(CommandLine cli, String option, int defaultVal) {
+ return Integer.parseInt(cli.getOptionValue(option, String.valueOf(defaultVal)));
+ }
+ } // end CreateCollectionTool class
+
private static final long MS_IN_MIN = 60 * 1000L;
private static final long MS_IN_HOUR = MS_IN_MIN * 60L;
private static final long MS_IN_DAY = MS_IN_HOUR * 24L;
Modified: lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-sortingresponse.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-sortingresponse.xml?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-sortingresponse.xml (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-sortingresponse.xml Sat Nov 1 09:32:06 2014
@@ -34,6 +34,20 @@
<str name="distrib">false</str>
</lst>
+ <query>
+
+ <enableLazyFieldLoading>true</enableLazyFieldLoading>
+
+ <queryResultWindowSize>20</queryResultWindowSize>
+
+ <queryResultMaxDocsCached>200</queryResultMaxDocsCached>
+
+ <documentCache class="solr.LRUCache"
+ size="512"
+ initialSize="512"
+ autowarmCount="0"/>
+ </query>
+
<arr name="components">
<str>query</str>
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java Sat Nov 1 09:32:06 2014
@@ -1032,12 +1032,14 @@ public class CollectionsAPIDistributedZk
client = createCloudClient(null);
} else if (i == 1) {
client = createCloudClient(collectionName);
+ } else {
+ client = createCloudClient(null);
}
createCollection(collectionInfos, collectionName,
numShards, replicationFactor, maxShardsPerNode, client, null,
"conf1");
-
+
// remove collection
CollectionAdminRequest.Delete delete = new CollectionAdminRequest.Delete();
delete.setCollectionName(collectionName);
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestZkChroot.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestZkChroot.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestZkChroot.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/TestZkChroot.java Sat Nov 1 09:32:06 2014
@@ -19,6 +19,7 @@ package org.apache.solr.cloud;
import java.io.File;
+import org.apache.solr.SolrJettyTestBase;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZooKeeperException;
@@ -46,7 +47,7 @@ public class TestZkChroot extends SolrTe
zkDir = createTempDir("zkData").toFile().getAbsolutePath();
zkServer = new ZkTestServer(zkDir);
zkServer.run();
- home = ExternalPaths.EXAMPLE_HOME;
+ home = SolrJettyTestBase.legacyExampleCollection1SolrHome();
}
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java Sat Nov 1 09:32:06 2014
@@ -29,6 +29,7 @@ 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.SolrJettyTestBase;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.cloud.SolrZkClient;
@@ -75,14 +76,16 @@ public class ZkCLITest extends SolrTestC
public void setUp() throws Exception {
super.setUp();
log.info("####SETUP_START " + getTestName());
+
+ String exampleHome = SolrJettyTestBase.legacyExampleCollection1SolrHome();
boolean useNewSolrXml = random().nextBoolean();
File tmpDir = createTempDir().toFile();
if (useNewSolrXml) {
- solrHome = ExternalPaths.EXAMPLE_HOME;
+ solrHome = exampleHome;
} else {
File tmpSolrHome = new File(tmpDir, "tmp-solr-home");
- FileUtils.copyDirectory(new File(ExternalPaths.EXAMPLE_HOME), tmpSolrHome);
+ FileUtils.copyDirectory(new File(exampleHome), tmpSolrHome);
FileUtils.copyFile(getFile("old-solr-example/solr.xml"), new File(tmpSolrHome, "solr.xml"));
solrHome = tmpSolrHome.getAbsolutePath();
}
@@ -214,8 +217,7 @@ public class ZkCLITest extends SolrTestC
"-cmd",
"upconfig",
"-confdir",
- ExternalPaths.EXAMPLE_HOME + File.separator + "collection1"
- + File.separator + "conf", "-confname", confsetname};
+ ExternalPaths.TECHPRODUCTS_CONFIGSET, "-confname", confsetname};
ZkCLI.main(args);
assertTrue(zkClient.exists(ZkController.CONFIGS_ZKNODE + "/" + confsetname, true));
@@ -245,13 +247,12 @@ public class ZkCLITest extends SolrTestC
List<String> zkFiles = zkClient.getChildren(ZkController.CONFIGS_ZKNODE + "/" + confsetname, null, true);
assertEquals(files.length, zkFiles.size());
- File sourceConfDir = new File(ExternalPaths.EXAMPLE_HOME + File.separator + "collection1"
- + File.separator + "conf");
+ File sourceConfDir = new File(ExternalPaths.TECHPRODUCTS_CONFIGSET);
// filter out all directories starting with . (e.g. .svn)
Collection<File> sourceFiles = FileUtils.listFiles(sourceConfDir, TrueFileFilter.INSTANCE, new RegexFileFilter("[^\\.].*"));
for (File sourceFile :sourceFiles){
- int indexOfRelativePath = sourceFile.getAbsolutePath().lastIndexOf("collection1" + File.separator + "conf");
- String relativePathofFile = sourceFile.getAbsolutePath().substring(indexOfRelativePath + 17, sourceFile.getAbsolutePath().length());
+ int indexOfRelativePath = sourceFile.getAbsolutePath().lastIndexOf("sample_techproducts_configs" + File.separator + "conf");
+ String relativePathofFile = sourceFile.getAbsolutePath().substring(indexOfRelativePath + 33, sourceFile.getAbsolutePath().length());
File downloadedFile = new File(confDir,relativePathofFile);
assertTrue(downloadedFile.getAbsolutePath() + " does not exist source:" + sourceFile.getAbsolutePath(), downloadedFile.exists());
assertTrue("Content didn't change",FileUtils.contentEquals(sourceFile,downloadedFile));
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java Sat Nov 1 09:32:06 2014
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import org.apache.lucene.util.LuceneTestCase.Slow;
+import org.apache.solr.SolrJettyTestBase;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkNodeProps;
@@ -232,11 +233,13 @@ public class ZkControllerTest extends So
}
});
- zkController.uploadToZK(new File(ExternalPaths.EXAMPLE_HOME + "/collection1/conf"),
+ String solrHome = SolrJettyTestBase.legacyExampleCollection1SolrHome();
+
+ zkController.uploadToZK(new File(solrHome + "/collection1/conf"),
ZkController.CONFIGS_ZKNODE + "/config1");
// uploading again should overwrite, not error...
- zkController.uploadToZK(new File(ExternalPaths.EXAMPLE_HOME + "/collection1/conf"),
+ zkController.uploadToZK(new File(solrHome + "/collection1/conf"),
ZkController.CONFIGS_ZKNODE + "/config1");
if (DEBUG) {
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java Sat Nov 1 09:32:06 2014
@@ -43,7 +43,7 @@ public class ShowFileRequestHandlerTest
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
+ createJetty(legacyExampleCollection1SolrHome(), null, null);
}
public void test404ViaHttp() throws SolrServerException {
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/response/TestSortingResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/response/TestSortingResponseWriter.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/response/TestSortingResponseWriter.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/response/TestSortingResponseWriter.java Sat Nov 1 09:32:06 2014
@@ -140,5 +140,11 @@ public class TestSortingResponseWriter e
s = h.query(req("q", "id:(1 2 3)", "qt", "/export", "fl", "intdv", "sort", "doubledv desc"));
assertEquals(s, "{\"numFound\":3, \"docs\":[{\"intdv\":3},{\"intdv\":1},{\"intdv\":2}]}");
+ s = h.query(req("q", "id:100000", "qt", "/export", "fl", "intdv", "sort", "doubledv desc"));
+ assertEquals(s, "{\"numFound\":0, \"docs\":[]}");
+
+
+
+
}
}
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/schema/DocValuesMultiTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/schema/DocValuesMultiTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/schema/DocValuesMultiTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/schema/DocValuesMultiTest.java Sat Nov 1 09:32:06 2014
@@ -18,7 +18,7 @@ package org.apache.solr.schema;
*/
import org.apache.lucene.index.LeafReader;
-import org.apache.lucene.index.FieldInfo.DocValuesType;
+import org.apache.lucene.index.DocValuesType;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.SortedSetDocValues;
import org.apache.solr.SolrTestCaseJ4;
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java Sat Nov 1 09:32:06 2014
@@ -18,7 +18,7 @@ package org.apache.solr.schema;
*/
import org.apache.lucene.index.LeafReader;
-import org.apache.lucene.index.FieldInfo.DocValuesType;
+import org.apache.lucene.index.DocValuesType;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.solr.SolrTestCaseJ4;
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java Sat Nov 1 09:32:06 2014
@@ -19,6 +19,7 @@ package org.apache.solr.search;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryUtils;
import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrRequestInfo;
import org.apache.solr.response.SolrQueryResponse;
@@ -838,6 +839,19 @@ public class QueryEqualityTest extends S
}
}
+ public void testQueryMLT() throws Exception {
+ assertU(adoc("id", "1", "lowerfilt", "sample data"));
+ assertU(commit());
+ try {
+ assertQueryEquals("mlt", "{!mlt qf=lowerfilt}1",
+ "{!mlt qf=lowerfilt v=1}");
+ } finally {
+ delQ("*:*");
+ assertU(commit());
+ }
+ }
+
+
/**
* NOTE: defType is not only used to pick the parser, but also to record
* the parser being tested for coverage sanity checking
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/search/TestStressLucene.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/search/TestStressLucene.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/search/TestStressLucene.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/search/TestStressLucene.java Sat Nov 1 09:32:06 2014
@@ -22,7 +22,7 @@ import org.apache.lucene.document.Docume
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.index.DirectoryReader;
-import org.apache.lucene.index.FieldInfo;
+import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.StoredDocument;
@@ -86,7 +86,7 @@ public class TestStressLucene extends Te
idFt.setStored(true);
idFt.setOmitNorms(true);
idFt.setTokenized(false);
- idFt.setIndexOptions(FieldInfo.IndexOptions.DOCS_ONLY);
+ idFt.setIndexOptions(IndexOptions.DOCS);
final FieldType ft2 = new FieldType();
ft2.setStored(true);
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/update/AddBlockUpdateTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/update/AddBlockUpdateTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/update/AddBlockUpdateTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/update/AddBlockUpdateTest.java Sat Nov 1 09:32:06 2014
@@ -1,11 +1,31 @@
package org.apache.solr.update;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TermRangeFilter;
import org.apache.lucene.search.TopDocs;
-import org.apache.lucene.search.join.FixedBitSetCachingWrapperFilter;
+import org.apache.lucene.search.join.BitDocIdSetCachingWrapperFilter;
import org.apache.lucene.search.join.ScoreMode;
import org.apache.lucene.search.join.ToParentBlockJoinQuery;
import org.apache.solr.SolrTestCaseJ4;
@@ -27,34 +47,6 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.xml.sax.SAXException;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-
-
-
-
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with this
@@ -568,7 +560,7 @@ public class AddBlockUpdateTest extends
protected ToParentBlockJoinQuery join(final String childTerm) {
return new ToParentBlockJoinQuery(
- new TermQuery(new Term(child, childTerm)), new FixedBitSetCachingWrapperFilter(new TermRangeFilter(parent,
+ new TermQuery(new Term(child, childTerm)), new BitDocIdSetCachingWrapperFilter(new TermRangeFilter(parent,
null, null, false, false)), ScoreMode.None);
}
Modified: lucene/dev/branches/lucene6005/solr/example/README.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/example/README.txt?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/example/README.txt (original)
+++ lucene/dev/branches/lucene6005/solr/example/README.txt Sat Nov 1 09:32:06 2014
@@ -16,14 +16,25 @@
Solr example
------------
-This directory contains an instance of the Jetty Servlet container setup to
-run Solr using an example configuration.
+This directory contains Solr examples. Each example is contained in a
+separate directory. To run a specific example, do:
-To run this example:
+ bin/solr -e <EXAMPLE> where <EXAMPLE> is one of:
+
+ cloud : SolrCloud example
+ dih : Data Import Handler (rdbms, mail, rss, tika)
+ schemaless : Schema-less example (schema is inferred from data during indexing)
+ techproducts : Kitchen sink example providing comprehensive examples of Solr features
- java -jar start.jar
+For instance, if you want to run the Solr Data Import Handler example, do:
-in this example directory, and when Solr is started connect to
+ bin/solr -e dih
+
+To see all the options available when starting Solr:
+
+ bin/solr start -help
+
+After starting a Solr example, direct your Web browser to:
http://localhost:8983/solr/
@@ -46,16 +57,6 @@ For more information about this example
Notes About These Examples
--------------------------
-* SolrHome *
-
-By default, start.jar starts Solr in Jetty using the default Solr Home
-directory of "./solr/" (relative to the working directory of hte servlet
-container). To run other example configurations, you can specify the
-solr.solr.home system property when starting jetty...
-
- java -Dsolr.solr.home=multicore -jar start.jar
- java -Dsolr.solr.home=example-DIH/solr -jar start.jar
-
* References to Jar Files Outside This Directory *
Various example SolrHome dirs contained in this directory may use "<lib>"
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleBinaryTest.java Sat Nov 1 09:32:06 2014
@@ -35,7 +35,7 @@ import org.junit.BeforeClass;
public class SolrExampleBinaryTest extends SolrExampleTests {
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
+ createJetty(legacyExampleCollection1SolrHome(), null, null);
}
@Override
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleXMLTest.java Sat Nov 1 09:32:06 2014
@@ -32,7 +32,7 @@ import org.junit.BeforeClass;
public class SolrExampleXMLTest extends SolrExampleTests {
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
+ createJetty(legacyExampleCollection1SolrHome(), null, null);
}
@Override
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java Sat Nov 1 09:32:06 2014
@@ -33,6 +33,10 @@ import org.slf4j.LoggerFactory;
import java.io.ByteArrayInputStream;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.OutputStreamWriter;
+import java.util.Properties;
public class SolrSchemalessExampleTest extends SolrExampleTestsBase {
private static Logger log = LoggerFactory.getLogger(SolrSchemalessExampleTest.class);
@@ -42,8 +46,24 @@ public class SolrSchemalessExampleTest e
File tempSolrHome = createTempDir().toFile();
// Schemaless renames schema.xml -> schema.xml.bak, and creates + modifies conf/managed-schema,
// which violates the test security manager's rules, which disallow writes outside the build dir,
- // so we copy the example/example-schemaless/solr/ directory to a new temp dir where writes are allowed.
- FileUtils.copyDirectory(new File(ExternalPaths.EXAMPLE_SCHEMALESS_HOME), tempSolrHome);
+ // so we copy the example/example-schemaless/solr/ directory to a new temp dir where writes are allowed.
+ FileUtils.copyFileToDirectory(new File(ExternalPaths.SERVER_HOME, "solr.xml"), tempSolrHome);
+ File collection1Dir = new File(tempSolrHome, "collection1");
+ FileUtils.forceMkdir(collection1Dir);
+ FileUtils.copyDirectoryToDirectory(new File(ExternalPaths.SCHEMALESS_CONFIGSET), collection1Dir);
+ Properties props = new Properties();
+ props.setProperty("name","collection1");
+ OutputStreamWriter writer = null;
+ try {
+ writer = new OutputStreamWriter(FileUtils.openOutputStream(new File(collection1Dir, "core.properties")), "UTF-8");
+ props.store(writer, null);
+ } finally {
+ if (writer != null) {
+ try {
+ writer.close();
+ } catch (Exception ignore){}
+ }
+ }
createJetty(tempSolrHome.getAbsolutePath(), null, null);
}
@Test
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/TestBatchUpdate.java Sat Nov 1 09:32:06 2014
@@ -42,7 +42,7 @@ public class TestBatchUpdate extends Sol
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
+ createJetty(legacyExampleCollection1SolrHome(), null, null);
}
static final int numdocs = 1000;
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java Sat Nov 1 09:32:06 2014
@@ -24,6 +24,7 @@ import java.util.Random;
import org.apache.commons.io.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
+import org.apache.solr.SolrJettyTestBase;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.util.ExternalPaths;
import org.eclipse.jetty.server.Connector;
@@ -56,7 +57,7 @@ public class JettyWebappTest extends Sol
public void setUp() throws Exception
{
super.setUp();
- System.setProperty("solr.solr.home", ExternalPaths.EXAMPLE_HOME);
+ System.setProperty("solr.solr.home", SolrJettyTestBase.legacyExampleCollection1SolrHome());
System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong()));
File dataDir = createTempDir().toFile();
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeBinaryJettyTest.java Sat Nov 1 09:32:06 2014
@@ -27,6 +27,6 @@ import org.junit.BeforeClass;
public class LargeVolumeBinaryJettyTest extends LargeVolumeTestBase {
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
+ createJetty(legacyExampleCollection1SolrHome(), null, null);
}
}
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeEmbeddedTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeEmbeddedTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeEmbeddedTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeEmbeddedTest.java Sat Nov 1 09:32:06 2014
@@ -24,7 +24,6 @@ import org.junit.BeforeClass;
public class LargeVolumeEmbeddedTest extends LargeVolumeTestBase {
@BeforeClass
public static void beforeTest() throws Exception {
- initCore(ExternalPaths.EXAMPLE_CONFIG, ExternalPaths.EXAMPLE_SCHEMA,
- ExternalPaths.EXAMPLE_HOME);
+ initCore();
}
}
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/LargeVolumeJettyTest.java Sat Nov 1 09:32:06 2014
@@ -24,6 +24,6 @@ import org.junit.BeforeClass;
public class LargeVolumeJettyTest extends LargeVolumeTestBase {
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
+ createJetty(legacyExampleCollection1SolrHome(), null, null);
}
}
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleEmbeddedTest.java Sat Nov 1 09:32:06 2014
@@ -31,6 +31,6 @@ public class SolrExampleEmbeddedTest ext
@BeforeClass
public static void beforeTest() throws Exception {
- initCore(ExternalPaths.EXAMPLE_CONFIG, ExternalPaths.EXAMPLE_SCHEMA, ExternalPaths.EXAMPLE_HOME);
+ initCore();
}
}
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java Sat Nov 1 09:32:06 2014
@@ -18,8 +18,11 @@
package org.apache.solr.client.solrj.embedded;
import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.util.Map;
+import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
@@ -47,7 +50,7 @@ public class SolrExampleJettyTest extend
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
+ createJetty(legacyExampleCollection1SolrHome(), null, null);
}
@Test
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java Sat Nov 1 09:32:06 2014
@@ -47,7 +47,7 @@ public class SolrExampleStreamingTest ex
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
+ createJetty(legacyExampleCollection1SolrHome(), null, null);
}
@Override
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java Sat Nov 1 09:32:06 2014
@@ -151,7 +151,7 @@ public class BasicHttpSolrServerTest ext
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
+ createJetty(legacyExampleCollection1SolrHome(), null, null);
jetty.getDispatchFilter().getServletHandler()
.addServletWithMapping(RedirectServlet.class, "/redirect/*");
jetty.getDispatchFilter().getServletHandler()
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServerTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServerTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServerTest.java Sat Nov 1 09:32:06 2014
@@ -125,7 +125,7 @@ public class ConcurrentUpdateSolrServerT
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
+ createJetty(legacyExampleCollection1SolrHome(), null, null);
jetty.getDispatchFilter().getServletHandler()
.addServletWithMapping(TestServlet.class, "/cuss/*");
}
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ExternalHttpClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ExternalHttpClientTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ExternalHttpClientTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ExternalHttpClientTest.java Sat Nov 1 09:32:06 2014
@@ -34,7 +34,7 @@ import org.junit.Test;
public class ExternalHttpClientTest extends SolrJettyTestBase {
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
+ createJetty(legacyExampleCollection1SolrHome(), null, null);
jetty.getDispatchFilter().getServletHandler()
.addServletWithMapping(BasicHttpSolrServerTest.SlowServlet.class, "/slow/*");
}
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/response/NoOpResponseParserTest.java Sat Nov 1 09:32:06 2014
@@ -57,7 +57,7 @@ public class NoOpResponseParserTest exte
@BeforeClass
public static void beforeTest() throws Exception {
- createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
+ createJetty(legacyExampleCollection1SolrHome(), null, null);
}
@Before
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java Sat Nov 1 09:32:06 2014
@@ -36,7 +36,7 @@ public class TermsResponseTest extends S
@BeforeClass
public static void beforeTest() throws Exception {
- initCore(ExternalPaths.EXAMPLE_CONFIG, ExternalPaths.EXAMPLE_SCHEMA, ExternalPaths.EXAMPLE_HOME);
+ initCore();
}
@Before
Modified: lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java (original)
+++ lucene/dev/branches/lucene6005/solr/solrj/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java Sat Nov 1 09:32:06 2014
@@ -40,9 +40,7 @@ import java.util.List;
public class TestSpellCheckResponse extends SolrJettyTestBase {
@BeforeClass
public static void beforeTest() throws Exception {
- // createJetty(EXAMPLE_HOME, null, null);
- initCore(ExternalPaths.EXAMPLE_CONFIG, ExternalPaths.EXAMPLE_SCHEMA, ExternalPaths.EXAMPLE_HOME);
- // initCore("solrconfig.xml", "schema.xml", null);
+ initCore();
}
static String field = "name";
Modified: lucene/dev/branches/lucene6005/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java (original)
+++ lucene/dev/branches/lucene6005/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java Sat Nov 1 09:32:06 2014
@@ -18,13 +18,19 @@ package org.apache.solr;
*/
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.OutputStreamWriter;
+import java.util.Properties;
import java.util.SortedMap;
import org.apache.commons.io.FileUtils;
+import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.util.ExternalPaths;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -132,5 +138,51 @@ abstract public class SolrJettyTestBase
}
}
+ public static void initCore() throws Exception {
+ String exampleHome = legacyExampleCollection1SolrHome();
+ String exampleConfig = exampleHome+"/collection1/conf/solrconfig.xml";
+ String exampleSchema = exampleHome+"/collection1/conf/schema.xml";
+ initCore(exampleConfig, exampleSchema, exampleHome);
+ }
+
+ public static String legacyExampleCollection1SolrHome() {
+ String sourceHome = ExternalPaths.SOURCE_HOME;
+ if (sourceHome == null)
+ throw new IllegalStateException("No source home! Cannot create the legacy example solr home directory.");
+
+ String legacyExampleSolrHome = null;
+ try {
+ File tempSolrHome = LuceneTestCase.createTempDir().toFile();
+ org.apache.commons.io.FileUtils.copyFileToDirectory(new File(sourceHome, "server/solr/solr.xml"), tempSolrHome);
+ File collection1Dir = new File(tempSolrHome, "collection1");
+ org.apache.commons.io.FileUtils.forceMkdir(collection1Dir);
+
+ File configSetDir = new File(sourceHome, "server/solr/configsets/sample_techproducts_configs/conf");
+ org.apache.commons.io.FileUtils.copyDirectoryToDirectory(configSetDir, collection1Dir);
+ Properties props = new Properties();
+ props.setProperty("name", "collection1");
+ OutputStreamWriter writer = null;
+ try {
+ writer = new OutputStreamWriter(FileUtils.openOutputStream(new File(collection1Dir, "core.properties")), "UTF-8");
+ props.store(writer, null);
+ } finally {
+ if (writer != null) {
+ try {
+ writer.close();
+ } catch (Exception ignore){}
+ }
+ }
+ legacyExampleSolrHome = tempSolrHome.getAbsolutePath();
+ } catch (Exception exc) {
+ if (exc instanceof RuntimeException) {
+ throw (RuntimeException)exc;
+ } else {
+ throw new RuntimeException(exc);
+ }
+ }
+
+ return legacyExampleSolrHome;
+ }
+
}
Modified: lucene/dev/branches/lucene6005/solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java (original)
+++ lucene/dev/branches/lucene6005/solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java Sat Nov 1 09:32:06 2014
@@ -18,6 +18,11 @@ package org.apache.solr.util;
*/
import java.io.File;
+import java.io.FileOutputStream;
+import java.util.Properties;
+
+import org.apache.commons.io.*;
+import org.apache.lucene.util.LuceneTestCase;
/**
* Some tests need to reach outside the classpath to get certain resources (e.g. the example configuration).
@@ -37,20 +42,20 @@ public class ExternalPaths {
* home, and if it is null, those paths will just be relative to 'null' and may not be
* meaningful.
*/
- private static final String SOURCE_HOME = determineSourceHome();
+ public static final String SOURCE_HOME = determineSourceHome();
/* @see #SOURCE_HOME */
public static String WEBAPP_HOME = new File(SOURCE_HOME, "webapp/web").getAbsolutePath();
/* @see #SOURCE_HOME */
- public static String EXAMPLE_HOME = new File(SOURCE_HOME, "example/solr").getAbsolutePath();
- /* @see #SOURCE_HOME */
- public static String EXAMPLE_SCHEMALESS_HOME = new File(SOURCE_HOME, "example/example-schemaless/solr").getAbsolutePath();
+ public static String SCHEMALESS_CONFIGSET =
+ new File(SOURCE_HOME, "server/solr/configsets/data_driven_schema_configs/conf").getAbsolutePath();
+ public static String TECHPRODUCTS_CONFIGSET =
+ new File(SOURCE_HOME, "server/solr/configsets/sample_techproducts_configs/conf").getAbsolutePath();
+
/* @see #SOURCE_HOME */
public static String EXAMPLE_MULTICORE_HOME = new File(SOURCE_HOME, "example/multicore").getAbsolutePath();
- /* @see #SOURCE_HOME */
- public static String EXAMPLE_SCHEMA=EXAMPLE_HOME+"/collection1/conf/schema.xml";
- /* @see #SOURCE_HOME */
- public static String EXAMPLE_CONFIG=EXAMPLE_HOME+"/collection1/conf/solrconfig.xml";
-
+
+ public static String SERVER_HOME = new File(SOURCE_HOME, "server/solr").getAbsolutePath();
+
/**
* Ugly, ugly hack to determine the example home without depending on the CWD
* this is needed for example/multicore tests which reside outside the classpath.
Modified: lucene/dev/branches/lucene6005/solr/test-framework/src/java/org/apache/solr/util/SSLTestConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/test-framework/src/java/org/apache/solr/util/SSLTestConfig.java?rev=1635908&r1=1635907&r2=1635908&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/test-framework/src/java/org/apache/solr/util/SSLTestConfig.java (original)
+++ lucene/dev/branches/lucene6005/solr/test-framework/src/java/org/apache/solr/util/SSLTestConfig.java Sat Nov 1 09:32:06 2014
@@ -38,8 +38,8 @@ import org.apache.solr.common.params.Sol
import org.eclipse.jetty.util.security.CertificateUtils;
public class SSLTestConfig extends SSLConfig {
- public static File TEST_KEYSTORE = ExternalPaths.EXAMPLE_HOME == null ? null
- : new File(ExternalPaths.EXAMPLE_HOME, "../etc/solrtest.keystore");
+ public static File TEST_KEYSTORE = ExternalPaths.SERVER_HOME == null ? null
+ : new File(ExternalPaths.SERVER_HOME, "../etc/solrtest.keystore");
private static String TEST_KEYSTORE_PATH = TEST_KEYSTORE != null
&& TEST_KEYSTORE.exists() ? TEST_KEYSTORE.getAbsolutePath() : null;