mirror of https://github.com/apache/lucene.git
SOLR-7179: Stop using sysprops to configure test jettys
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1664292 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a275ca2bb5
commit
739e9b489d
|
@ -81,6 +81,9 @@ Upgrading from Solr 5.0
|
|||
* SolrRequest.process() is now final. Subclasses should instead be parametrized
|
||||
by their corresponding SolrResponse type, and implement createResponse()
|
||||
|
||||
* The signature of SolrDispatchFilter.createCoreContainer() has changed to take
|
||||
(String,Properties) arguments
|
||||
|
||||
Detailed Change List
|
||||
----------------------
|
||||
|
||||
|
@ -237,6 +240,10 @@ Other Changes
|
|||
|
||||
* SOLR-7151: SolrClient query methods throw IOException (Alan Woodward)
|
||||
|
||||
* SOLR-7179: JettySolrRunner no longer passes configuration to
|
||||
SolrDispatchFilter via system properties, but instead uses a Properties
|
||||
object in the servlet context (Alan Woodward)
|
||||
|
||||
* SOLR-6275: Improve accuracy of QTime reporting (Ramkumar Aiyengar)
|
||||
|
||||
* SOLR-7174: DIH should reset TikaEntityProcessor so that it is capable
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
|
||||
<solr>
|
||||
|
||||
<str name="coreRootDirectory">cores/</str>
|
||||
<str name="configSetBaseDir"></str>
|
||||
|
||||
<shardHandlerFactory name="shardHandlerFactory" class="HttpShardHandlerFactory">
|
||||
<str name="urlScheme">${urlScheme:}</str>
|
||||
</shardHandlerFactory>
|
||||
|
|
|
@ -80,6 +80,7 @@ import java.util.Collection;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
@ThreadLeakAction({Action.WARN})
|
||||
|
@ -744,19 +745,21 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {
|
|||
String shardList, String solrConfigOverride, String schemaOverride)
|
||||
throws Exception {
|
||||
|
||||
JettySolrRunner jetty
|
||||
= new JettySolrRunner(solrHome.getAbsolutePath(), solrConfigOverride, schemaOverride, buildJettyConfig(context));
|
||||
Properties props = new Properties();
|
||||
if (solrConfigOverride != null)
|
||||
props.setProperty("solrconfig", solrConfigOverride);
|
||||
if (schemaOverride != null)
|
||||
props.setProperty("schema", schemaOverride);
|
||||
props.setProperty("shards", shardList);
|
||||
|
||||
jetty.setShards(shardList);
|
||||
|
||||
if (System.getProperty("collection") == null) {
|
||||
System.setProperty("collection", "collection1");
|
||||
}
|
||||
|
||||
String collection = System.getProperty("collection");
|
||||
if (collection == null)
|
||||
collection = "collection1";
|
||||
props.setProperty("collection", collection);
|
||||
|
||||
JettySolrRunner jetty = new JettySolrRunner(solrHome.getAbsolutePath(), props, buildJettyConfig(context));
|
||||
jetty.start();
|
||||
|
||||
System.clearProperty("collection");
|
||||
|
||||
return jetty;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
|
||||
public abstract class AbstractSolrMorphlineZkTestBase extends AbstractFullDistribZkTestBase {
|
||||
private static File solrHomeDirectory;
|
||||
|
@ -144,19 +145,23 @@ public abstract class AbstractSolrMorphlineZkTestBase extends AbstractFullDistri
|
|||
throws Exception {
|
||||
|
||||
writeCoreProperties(solrHome.toPath(), DEFAULT_TEST_CORENAME);
|
||||
JettySolrRunner jetty
|
||||
= new JettySolrRunner(solrHome.getAbsolutePath(), solrConfigOverride, schemaOverride, buildJettyConfig(context));
|
||||
|
||||
jetty.setShards(shardList);
|
||||
|
||||
if (System.getProperty("collection") == null) {
|
||||
System.setProperty("collection", "collection1");
|
||||
}
|
||||
|
||||
Properties props = new Properties();
|
||||
if (solrConfigOverride != null)
|
||||
props.setProperty("solrconfig", solrConfigOverride);
|
||||
if (schemaOverride != null)
|
||||
props.setProperty("schema", schemaOverride);
|
||||
if (shardList != null)
|
||||
props.setProperty("shards", shardList);
|
||||
|
||||
String collection = System.getProperty("collection");
|
||||
if (collection == null)
|
||||
collection = "collection1";
|
||||
props.setProperty("collection", collection);
|
||||
|
||||
JettySolrRunner jetty = new JettySolrRunner(solrHome.getAbsolutePath(), props, buildJettyConfig(context));
|
||||
jetty.start();
|
||||
|
||||
System.clearProperty("collection");
|
||||
|
||||
return jetty;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,9 +32,10 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
|
|||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.servlets.GzipFilter;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.Filter;
|
||||
|
@ -51,6 +52,7 @@ import java.net.MalformedURLException;
|
|||
import java.net.URL;
|
||||
import java.util.EnumSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
||||
import java.util.SortedMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -63,41 +65,28 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||
*/
|
||||
public class JettySolrRunner {
|
||||
|
||||
private static final AtomicLong JETTY_ID_COUNTER = new AtomicLong();
|
||||
private static final Logger logger = LoggerFactory.getLogger(JettySolrRunner.class);
|
||||
|
||||
Server server;
|
||||
|
||||
FilterHolder dispatchFilter;
|
||||
FilterHolder debugFilter;
|
||||
|
||||
private String solrConfigFilename;
|
||||
private String schemaFilename;
|
||||
private final String coreRootDirectory;
|
||||
|
||||
private boolean waitOnSolr = false;
|
||||
|
||||
private int lastPort = -1;
|
||||
|
||||
private final JettyConfig config;
|
||||
|
||||
private String shards;
|
||||
|
||||
private String dataDir;
|
||||
private String solrUlogDir;
|
||||
private final String solrHome;
|
||||
private final Properties nodeProperties;
|
||||
|
||||
private volatile boolean startedBefore = false;
|
||||
|
||||
private final String solrHome;
|
||||
|
||||
private String coreNodeName;
|
||||
|
||||
private final String name;
|
||||
|
||||
private LinkedList<FilterHolder> extraFilters;
|
||||
|
||||
private int proxyPort = -1;
|
||||
|
||||
public static class DebugFilter implements Filter {
|
||||
public int requestsToKeep = 10;
|
||||
|
||||
private AtomicLong nRequests = new AtomicLong();
|
||||
|
||||
public long getTotalRequests() {
|
||||
|
@ -105,13 +94,8 @@ public class JettySolrRunner {
|
|||
|
||||
}
|
||||
|
||||
// TODO: keep track of certain number of last requests
|
||||
private LinkedList<HttpServletRequest> requests = new LinkedList<>();
|
||||
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
}
|
||||
public void init(FilterConfig filterConfig) throws ServletException { }
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
|
@ -120,25 +104,49 @@ public class JettySolrRunner {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
public void destroy() { }
|
||||
|
||||
}
|
||||
|
||||
private static Properties defaultNodeProperties(String solrconfigFilename, String schemaFilename) {
|
||||
Properties props = new Properties();
|
||||
props.setProperty("solrconfig", solrconfigFilename);
|
||||
props.setProperty("schema", schemaFilename);
|
||||
return props;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new JettySolrRunner.
|
||||
*
|
||||
* After construction, you must start the jetty with {@link #start()}
|
||||
*
|
||||
* @param solrHome the solr home directory to use
|
||||
* @param context the context to run in
|
||||
* @param port the port to run on
|
||||
*/
|
||||
public JettySolrRunner(String solrHome, String context, int port) {
|
||||
this(solrHome, JettyConfig.builder().setContext(context).setPort(port).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #JettySolrRunner(String,Properties,JettyConfig)}
|
||||
*/
|
||||
@Deprecated
|
||||
public JettySolrRunner(String solrHome, String context, int port, String solrConfigFilename, String schemaFileName) {
|
||||
this(solrHome, solrConfigFilename, schemaFileName, JettyConfig.builder()
|
||||
this(solrHome, defaultNodeProperties(solrConfigFilename, schemaFileName), JettyConfig.builder()
|
||||
.setContext(context)
|
||||
.setPort(port)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #JettySolrRunner(String,Properties,JettyConfig)}
|
||||
*/
|
||||
@Deprecated
|
||||
public JettySolrRunner(String solrHome, String context, int port,
|
||||
String solrConfigFilename, String schemaFileName, boolean stopAtShutdown) {
|
||||
this(solrHome, solrConfigFilename, schemaFileName, JettyConfig.builder()
|
||||
this(solrHome, defaultNodeProperties(solrConfigFilename, schemaFileName),
|
||||
JettyConfig.builder()
|
||||
.setContext(context)
|
||||
.setPort(port)
|
||||
.stopAtShutdown(stopAtShutdown)
|
||||
|
@ -148,13 +156,14 @@ public class JettySolrRunner {
|
|||
/**
|
||||
* Constructor taking an ordered list of additional (servlet holder -> path spec) mappings
|
||||
* to add to the servlet context
|
||||
* @deprecated use {@link #JettySolrRunner(String,String,String,JettyConfig)}
|
||||
* @deprecated use {@link JettySolrRunner#JettySolrRunner(String,Properties,JettyConfig)}
|
||||
*/
|
||||
@Deprecated
|
||||
public JettySolrRunner(String solrHome, String context, int port,
|
||||
String solrConfigFilename, String schemaFileName, boolean stopAtShutdown,
|
||||
SortedMap<ServletHolder,String> extraServlets) {
|
||||
this(solrHome, solrConfigFilename, schemaFileName, JettyConfig.builder()
|
||||
this(solrHome, defaultNodeProperties(solrConfigFilename, schemaFileName),
|
||||
JettyConfig.builder()
|
||||
.setContext(context)
|
||||
.setPort(port)
|
||||
.stopAtShutdown(stopAtShutdown)
|
||||
|
@ -162,10 +171,14 @@ public class JettySolrRunner {
|
|||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #JettySolrRunner(String,Properties,JettyConfig)}
|
||||
*/
|
||||
@Deprecated
|
||||
public JettySolrRunner(String solrHome, String context, int port, String solrConfigFilename, String schemaFileName,
|
||||
boolean stopAtShutdown, SortedMap<ServletHolder, String> extraServlets, SSLConfig sslConfig) {
|
||||
this(solrHome, solrConfigFilename, schemaFileName, JettyConfig.builder()
|
||||
this(solrHome, defaultNodeProperties(solrConfigFilename, schemaFileName),
|
||||
JettyConfig.builder()
|
||||
.setContext(context)
|
||||
.setPort(port)
|
||||
.stopAtShutdown(stopAtShutdown)
|
||||
|
@ -174,11 +187,15 @@ public class JettySolrRunner {
|
|||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #JettySolrRunner(String,Properties,JettyConfig)}
|
||||
*/
|
||||
@Deprecated
|
||||
public JettySolrRunner(String solrHome, String context, int port, String solrConfigFilename, String schemaFileName,
|
||||
boolean stopAtShutdown, SortedMap<ServletHolder, String> extraServlets, SSLConfig sslConfig,
|
||||
SortedMap<Class<? extends Filter>, String> extraRequestFilters) {
|
||||
this(solrHome, solrConfigFilename, schemaFileName, JettyConfig.builder()
|
||||
this(solrHome, defaultNodeProperties(solrConfigFilename, schemaFileName),
|
||||
JettyConfig.builder()
|
||||
.setContext(context)
|
||||
.setPort(port)
|
||||
.stopAtShutdown(stopAtShutdown)
|
||||
|
@ -191,39 +208,35 @@ public class JettySolrRunner {
|
|||
/**
|
||||
* Construct a JettySolrRunner
|
||||
*
|
||||
* After construction, you must start the jetty with {@link #start()}
|
||||
*
|
||||
* @param solrHome the base path to run from
|
||||
* @param jettyConfig the configuration
|
||||
* @param config the configuration
|
||||
*/
|
||||
public JettySolrRunner(String solrHome, JettyConfig jettyConfig) {
|
||||
this(solrHome, null, null, jettyConfig);
|
||||
public JettySolrRunner(String solrHome, JettyConfig config) {
|
||||
this(solrHome, new Properties(), config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a JettySolrRunner
|
||||
*
|
||||
* @param solrHome the base path to run from
|
||||
* @param solrConfigFilename the name of the solrconfig file to use
|
||||
* @param schemaFileName the name of the schema file to use
|
||||
* @param jettyConfig the configuration
|
||||
* After construction, you must start the jetty with {@link #start()}
|
||||
*
|
||||
* @param solrHome the solrHome to use
|
||||
* @param nodeProperties the container properties
|
||||
* @param config the configuration
|
||||
*/
|
||||
public JettySolrRunner(String solrHome, String solrConfigFilename, String schemaFileName, JettyConfig jettyConfig) {
|
||||
public JettySolrRunner(String solrHome, Properties nodeProperties, JettyConfig config) {
|
||||
|
||||
this.solrConfigFilename = solrConfigFilename;
|
||||
this.schemaFilename = schemaFileName;
|
||||
|
||||
this.name = "jetty-" + JETTY_ID_COUNTER.incrementAndGet();
|
||||
this.coreRootDirectory = System.getProperty("coreRootDirectory", null);
|
||||
|
||||
this.config = jettyConfig;
|
||||
this.solrHome = solrHome;
|
||||
this.config = config;
|
||||
this.nodeProperties = nodeProperties;
|
||||
|
||||
this.init(this.config.port);
|
||||
}
|
||||
|
||||
private void init(int port) {
|
||||
|
||||
System.setProperty("solr.solr.home", solrHome);
|
||||
|
||||
QueuedThreadPool qtp = new QueuedThreadPool();
|
||||
qtp.setMaxThreads(10000);
|
||||
qtp.setIdleTimeout((int) TimeUnit.SECONDS.toMillis(5));
|
||||
|
@ -281,7 +294,6 @@ public class JettySolrRunner {
|
|||
|
||||
@Override
|
||||
public void lifeCycleStopping(LifeCycle arg0) {
|
||||
System.clearProperty("hostPort");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -299,14 +311,13 @@ public class JettySolrRunner {
|
|||
public void lifeCycleStarted(LifeCycle arg0) {
|
||||
|
||||
lastPort = getFirstConnectorPort();
|
||||
nodeProperties.setProperty("hostPort", Integer.toString(lastPort));
|
||||
nodeProperties.setProperty("hostContext", config.context);
|
||||
|
||||
System.setProperty("hostPort", Integer.toString(lastPort));
|
||||
if (solrConfigFilename != null) System.setProperty("solrconfig",
|
||||
solrConfigFilename);
|
||||
if (schemaFilename != null) System.setProperty("schema",
|
||||
schemaFilename);
|
||||
if (coreRootDirectory != null)
|
||||
System.setProperty("coreRootDirectory", coreRootDirectory);
|
||||
root.getServletContext().setAttribute(SolrDispatchFilter.PROPERTIES_ATTRIBUTE, nodeProperties);
|
||||
root.getServletContext().setAttribute(SolrDispatchFilter.SOLRHOME_ATTRIBUTE, solrHome);
|
||||
|
||||
logger.info("Jetty properties: {}", nodeProperties);
|
||||
|
||||
debugFilter = root.addFilter(DebugFilter.class, "*", EnumSet.of(DispatcherType.REQUEST) );
|
||||
extraFilters = new LinkedList<>();
|
||||
|
@ -322,9 +333,6 @@ public class JettySolrRunner {
|
|||
|
||||
dispatchFilter = root.addFilter(SolrDispatchFilter.class, "*", EnumSet.of(DispatcherType.REQUEST) );
|
||||
|
||||
if (solrConfigFilename != null) System.clearProperty("solrconfig");
|
||||
if (schemaFilename != null) System.clearProperty("schema");
|
||||
System.clearProperty("solr.solr.home");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -338,8 +346,6 @@ public class JettySolrRunner {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public FilterHolder getDispatchFilter() {
|
||||
return dispatchFilter;
|
||||
}
|
||||
|
@ -355,11 +361,12 @@ public class JettySolrRunner {
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Start the Jetty server
|
||||
*
|
||||
* @throws Exception if an error occurs on startup
|
||||
*/
|
||||
public void start() throws Exception {
|
||||
start(true);
|
||||
}
|
||||
|
||||
public void start(boolean waitForSolr) throws Exception {
|
||||
// if started before, make a new server
|
||||
if (startedBefore) {
|
||||
waitOnSolr = false;
|
||||
|
@ -367,50 +374,33 @@ public class JettySolrRunner {
|
|||
} else {
|
||||
startedBefore = true;
|
||||
}
|
||||
|
||||
if (dataDir != null) {
|
||||
System.setProperty("solr.data.dir", dataDir);
|
||||
|
||||
if (!server.isRunning()) {
|
||||
server.start();
|
||||
}
|
||||
if (solrUlogDir != null) {
|
||||
System.setProperty("solr.ulog.dir", solrUlogDir);
|
||||
}
|
||||
if (shards != null) {
|
||||
System.setProperty("shard", shards);
|
||||
}
|
||||
if (coreNodeName != null) {
|
||||
System.setProperty("coreNodeName", coreNodeName);
|
||||
}
|
||||
try {
|
||||
|
||||
if (!server.isRunning()) {
|
||||
server.start();
|
||||
}
|
||||
synchronized (JettySolrRunner.this) {
|
||||
int cnt = 0;
|
||||
while (!waitOnSolr) {
|
||||
this.wait(100);
|
||||
if (cnt++ == 5) {
|
||||
throw new RuntimeException("Jetty/Solr unresponsive");
|
||||
}
|
||||
synchronized (JettySolrRunner.this) {
|
||||
int cnt = 0;
|
||||
while (!waitOnSolr) {
|
||||
this.wait(100);
|
||||
if (cnt++ == 5) {
|
||||
throw new RuntimeException("Jetty/Solr unresponsive");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
||||
System.clearProperty("shard");
|
||||
System.clearProperty("solr.data.dir");
|
||||
System.clearProperty("coreNodeName");
|
||||
System.clearProperty("solr.ulog.dir");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the Jetty server
|
||||
*
|
||||
* @throws Exception if an error occurs on shutdown
|
||||
*/
|
||||
public void stop() throws Exception {
|
||||
|
||||
Filter filter = dispatchFilter.getFilter();
|
||||
|
||||
server.stop();
|
||||
|
||||
//server.destroy();
|
||||
if (server.getState().equals(Server.FAILED)) {
|
||||
filter.destroy();
|
||||
if (extraFilters != null) {
|
||||
|
@ -512,118 +502,42 @@ public class JettySolrRunner {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated set properties in the Properties passed to the constructor
|
||||
*/
|
||||
@Deprecated
|
||||
public void setShards(String shardList) {
|
||||
this.shards = shardList;
|
||||
nodeProperties.setProperty("shard", shardList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated set properties in the Properties passed to the constructor
|
||||
*/
|
||||
@Deprecated
|
||||
public void setDataDir(String dataDir) {
|
||||
this.dataDir = dataDir;
|
||||
nodeProperties.setProperty("solr.data.dir", dataDir);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated set properties in the Properties passed to the constructor
|
||||
*/
|
||||
@Deprecated
|
||||
public void setUlogDir(String ulogDir) {
|
||||
this.solrUlogDir = ulogDir;
|
||||
nodeProperties.setProperty("solr.ulog.dir", ulogDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated set properties in the Properties passed to the constructor
|
||||
*/
|
||||
@Deprecated
|
||||
public void setCoreNodeName(String coreNodeName) {
|
||||
this.coreNodeName = coreNodeName;
|
||||
nodeProperties.setProperty("coreNodeName", coreNodeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Solr home directory of this JettySolrRunner
|
||||
*/
|
||||
public String getSolrHome() {
|
||||
return solrHome;
|
||||
}
|
||||
}
|
||||
|
||||
class NoLog implements Logger {
|
||||
private static boolean debug = System.getProperty("DEBUG", null) != null;
|
||||
|
||||
private final String name;
|
||||
|
||||
public NoLog() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public NoLog(String name) {
|
||||
this.name = name == null ? "" : name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugEnabled() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebugEnabled(boolean enabled) {
|
||||
debug = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String msg, Throwable th) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger(String name) {
|
||||
if ((name == null && this.name == null)
|
||||
|| (name != null && name.equals(this.name)))
|
||||
return this;
|
||||
return new NoLog(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NOLOG[" + name + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Throwable arg0) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String arg0, Object... arg1) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String s, long l) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ignore(Throwable arg0) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Throwable arg0) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String arg0, Object... arg1) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String arg0, Throwable arg1) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Throwable arg0) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String arg0, Object... arg1) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String arg0, Throwable arg1) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,14 +161,19 @@ public class CoreContainer {
|
|||
* @see #load()
|
||||
*/
|
||||
public CoreContainer(NodeConfig config) {
|
||||
this(config, new CorePropertiesLocator(config.getCoreRootDirectory()));
|
||||
this(config, new Properties());
|
||||
}
|
||||
|
||||
public CoreContainer(NodeConfig config, CoresLocator locator) {
|
||||
public CoreContainer(NodeConfig config, Properties properties) {
|
||||
this(config, properties, new CorePropertiesLocator(config.getCoreRootDirectory()));
|
||||
}
|
||||
|
||||
public CoreContainer(NodeConfig config, Properties properties, CoresLocator locator) {
|
||||
this.loader = config.getSolrResourceLoader();
|
||||
this.solrHome = loader.getInstanceDir();
|
||||
this.cfg = checkNotNull(config);
|
||||
this.coresLocator = locator;
|
||||
this.containerProperties = new Properties(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,6 +188,7 @@ public class CoreContainer {
|
|||
loader = null;
|
||||
coresLocator = null;
|
||||
cfg = null;
|
||||
containerProperties = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -250,7 +256,7 @@ public class CoreContainer {
|
|||
|
||||
coreConfigService = ConfigSetService.createConfigSetService(cfg, loader, zkSys.zkController);
|
||||
|
||||
containerProperties = cfg.getSolrProperties();
|
||||
containerProperties.putAll(cfg.getSolrProperties());
|
||||
|
||||
// setup executor to load cores in parallel
|
||||
// do not limit the size of the executor in zk mode since cores may try and wait for each other.
|
||||
|
|
|
@ -206,6 +206,8 @@ public class CoreDescriptor {
|
|||
else {
|
||||
cloudDesc = null;
|
||||
}
|
||||
|
||||
System.out.println("CORE DESCRIPTOR: " + coreProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,6 +16,7 @@ package org.apache.solr.handler.component;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrResponse;
|
||||
|
@ -177,6 +178,8 @@ public class HttpShardHandler extends ShardHandler {
|
|||
public void submit(final ShardRequest sreq, final String shard, final ModifiableSolrParams params) {
|
||||
// do this outside of the callable for thread safety reasons
|
||||
final List<String> urls = getURLs(sreq, shard);
|
||||
if (Strings.isNullOrEmpty(shard))
|
||||
System.out.println("Empty shard!");
|
||||
|
||||
Callable<ShardResponse> task = new Callable<ShardResponse>() {
|
||||
@Override
|
||||
|
|
|
@ -96,10 +96,9 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.singletonMap;
|
||||
|
||||
/**
|
||||
* This filter looks at the incoming URL maps them to handlers defined in solrconfig.xml
|
||||
*
|
||||
|
@ -120,6 +119,10 @@ public class SolrDispatchFilter extends BaseSolrFilter {
|
|||
|
||||
public SolrDispatchFilter() {
|
||||
}
|
||||
|
||||
public static final String PROPERTIES_ATTRIBUTE = "solr.properties";
|
||||
|
||||
public static final String SOLRHOME_ATTRIBUTE = "solr.solr.home";
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig config) throws ServletException
|
||||
|
@ -130,7 +133,16 @@ public class SolrDispatchFilter extends BaseSolrFilter {
|
|||
// web.xml configuration
|
||||
this.pathPrefix = config.getInitParameter( "path-prefix" );
|
||||
|
||||
this.cores = createCoreContainer();
|
||||
Properties extraProperties = (Properties) config.getServletContext().getAttribute(PROPERTIES_ATTRIBUTE);
|
||||
if (extraProperties == null)
|
||||
extraProperties = new Properties();
|
||||
|
||||
String solrHome = (String) config.getServletContext().getAttribute(SOLRHOME_ATTRIBUTE);
|
||||
if (solrHome == null)
|
||||
solrHome = SolrResourceLoader.locateSolrHome();
|
||||
|
||||
this.cores = createCoreContainer(solrHome, extraProperties);
|
||||
|
||||
log.info("user.dir=" + System.getProperty("user.dir"));
|
||||
}
|
||||
catch( Throwable t ) {
|
||||
|
@ -145,7 +157,20 @@ public class SolrDispatchFilter extends BaseSolrFilter {
|
|||
log.info("SolrDispatchFilter.init() done");
|
||||
}
|
||||
|
||||
private NodeConfig loadConfigSolr(SolrResourceLoader loader) {
|
||||
/**
|
||||
* Override this to change CoreContainer initialization
|
||||
* @return a CoreContainer to hold this server's cores
|
||||
*/
|
||||
protected CoreContainer createCoreContainer(String solrHome, Properties extraProperties) {
|
||||
NodeConfig nodeConfig = loadNodeConfig(solrHome, extraProperties);
|
||||
cores = new CoreContainer(nodeConfig, extraProperties);
|
||||
cores.load();
|
||||
return cores;
|
||||
}
|
||||
|
||||
private NodeConfig loadNodeConfig(String solrHome, Properties nodeProperties) {
|
||||
|
||||
SolrResourceLoader loader = new SolrResourceLoader(solrHome, null, nodeProperties);
|
||||
|
||||
String solrxmlLocation = System.getProperty("solr.solrxml.location", "solrhome");
|
||||
|
||||
|
@ -158,34 +183,19 @@ public class SolrDispatchFilter extends BaseSolrFilter {
|
|||
if (StringUtils.isEmpty(zkHost))
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR,
|
||||
"Could not load solr.xml from zookeeper: zkHost system property not set");
|
||||
SolrZkClient zkClient = new SolrZkClient(zkHost, 30000);
|
||||
try {
|
||||
try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) {
|
||||
if (!zkClient.exists("/solr.xml", true))
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, "Could not load solr.xml from zookeeper: node not found");
|
||||
byte[] data = zkClient.getData("/solr.xml", null, null, true);
|
||||
return SolrXmlConfig.fromInputStream(loader, new ByteArrayInputStream(data));
|
||||
} catch (Exception e) {
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, "Could not load solr.xml from zookeeper", e);
|
||||
} finally {
|
||||
zkClient.close();
|
||||
}
|
||||
}
|
||||
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR,
|
||||
"Bad solr.solrxml.location set: " + solrxmlLocation + " - should be 'solrhome' or 'zookeeper'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this to change CoreContainer initialization
|
||||
* @return a CoreContainer to hold this server's cores
|
||||
*/
|
||||
protected CoreContainer createCoreContainer() {
|
||||
SolrResourceLoader loader = new SolrResourceLoader(SolrResourceLoader.locateSolrHome());
|
||||
NodeConfig config = loadConfigSolr(loader);
|
||||
CoreContainer cores = new CoreContainer(config);
|
||||
cores.load();
|
||||
return cores;
|
||||
}
|
||||
|
||||
public CoreContainer getCores() {
|
||||
return cores;
|
||||
|
|
|
@ -58,7 +58,7 @@ public class TestTolerantSearch extends SolrJettyTestBase {
|
|||
@BeforeClass
|
||||
public static void createThings() throws Exception {
|
||||
solrHome = createSolrHome();
|
||||
createJetty(solrHome.getAbsolutePath(), null, null);
|
||||
createJetty(solrHome.getAbsolutePath());
|
||||
String url = jetty.getBaseUrl().toString();
|
||||
collection1 = new HttpSolrClient(url + "/collection1");
|
||||
collection2 = new HttpSolrClient(url + "/collection2");
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
package org.apache.solr.client.solrj.embedded;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.request.CoreAdminRequest;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Properties;
|
||||
|
||||
public class TestJettySolrRunner extends SolrTestCaseJ4 {
|
||||
|
||||
@Test
|
||||
public void testPassSolrHomeToRunner() throws Exception {
|
||||
|
||||
// We set a non-standard coreRootDirectory, create a core, and check that it has been
|
||||
// built in the correct place
|
||||
|
||||
Path solrHome = createTempDir();
|
||||
Path coresDir = createTempDir("crazy_path_to_cores");
|
||||
|
||||
Path configsets = Paths.get(TEST_HOME()).resolve("configsets");
|
||||
|
||||
String solrxml
|
||||
= "<solr><str name=\"configSetBaseDir\">CONFIGSETS</str><str name=\"coreRootDirectory\">COREROOT</str></solr>"
|
||||
.replace("CONFIGSETS", configsets.toString())
|
||||
.replace("COREROOT", coresDir.toString());
|
||||
Files.write(solrHome.resolve("solr.xml"), solrxml.getBytes(Charsets.UTF_8));
|
||||
|
||||
JettyConfig jettyConfig = buildJettyConfig("/solr");
|
||||
|
||||
JettySolrRunner runner = new JettySolrRunner(solrHome.toString(), new Properties(), jettyConfig);
|
||||
try {
|
||||
runner.start();
|
||||
|
||||
SolrClient client = new HttpSolrClient(runner.getBaseUrl().toString());
|
||||
|
||||
CoreAdminRequest.Create createReq = new CoreAdminRequest.Create();
|
||||
createReq.setCoreName("newcore");
|
||||
createReq.setConfigSet("minimal");
|
||||
|
||||
client.request(createReq);
|
||||
|
||||
assertTrue(Files.exists(coresDir.resolve("newcore").resolve("core.properties")));
|
||||
|
||||
}
|
||||
finally {
|
||||
runner.stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -100,7 +100,7 @@ import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
|
|||
*/
|
||||
@Slow
|
||||
public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBase {
|
||||
|
||||
|
||||
private static final String DEFAULT_COLLECTION = "collection1";
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
|
@ -646,6 +646,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
|
|||
if (random().nextBoolean()) {
|
||||
JettySolrRunner jetty = jettys.get(random().nextInt(jettys.size()));
|
||||
ChaosMonkey.stop(jetty);
|
||||
log.info("============ Restarting jetty");
|
||||
ChaosMonkey.start(jetty);
|
||||
|
||||
for (Entry<String,List<Integer>> entry : collectionInfosEntrySet) {
|
||||
|
@ -665,6 +666,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
|
|||
// sometimes we restart zookeeper
|
||||
if (random().nextBoolean()) {
|
||||
zkServer.shutdown();
|
||||
log.info("============ Restarting zookeeper");
|
||||
zkServer = new ZkTestServer(zkServer.getZkDir(), zkServer.getPort());
|
||||
zkServer.run();
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
|
||||
|
||||
|
@ -81,9 +82,16 @@ public class SSLMigrationTest extends AbstractFullDistribZkTestBase {
|
|||
.withFilters(getExtraRequestFilters())
|
||||
.withSSLConfig(sslConfig)
|
||||
.build();
|
||||
JettySolrRunner newRunner = new JettySolrRunner(runner.getSolrHome(), getSolrConfigFile(), getSchemaFile(), config);
|
||||
newRunner.setDataDir(getDataDir(testDir + "/shard" + i + "/data"));
|
||||
newRunner.start(true);
|
||||
|
||||
Properties props = new Properties();
|
||||
if (getSolrConfigFile() != null)
|
||||
props.setProperty("solrconfig", getSolrConfigFile());
|
||||
if (getSchemaFile() != null)
|
||||
props.setProperty("schema", getSchemaFile());
|
||||
props.setProperty("solr.data.dir", getDataDir(testDir + "/shard" + i + "/data"));
|
||||
|
||||
JettySolrRunner newRunner = new JettySolrRunner(runner.getSolrHome(), props, config);
|
||||
newRunner.start();
|
||||
jettys.set(i, newRunner);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.solr.cloud;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class ShardRoutingCustomTest extends AbstractFullDistribZkTestBase {
|
||||
|
||||
String collection = DEFAULT_COLLECTION; // enable this to be configurable (more work needs to be done)
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.apache.solr.common.SolrException;
|
|||
import org.apache.solr.common.cloud.SolrZkClient;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.core.NodeConfig;
|
||||
import org.apache.solr.core.SolrResourceLoader;
|
||||
import org.apache.solr.servlet.SolrDispatchFilter;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -36,6 +35,7 @@ import java.io.File;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Properties;
|
||||
|
||||
public class SolrXmlInZkTest extends SolrTestCaseJ4 {
|
||||
|
||||
|
@ -74,8 +74,6 @@ public class SolrXmlInZkTest extends SolrTestCaseJ4 {
|
|||
FileUtils.copyFile(new File(SolrTestCaseJ4.TEST_HOME(), "solr-stress-new.xml"), new File(solrHome, "solr.xml"));
|
||||
}
|
||||
|
||||
System.setProperty("solr.solr.home", solrHome.getAbsolutePath());
|
||||
|
||||
ignoreException("No UpdateLog found - cannot sync");
|
||||
ignoreException("No UpdateLog found - cannot recover");
|
||||
|
||||
|
@ -100,14 +98,15 @@ public class SolrXmlInZkTest extends SolrTestCaseJ4 {
|
|||
log.info("####SETUP_START " + getTestName());
|
||||
|
||||
// set some system properties for use by tests
|
||||
System.setProperty("solr.test.sys.prop1", "propone");
|
||||
System.setProperty("solr.test.sys.prop2", "proptwo");
|
||||
Properties props = new Properties();
|
||||
props.setProperty("solr.test.sys.prop1", "propone");
|
||||
props.setProperty("solr.test.sys.prop2", "proptwo");
|
||||
|
||||
Method method = SolrDispatchFilter.class.getDeclaredMethod("loadConfigSolr", SolrResourceLoader.class);
|
||||
Method method = SolrDispatchFilter.class.getDeclaredMethod("loadNodeConfig", String.class, Properties.class);
|
||||
method.setAccessible(true);
|
||||
if (solrDispatchFilter != null) solrDispatchFilter.destroy();
|
||||
solrDispatchFilter = new SolrDispatchFilter();
|
||||
Object obj = method.invoke(solrDispatchFilter, new SolrResourceLoader(null));
|
||||
Object obj = method.invoke(solrDispatchFilter, solrHome.getAbsolutePath(), props);
|
||||
cfg = (NodeConfig) obj;
|
||||
|
||||
log.info("####SETUP_END " + getTestName());
|
||||
|
@ -208,11 +207,11 @@ public class SolrXmlInZkTest extends SolrTestCaseJ4 {
|
|||
// Should see an error when zkHost is not defined but solr.solrxml.location is set to zookeeper.
|
||||
System.clearProperty("zkHost");
|
||||
try {
|
||||
Method method = SolrDispatchFilter.class.getDeclaredMethod("loadConfigSolr", SolrResourceLoader.class);
|
||||
Method method = SolrDispatchFilter.class.getDeclaredMethod("loadNodeConfig", String.class, Properties.class);
|
||||
method.setAccessible(true);
|
||||
if (solrDispatchFilter != null) solrDispatchFilter.destroy();
|
||||
solrDispatchFilter = new SolrDispatchFilter();
|
||||
method.invoke(solrDispatchFilter, new SolrResourceLoader(null));
|
||||
method.invoke(solrDispatchFilter, "", new Properties());
|
||||
fail("Should have thrown an exception");
|
||||
} catch (InvocationTargetException ite) {
|
||||
assertTrue("Should be catching a SolrException", ite.getTargetException() instanceof SolrException);
|
||||
|
|
|
@ -36,6 +36,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -203,7 +204,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
|||
|
||||
System.setProperty("configsets", getFile("solr/configsets").getAbsolutePath());
|
||||
|
||||
final CoreContainer cc = new CoreContainer(SolrXmlConfig.fromString(resourceLoader, CONFIGSETS_SOLR_XML), cl);
|
||||
final CoreContainer cc = new CoreContainer(SolrXmlConfig.fromString(resourceLoader, CONFIGSETS_SOLR_XML), new Properties(), cl);
|
||||
CoreDescriptor badcore = new CoreDescriptor(cc, "badcore", "badcore", "configSet", "nosuchconfigset");
|
||||
cl.add(badcore);
|
||||
|
||||
|
@ -452,7 +453,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
|||
|
||||
System.setProperty("configsets", getFile("solr/configsets").getAbsolutePath());
|
||||
|
||||
final CoreContainer cc = new CoreContainer(SolrXmlConfig.fromString(resourceLoader, CONFIGSETS_SOLR_XML), cl);
|
||||
final CoreContainer cc = new CoreContainer(SolrXmlConfig.fromString(resourceLoader, CONFIGSETS_SOLR_XML), new Properties(), cl);
|
||||
cl.add(new CoreDescriptor(cc, "col_ok", "col_ok", "configSet", "minimal"));
|
||||
cl.add(new CoreDescriptor(cc, "col_bad", "col_bad", "configSet", "bad-mergepolicy"));
|
||||
cc.load();
|
||||
|
|
|
@ -1050,7 +1050,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
|
|||
// tries to
|
||||
// replicate
|
||||
masterJetty.stop();
|
||||
masterJetty.start(true);
|
||||
masterJetty.start();
|
||||
|
||||
// masterClient = createNewSolrClient(masterJetty.getLocalPort());
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public class ShowFileRequestHandlerTest extends SolrJettyTestBase {
|
|||
|
||||
@BeforeClass
|
||||
public static void beforeTest() throws Exception {
|
||||
createJetty(legacyExampleCollection1SolrHome(), null, null);
|
||||
createJetty(legacyExampleCollection1SolrHome());
|
||||
}
|
||||
|
||||
public void test404ViaHttp() throws SolrServerException, IOException {
|
||||
|
|
|
@ -64,7 +64,7 @@ public class DistributedDebugComponentTest extends SolrJettyTestBase {
|
|||
@BeforeClass
|
||||
public static void createThings() throws Exception {
|
||||
solrHome = createSolrHome();
|
||||
createJetty(solrHome.getAbsolutePath(), null, null);
|
||||
createJetty(solrHome.getAbsolutePath());
|
||||
String url = jetty.getBaseUrl().toString();
|
||||
|
||||
collection1 = new HttpSolrClient(url + "/collection1");
|
||||
|
|
|
@ -57,7 +57,7 @@ public class TestRemoteStreaming extends SolrJettyTestBase {
|
|||
//this one has handleSelect=true which a test here needs
|
||||
solrHomeDirectory = createTempDir(LuceneTestCase.getTestClass().getSimpleName()).toFile();
|
||||
setupJettyTestHome(solrHomeDirectory, "collection1");
|
||||
createJetty(solrHomeDirectory.getAbsolutePath(), null, null);
|
||||
createJetty(solrHomeDirectory.getAbsolutePath());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
@ -71,7 +71,7 @@ public class TestBinaryField extends SolrJettyTestBase {
|
|||
coreProps.store(w, "");
|
||||
}
|
||||
|
||||
createJetty(homeDir.getAbsolutePath(), null, null);
|
||||
createJetty(homeDir.getAbsolutePath());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,15 +18,6 @@ package org.apache.solr.servlet;
|
|||
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
|
@ -36,6 +27,15 @@ import org.junit.AfterClass;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* A test case for the several HTTP cache headers emitted by Solr
|
||||
*/
|
||||
|
@ -46,7 +46,7 @@ public class CacheHeaderTest extends CacheHeaderTestBase {
|
|||
public static void beforeTest() throws Exception {
|
||||
solrHomeDirectory = createTempDir().toFile();
|
||||
setupJettyTestHome(solrHomeDirectory, "collection1");
|
||||
createJetty(solrHomeDirectory.getAbsolutePath(), null, null);
|
||||
createJetty(solrHomeDirectory.getAbsolutePath());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
@ -17,13 +17,6 @@ package org.apache.solr.servlet;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
|
@ -40,6 +33,13 @@ import org.junit.AfterClass;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
|
||||
public class ResponseHeaderTest extends SolrJettyTestBase {
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class ResponseHeaderTest extends SolrJettyTestBase {
|
|||
setupJettyTestHome(solrHomeDirectory, "collection1");
|
||||
String top = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf";
|
||||
FileUtils.copyFile(new File(top, "solrconfig-headers.xml"), new File(solrHomeDirectory + "/collection1/conf", "solrconfig.xml"));
|
||||
createJetty(solrHomeDirectory.getAbsolutePath(), null, null);
|
||||
createJetty(solrHomeDirectory.getAbsolutePath());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
@ -90,9 +90,12 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {
|
|||
protected void createServers(int numShards) throws Exception {
|
||||
|
||||
System.setProperty("configSetBaseDir", TEST_HOME());
|
||||
System.setProperty("coreRootDirectory", testDir.toPath().resolve("control").toString());
|
||||
writeCoreProperties(testDir.toPath().resolve("control/cores"), DEFAULT_TEST_CORENAME);
|
||||
controlJetty = createJetty(new File(getSolrHome()), testDir + "/control/data", null, getSolrConfigFile(), getSchemaFile());
|
||||
|
||||
File controlHome = testDir.toPath().resolve("control").toFile();
|
||||
|
||||
seedSolrHome(controlHome);
|
||||
writeCoreProperties(controlHome.toPath().resolve("cores").resolve(DEFAULT_TEST_CORENAME), DEFAULT_TEST_CORENAME);
|
||||
controlJetty = createJetty(controlHome, testDir + "/control/data", null, getSolrConfigFile(), getSchemaFile());
|
||||
|
||||
controlClient = createNewSolrClient(controlJetty.getLocalPort());
|
||||
|
||||
|
@ -101,10 +104,11 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {
|
|||
for (int i = 0; i < numShards; i++) {
|
||||
if (sb.length() > 0) sb.append(',');
|
||||
String shardname = "shard" + i;
|
||||
Path coresPath = testDir.toPath().resolve(shardname).resolve("cores");
|
||||
writeCoreProperties(coresPath, DEFAULT_TEST_CORENAME);
|
||||
System.setProperty("coreRootDirectory", testDir.toPath().resolve(shardname).toString());
|
||||
JettySolrRunner j = createJetty(new File(getSolrHome()),
|
||||
Path shardHome = testDir.toPath().resolve(shardname);
|
||||
seedSolrHome(shardHome.toFile());
|
||||
Path coresPath = shardHome.resolve("cores");
|
||||
writeCoreProperties(coresPath.resolve(DEFAULT_TEST_CORENAME), DEFAULT_TEST_CORENAME);
|
||||
JettySolrRunner j = createJetty(shardHome.toFile(),
|
||||
testDir + "/shard" + i + "/data", null, getSolrConfigFile(),
|
||||
getSchemaFile());
|
||||
jettys.add(j);
|
||||
|
|
|
@ -87,6 +87,7 @@ import java.util.concurrent.Future;
|
|||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class CloudSolrClient extends SolrClient {
|
||||
|
||||
protected static final Logger log = LoggerFactory.getLogger(CloudSolrClient.class);
|
||||
|
||||
private volatile ZkStateReader zkStateReader;
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.junit.BeforeClass;
|
|||
public class SolrExampleBinaryTest extends SolrExampleTests {
|
||||
@BeforeClass
|
||||
public static void beforeTest() throws Exception {
|
||||
createJetty(legacyExampleCollection1SolrHome(), null, null);
|
||||
createJetty(legacyExampleCollection1SolrHome());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.junit.BeforeClass;
|
|||
public class SolrExampleXMLTest extends SolrExampleTests {
|
||||
@BeforeClass
|
||||
public static void beforeTest() throws Exception {
|
||||
createJetty(legacyExampleCollection1SolrHome(), null, null);
|
||||
createJetty(legacyExampleCollection1SolrHome());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -68,7 +68,7 @@ public class SolrSchemalessExampleTest extends SolrExampleTestsBase {
|
|||
} catch (Exception ignore){}
|
||||
}
|
||||
}
|
||||
createJetty(tempSolrHome.getAbsolutePath(), null, null);
|
||||
createJetty(tempSolrHome.getAbsolutePath());
|
||||
}
|
||||
@Test
|
||||
public void testArbitraryJsonIndexing() throws Exception {
|
||||
|
|
|
@ -41,7 +41,7 @@ public class TestBatchUpdate extends SolrJettyTestBase {
|
|||
|
||||
@BeforeClass
|
||||
public static void beforeTest() throws Exception {
|
||||
createJetty(legacyExampleCollection1SolrHome(), null, null);
|
||||
createJetty(legacyExampleCollection1SolrHome());
|
||||
}
|
||||
|
||||
static final int numdocs = 1000;
|
||||
|
|
|
@ -46,6 +46,7 @@ import java.nio.file.Files;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -309,13 +310,14 @@ public class TestLBHttpSolrClient extends SolrTestCaseJ4 {
|
|||
}
|
||||
|
||||
public void startJetty() throws Exception {
|
||||
jetty = new JettySolrRunner(getHomeDir(), "bad_solrconfig.xml", null, JettyConfig.builder()
|
||||
.setContext("/solr")
|
||||
.stopAtShutdown(true)
|
||||
.setPort(port)
|
||||
.withSSLConfig(sslConfig)
|
||||
.build());
|
||||
jetty.setDataDir(getDataDir());
|
||||
|
||||
Properties props = new Properties();
|
||||
props.setProperty("solrconfig", "bad_solrconfig.xml");
|
||||
props.setProperty("solr.data.dir", getDataDir());
|
||||
|
||||
JettyConfig jettyConfig = JettyConfig.builder(buildJettyConfig("/solr")).setPort(port).build();
|
||||
|
||||
jetty = new JettySolrRunner(getHomeDir(), props, jettyConfig);
|
||||
jetty.start();
|
||||
int newPort = jetty.getLocalPort();
|
||||
if (port != 0 && newPort != port) {
|
||||
|
|
|
@ -27,6 +27,6 @@ import org.junit.BeforeClass;
|
|||
public class LargeVolumeBinaryJettyTest extends LargeVolumeTestBase {
|
||||
@BeforeClass
|
||||
public static void beforeTest() throws Exception {
|
||||
createJetty(legacyExampleCollection1SolrHome(), null, null);
|
||||
createJetty(legacyExampleCollection1SolrHome());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,6 @@ import org.junit.BeforeClass;
|
|||
public class LargeVolumeJettyTest extends LargeVolumeTestBase {
|
||||
@BeforeClass
|
||||
public static void beforeTest() throws Exception {
|
||||
createJetty(legacyExampleCollection1SolrHome(), null, null);
|
||||
createJetty(legacyExampleCollection1SolrHome());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class SolrExampleJettyTest extends SolrExampleTests {
|
|||
|
||||
@BeforeClass
|
||||
public static void beforeTest() throws Exception {
|
||||
createJetty(legacyExampleCollection1SolrHome(), null, null);
|
||||
createJetty(legacyExampleCollection1SolrHome());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -44,7 +44,7 @@ public class SolrExampleStreamingTest extends SolrExampleTests {
|
|||
|
||||
@BeforeClass
|
||||
public static void beforeTest() throws Exception {
|
||||
createJetty(legacyExampleCollection1SolrHome(), null, null);
|
||||
createJetty(legacyExampleCollection1SolrHome());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.solr.client.solrj.SolrQuery;
|
|||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrRequest.METHOD;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.embedded.JettyConfig;
|
||||
import org.apache.solr.client.solrj.request.QueryRequest;
|
||||
import org.apache.solr.client.solrj.request.UpdateRequest;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
|
@ -36,6 +37,7 @@ import org.apache.solr.common.SolrInputDocument;
|
|||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.util.SSLTestConfig;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -147,13 +149,13 @@ public class BasicHttpSolrClientTest extends SolrJettyTestBase {
|
|||
|
||||
@BeforeClass
|
||||
public static void beforeTest() throws Exception {
|
||||
createJetty(legacyExampleCollection1SolrHome(), null, null);
|
||||
jetty.getDispatchFilter().getServletHandler()
|
||||
.addServletWithMapping(RedirectServlet.class, "/redirect/*");
|
||||
jetty.getDispatchFilter().getServletHandler()
|
||||
.addServletWithMapping(SlowServlet.class, "/slow/*");
|
||||
jetty.getDispatchFilter().getServletHandler()
|
||||
.addServletWithMapping(DebugServlet.class, "/debug/*");
|
||||
JettyConfig jettyConfig = JettyConfig.builder()
|
||||
.withServlet(new ServletHolder(RedirectServlet.class), "/redirect/*")
|
||||
.withServlet(new ServletHolder(SlowServlet.class), "/slow/*")
|
||||
.withServlet(new ServletHolder(DebugServlet.class), "/debug/*")
|
||||
.withSSLConfig(sslConfig)
|
||||
.build();
|
||||
createJetty(legacyExampleCollection1SolrHome(), jettyConfig);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -19,10 +19,12 @@ package org.apache.solr.client.solrj.impl;
|
|||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.solr.SolrJettyTestBase;
|
||||
import org.apache.solr.client.solrj.embedded.JettyConfig;
|
||||
import org.apache.solr.client.solrj.request.JavaBinUpdateRequestCodec;
|
||||
import org.apache.solr.client.solrj.request.UpdateRequest;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.common.util.SolrjNamedThreadFactory;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -123,9 +125,11 @@ public class ConcurrentUpdateSolrClientTest extends SolrJettyTestBase {
|
|||
|
||||
@BeforeClass
|
||||
public static void beforeTest() throws Exception {
|
||||
createJetty(legacyExampleCollection1SolrHome(), null, null);
|
||||
jetty.getDispatchFilter().getServletHandler()
|
||||
.addServletWithMapping(TestServlet.class, "/cuss/*");
|
||||
JettyConfig jettyConfig = JettyConfig.builder()
|
||||
.withServlet(new ServletHolder(TestServlet.class), "/cuss/*")
|
||||
.withSSLConfig(sslConfig)
|
||||
.build();
|
||||
createJetty(legacyExampleCollection1SolrHome(), jettyConfig);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -25,6 +25,8 @@ import org.apache.solr.SolrTestCaseJ4;
|
|||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.embedded.JettyConfig;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -32,9 +34,11 @@ import org.junit.Test;
|
|||
public class ExternalHttpClientTest extends SolrJettyTestBase {
|
||||
@BeforeClass
|
||||
public static void beforeTest() throws Exception {
|
||||
createJetty(legacyExampleCollection1SolrHome(), null, null);
|
||||
jetty.getDispatchFilter().getServletHandler()
|
||||
.addServletWithMapping(BasicHttpSolrClientTest.SlowServlet.class, "/slow/*");
|
||||
JettyConfig jettyConfig = JettyConfig.builder()
|
||||
.withServlet(new ServletHolder(BasicHttpSolrClientTest.SlowServlet.class), "/slow/*")
|
||||
.withSSLConfig(sslConfig)
|
||||
.build();
|
||||
createJetty(legacyExampleCollection1SolrHome(), jettyConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -55,7 +55,7 @@ public class NoOpResponseParserTest extends SolrJettyTestBase {
|
|||
|
||||
@BeforeClass
|
||||
public static void beforeTest() throws Exception {
|
||||
createJetty(legacyExampleCollection1SolrHome(), null, null);
|
||||
createJetty(legacyExampleCollection1SolrHome());
|
||||
}
|
||||
|
||||
@Before
|
||||
|
|
|
@ -310,8 +310,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
|
|||
Path jettyHome = testDir.toPath().resolve("control");
|
||||
File jettyHomeFile = jettyHome.toFile();
|
||||
seedSolrHome(jettyHomeFile);
|
||||
seedCoreRootDirWithDefaultTestCore(jettyHome);
|
||||
System.setProperty("coreRootDirectory", jettyHome.toString());
|
||||
seedCoreRootDirWithDefaultTestCore(jettyHome.resolve("cores"));
|
||||
JettySolrRunner jetty = createJetty(jettyHomeFile, null, null, getSolrConfigFile(), getSchemaFile());
|
||||
return jetty;
|
||||
}
|
||||
|
@ -331,10 +330,8 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
|
|||
Path jettyHome = testDir.toPath().resolve(shardname);
|
||||
File jettyHomeFile = jettyHome.toFile();
|
||||
seedSolrHome(jettyHomeFile);
|
||||
seedCoreRootDirWithDefaultTestCore(jettyHome);
|
||||
System.setProperty("coreRootDirectory", jettyHome.toString());
|
||||
seedCoreRootDirWithDefaultTestCore(jettyHome.resolve("cores"));
|
||||
JettySolrRunner j = createJetty(jettyHomeFile, null, null, getSolrConfigFile(), getSchemaFile());
|
||||
|
||||
jettys.add(j);
|
||||
clients.add(createNewSolrClient(j.getLocalPort()));
|
||||
String shardStr = buildUrl(j.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME;
|
||||
|
@ -396,18 +393,29 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
|
|||
|
||||
public JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, String solrConfigOverride, String schemaOverride, boolean explicitCoreNodeName) throws Exception {
|
||||
|
||||
JettySolrRunner jetty = new JettySolrRunner(solrHome.getAbsolutePath(), solrConfigOverride, schemaOverride, JettyConfig.builder()
|
||||
Properties props = new Properties();
|
||||
if (solrConfigOverride != null)
|
||||
props.setProperty("solrconfig", solrConfigOverride);
|
||||
if (schemaOverride != null)
|
||||
props.setProperty("schema", schemaOverride);
|
||||
if (shardList != null)
|
||||
props.setProperty("shards", shardList);
|
||||
if (dataDir != null) {
|
||||
props.setProperty("solr.data.dir", dataDir);
|
||||
}
|
||||
if (explicitCoreNodeName) {
|
||||
props.setProperty("coreNodeName", Integer.toString(nodeCnt.incrementAndGet()));
|
||||
}
|
||||
props.setProperty("coreRootDirectory", solrHome.toPath().resolve("cores").toAbsolutePath().toString());
|
||||
|
||||
JettySolrRunner jetty = new JettySolrRunner(solrHome.getAbsolutePath(), props, JettyConfig.builder()
|
||||
.stopAtShutdown(true)
|
||||
.setContext(context)
|
||||
.withFilters(getExtraRequestFilters())
|
||||
.withServlets(getExtraServlets())
|
||||
.withSSLConfig(sslConfig)
|
||||
.build());
|
||||
jetty.setShards(shardList);
|
||||
jetty.setDataDir(dataDir);
|
||||
if (explicitCoreNodeName) {
|
||||
jetty.setCoreNodeName(Integer.toString(nodeCnt.incrementAndGet()));
|
||||
}
|
||||
|
||||
jetty.start();
|
||||
|
||||
return jetty;
|
||||
|
@ -1051,7 +1059,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
|
|||
* directory with the contents of {@link #getSolrHome} and ensures that the proper {@link #getSolrXml}
|
||||
* file is in place.
|
||||
*/
|
||||
private void seedSolrHome(File jettyHome) throws IOException {
|
||||
protected void seedSolrHome(File jettyHome) throws IOException {
|
||||
FileUtils.copyDirectory(new File(getSolrHome()), jettyHome);
|
||||
String solrxml = getSolrXml();
|
||||
if (solrxml != null) {
|
||||
|
@ -1087,7 +1095,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
|
|||
coreProperties.setProperty("schema", "${schema:schema.xml}");
|
||||
coreProperties.setProperty("coreNodeName", "${coreNodeName:}");
|
||||
|
||||
writeCoreProperties(jettyHome.toPath().resolve("cores/collection1"), coreProperties, "collection1");
|
||||
writeCoreProperties(jettyHome.toPath().resolve("cores").resolve("collection1"), coreProperties, "collection1");
|
||||
|
||||
// <core name="collection1" instanceDir="collection1" shard="${shard:}"
|
||||
// collection="${collection:collection1}" config="${solrconfig:solrconfig.xml}" schema="${schema:schema.xml}"
|
||||
|
|
|
@ -57,22 +57,6 @@ abstract public class SolrJettyTestBase extends SolrTestCaseJ4
|
|||
boolean stopAtShutdown, SortedMap<ServletHolder,String> extraServlets)
|
||||
throws Exception {
|
||||
// creates the data dir
|
||||
initCore(null, null, solrHome);
|
||||
|
||||
Path coresDir = createTempDir().resolve("cores");
|
||||
|
||||
System.setProperty("coreRootDirectory", coresDir.toString());
|
||||
System.setProperty("configSetBaseDir", solrHome);
|
||||
|
||||
Properties props = new Properties();
|
||||
props.setProperty("name", DEFAULT_TEST_CORENAME);
|
||||
props.setProperty("configSet", "collection1");
|
||||
props.setProperty("config", "${solrconfig:solrconfig.xml}");
|
||||
props.setProperty("schema", "${schema:schema.xml}");
|
||||
|
||||
writeCoreProperties(coresDir.resolve("core"), props, "RestTestBase");
|
||||
|
||||
ignoreException("maxWarmingSearchers");
|
||||
|
||||
context = context==null ? "/solr" : context;
|
||||
SolrJettyTestBase.context = context;
|
||||
|
@ -84,23 +68,57 @@ abstract public class SolrJettyTestBase extends SolrTestCaseJ4
|
|||
.withSSLConfig(sslConfig)
|
||||
.build();
|
||||
|
||||
jetty = new JettySolrRunner(solrHome, configFile, schemaFile, jettyConfig);
|
||||
|
||||
// this sets the property for jetty starting SolrDispatchFilter
|
||||
Properties nodeProps = new Properties();
|
||||
if (configFile != null)
|
||||
nodeProps.setProperty("solrconfig", configFile);
|
||||
if (schemaFile != null)
|
||||
nodeProps.setProperty("schema", schemaFile);
|
||||
if (System.getProperty("solr.data.dir") == null && System.getProperty("solr.hdfs.home") == null) {
|
||||
jetty.setDataDir(createTempDir().toFile().getCanonicalPath());
|
||||
nodeProps.setProperty("solr.data.dir", createTempDir().toFile().getCanonicalPath());
|
||||
}
|
||||
|
||||
jetty.start();
|
||||
port = jetty.getLocalPort();
|
||||
log.info("Jetty Assigned Port#" + port);
|
||||
return jetty;
|
||||
|
||||
return createJetty(solrHome, nodeProps, jettyConfig);
|
||||
}
|
||||
|
||||
public static JettySolrRunner createJetty(String solrHome, String configFile, String context) throws Exception {
|
||||
return createJetty(solrHome, configFile, null, context, true, null);
|
||||
}
|
||||
|
||||
public static JettySolrRunner createJetty(String solrHome, JettyConfig jettyConfig) throws Exception {
|
||||
return createJetty(solrHome, new Properties(), jettyConfig);
|
||||
}
|
||||
|
||||
public static JettySolrRunner createJetty(String solrHome) throws Exception {
|
||||
return createJetty(solrHome, new Properties(), JettyConfig.builder().withSSLConfig(sslConfig).build());
|
||||
}
|
||||
|
||||
public static JettySolrRunner createJetty(String solrHome, Properties nodeProperties, JettyConfig jettyConfig) throws Exception {
|
||||
|
||||
initCore(null, null, solrHome);
|
||||
|
||||
Path coresDir = createTempDir().resolve("cores");
|
||||
|
||||
Properties props = new Properties();
|
||||
props.setProperty("name", DEFAULT_TEST_CORENAME);
|
||||
props.setProperty("configSet", "collection1");
|
||||
props.setProperty("config", "${solrconfig:solrconfig.xml}");
|
||||
props.setProperty("schema", "${schema:schema.xml}");
|
||||
|
||||
writeCoreProperties(coresDir.resolve("core"), props, "RestTestBase");
|
||||
|
||||
Properties nodeProps = new Properties(nodeProperties);
|
||||
nodeProps.setProperty("coreRootDirectory", coresDir.toString());
|
||||
nodeProps.setProperty("configSetBaseDir", solrHome);
|
||||
|
||||
ignoreException("maxWarmingSearchers");
|
||||
|
||||
jetty = new JettySolrRunner(solrHome, nodeProps, jettyConfig);
|
||||
jetty.start();
|
||||
port = jetty.getLocalPort();
|
||||
log.info("Jetty Assigned Port#" + port);
|
||||
return jetty;
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterSolrJettyTestBase() throws Exception {
|
||||
|
|
|
@ -76,6 +76,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
@ -281,7 +282,6 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
|
|||
File controlJettyDir = createTempDir("control").toFile();
|
||||
setupJettySolrHome(controlJettyDir);
|
||||
|
||||
System.setProperty("coreRootDirectory", controlJettyDir.toPath().resolve("cores").toString());
|
||||
controlJetty = createJetty(controlJettyDir, useJettyDataDir ? getDataDir(testDir
|
||||
+ "/control/data") : null); // don't pass shard name... let it default to
|
||||
// "shard1"
|
||||
|
@ -391,8 +391,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
|
|||
|
||||
jettyDir.mkdirs();
|
||||
setupJettySolrHome(jettyDir);
|
||||
log.info("create jetty " + i);
|
||||
System.setProperty("coreRootDirectory", jettyDir.toPath().resolve("cores").toString());
|
||||
log.info("create jetty {} in directory {}", i, jettyDir);
|
||||
JettySolrRunner j = createJetty(jettyDir, useJettyDataDir ? getDataDir(testDir + "/jetty"
|
||||
+ cnt) : null, null, "solrconfig.xml", null);
|
||||
jettys.add(j);
|
||||
|
@ -453,13 +452,13 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
|
|||
|
||||
int cnt = this.jettyIntCntr.incrementAndGet();
|
||||
|
||||
File jettyDir = createTempDir("jetty").toFile();
|
||||
jettyDir.mkdirs();
|
||||
org.apache.commons.io.FileUtils.copyDirectory(new File(getSolrHome()), jettyDir);
|
||||
JettySolrRunner j = createJetty(jettyDir, testDir + "/jetty" + cnt, shard, "solrconfig.xml", null);
|
||||
jettys.add(j);
|
||||
SolrClient client = createNewSolrClient(j.getLocalPort());
|
||||
clients.add(client);
|
||||
File jettyDir = createTempDir("jetty").toFile();
|
||||
jettyDir.mkdirs();
|
||||
setupJettySolrHome(jettyDir);
|
||||
JettySolrRunner j = createJetty(jettyDir, testDir + "/jetty" + cnt, shard, "solrconfig.xml", null);
|
||||
jettys.add(j);
|
||||
SolrClient client = createNewSolrClient(j.getLocalPort());
|
||||
clients.add(client);
|
||||
|
||||
int retries = 60;
|
||||
while (--retries >= 0) {
|
||||
|
@ -502,11 +501,15 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
|
|||
.withFilters(getExtraRequestFilters())
|
||||
.withSSLConfig(sslConfig)
|
||||
.build();
|
||||
|
||||
JettySolrRunner jetty = new JettySolrRunner(getSolrHome(), solrConfigOverride, null, jettyconfig);
|
||||
|
||||
jetty.setShards(shardList);
|
||||
jetty.setDataDir(getDataDir(dataDir));
|
||||
Properties props = new Properties();
|
||||
props.setProperty("solr.data.dir", getDataDir(dataDir));
|
||||
props.setProperty("shards", shardList);
|
||||
props.setProperty("solr.ulog.dir", ulogDir);
|
||||
props.setProperty("solrconfig", solrConfigOverride);
|
||||
|
||||
JettySolrRunner jetty = new JettySolrRunner(getSolrHome(), props, jettyconfig);
|
||||
|
||||
jetty.start();
|
||||
|
||||
return jetty;
|
||||
|
@ -525,11 +528,19 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
|
|||
.withFilters(getExtraRequestFilters())
|
||||
.withSSLConfig(sslConfig)
|
||||
.build();
|
||||
|
||||
JettySolrRunner jetty = new JettySolrRunner(solrHome.getPath(), solrConfigOverride, schemaOverride, jettyconfig);
|
||||
|
||||
jetty.setShards(shardList);
|
||||
jetty.setDataDir(getDataDir(dataDir));
|
||||
Properties props = new Properties();
|
||||
if (solrConfigOverride != null)
|
||||
props.setProperty("solrconfig", solrConfigOverride);
|
||||
if (schemaOverride != null)
|
||||
props.setProperty("schema", schemaOverride);
|
||||
if (shardList != null)
|
||||
props.setProperty("shards", shardList);
|
||||
if (dataDir != null)
|
||||
props.setProperty("solr.data.dir", getDataDir(dataDir));
|
||||
props.setProperty("coreRootDirectory", solrHome.toPath().resolve("cores").toAbsolutePath().toString());
|
||||
|
||||
JettySolrRunner jetty = new JettySolrRunner(solrHome.getPath(), props, jettyconfig);
|
||||
jetty.start();
|
||||
|
||||
return jetty;
|
||||
|
@ -552,9 +563,18 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
|
|||
.withSSLConfig(sslConfig)
|
||||
.build();
|
||||
|
||||
JettySolrRunner jetty = new JettySolrRunner(solrHome.getPath(), solrConfigOverride, schemaOverride, jettyconfig);
|
||||
jetty.setShards(shardList);
|
||||
jetty.setDataDir(getDataDir(dataDir));
|
||||
Properties props = new Properties();
|
||||
if (solrConfigOverride != null)
|
||||
props.setProperty("solrconfig", solrConfigOverride);
|
||||
if (schemaOverride != null)
|
||||
props.setProperty("schema", schemaOverride);
|
||||
if (shardList != null)
|
||||
props.setProperty("shards", shardList);
|
||||
if (dataDir != null)
|
||||
props.setProperty("solr.data.dir", getDataDir(dataDir));
|
||||
props.setProperty("coreRootDirectory", solrHome.toPath().resolve("cores").toAbsolutePath().toString());
|
||||
|
||||
JettySolrRunner jetty = new JettySolrRunner(solrHome.getPath(), props, jettyconfig);
|
||||
|
||||
SocketProxy proxy = new SocketProxy(0, sslConfig != null && sslConfig.isSSLMode());
|
||||
jetty.setProxyPort(proxy.getListenPort());
|
||||
|
|
|
@ -51,6 +51,7 @@ import java.io.StringWriter;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* This class provides a simple harness that may be useful when
|
||||
|
@ -169,7 +170,7 @@ public class TestHarness extends BaseTestHarness {
|
|||
* @param config the ConfigSolr to use
|
||||
*/
|
||||
public TestHarness(NodeConfig config, CoresLocator coresLocator) {
|
||||
container = new CoreContainer(config, coresLocator);
|
||||
container = new CoreContainer(config, new Properties(), coresLocator);
|
||||
container.load();
|
||||
updater = new UpdateRequestHandler();
|
||||
updater.init(null);
|
||||
|
|
Loading…
Reference in New Issue