mirror of https://github.com/apache/lucene.git
SOLR-4394: phase 2, promoted SSL randomization logic up to SolrJettyTestBase
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1447885 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dc070b4ab8
commit
881c0b21eb
|
@ -26,7 +26,6 @@ import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.client.methods.HttpHead;
|
import org.apache.http.client.methods.HttpHead;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.client.methods.HttpRequestBase;
|
import org.apache.http.client.methods.HttpRequestBase;
|
||||||
import org.apache.http.client.utils.URIUtils;
|
|
||||||
import org.apache.http.client.utils.URLEncodedUtils;
|
import org.apache.http.client.utils.URLEncodedUtils;
|
||||||
import org.apache.http.message.BasicNameValuePair;
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
@ -49,10 +48,8 @@ public abstract class CacheHeaderTestBase extends SolrJettyTestBase {
|
||||||
qparams.add(new BasicNameValuePair(params[i * 2], params[i * 2 + 1]));
|
qparams.add(new BasicNameValuePair(params[i * 2], params[i * 2 + 1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
java.net.URI uri = URIUtils.createURI("http",
|
URI uri = URI.create(httpserver.getBaseURL() + "/select?" +
|
||||||
new URI(httpserver.getBaseURL()).getHost(),
|
URLEncodedUtils.format(qparams, "UTF-8"));
|
||||||
new URI(httpserver.getBaseURL()).getPort(), "/solr/select",
|
|
||||||
URLEncodedUtils.format(qparams, "UTF-8"), null);
|
|
||||||
|
|
||||||
if ("GET".equals(method)) {
|
if ("GET".equals(method)) {
|
||||||
m = new HttpGet(uri);
|
m = new HttpGet(uri);
|
||||||
|
@ -73,10 +70,9 @@ public abstract class CacheHeaderTestBase extends SolrJettyTestBase {
|
||||||
for(int i=0;i<params.length/2;i++) {
|
for(int i=0;i<params.length/2;i++) {
|
||||||
qparams.add(new BasicNameValuePair(params[i*2], params[i*2+1]));
|
qparams.add(new BasicNameValuePair(params[i*2], params[i*2+1]));
|
||||||
}
|
}
|
||||||
java.net.URI uri = URIUtils.createURI("http",
|
|
||||||
new URI(httpserver.getBaseURL()).getHost(),
|
URI uri = URI.create(httpserver.getBaseURL() + "/update?" +
|
||||||
new URI(httpserver.getBaseURL()).getPort(), "/solr/update",
|
URLEncodedUtils.format(qparams, "UTF-8"));
|
||||||
URLEncodedUtils.format(qparams, "UTF-8"), null);
|
|
||||||
|
|
||||||
if ("GET".equals(method)) {
|
if ("GET".equals(method)) {
|
||||||
m=new HttpGet(uri);
|
m=new HttpGet(uri);
|
||||||
|
|
|
@ -25,6 +25,8 @@ import org.apache.solr.client.solrj.response.QueryResponse;
|
||||||
import org.apache.solr.client.solrj.response.UpdateResponse;
|
import org.apache.solr.client.solrj.response.UpdateResponse;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -32,6 +34,7 @@ import org.junit.Test;
|
||||||
*/
|
*/
|
||||||
public abstract class LargeVolumeTestBase extends SolrJettyTestBase
|
public abstract class LargeVolumeTestBase extends SolrJettyTestBase
|
||||||
{
|
{
|
||||||
|
private static Logger log = LoggerFactory.getLogger(LargeVolumeTestBase.class);
|
||||||
|
|
||||||
// for real load testing, make these numbers bigger
|
// for real load testing, make these numbers bigger
|
||||||
static final int numdocs = 100; //1000 * 1000;
|
static final int numdocs = 100; //1000 * 1000;
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class SolrExampleBinaryTest extends SolrExampleTests {
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// setup the server...
|
// setup the server...
|
||||||
String url = "http://127.0.0.1:"+port+context;
|
String url = jetty.getBaseUrl().toString();
|
||||||
HttpSolrServer s = new HttpSolrServer( url );
|
HttpSolrServer s = new HttpSolrServer( url );
|
||||||
s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
|
s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
|
||||||
s.setDefaultMaxConnectionsPerHost(100);
|
s.setDefaultMaxConnectionsPerHost(100);
|
||||||
|
|
|
@ -61,6 +61,8 @@ import org.apache.solr.common.params.AnalysisParams;
|
||||||
import org.apache.solr.common.params.CommonParams;
|
import org.apache.solr.common.params.CommonParams;
|
||||||
import org.apache.solr.common.params.FacetParams;
|
import org.apache.solr.common.params.FacetParams;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This should include tests against the example solr config
|
* This should include tests against the example solr config
|
||||||
|
@ -72,6 +74,8 @@ import org.junit.Test;
|
||||||
*/
|
*/
|
||||||
abstract public class SolrExampleTests extends SolrJettyTestBase
|
abstract public class SolrExampleTests extends SolrJettyTestBase
|
||||||
{
|
{
|
||||||
|
private static Logger log = LoggerFactory.getLogger(SolrExampleTests.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ignoreException("uniqueKey");
|
ignoreException("uniqueKey");
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class SolrExampleXMLTest extends SolrExampleTests {
|
||||||
@Override
|
@Override
|
||||||
public SolrServer createNewSolrServer() {
|
public SolrServer createNewSolrServer() {
|
||||||
try {
|
try {
|
||||||
String url = "http://127.0.0.1:" + port + context;
|
String url = jetty.getBaseUrl().toString();
|
||||||
HttpSolrServer s = new HttpSolrServer(url);
|
HttpSolrServer s = new HttpSolrServer(url);
|
||||||
s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
|
s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
|
||||||
s.setDefaultMaxConnectionsPerHost(100);
|
s.setDefaultMaxConnectionsPerHost(100);
|
||||||
|
|
|
@ -21,18 +21,10 @@ import org.apache.solr.client.solrj.SolrExampleTests;
|
||||||
import org.apache.solr.client.solrj.impl.HttpSolrServer;
|
import org.apache.solr.client.solrj.impl.HttpSolrServer;
|
||||||
import org.apache.solr.util.ExternalPaths;
|
import org.apache.solr.util.ExternalPaths;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO? perhaps use:
|
* TODO? perhaps use:
|
||||||
* http://docs.codehaus.org/display/JETTY/ServletTester
|
* http://docs.codehaus.org/display/JETTY/ServletTester
|
||||||
|
@ -41,73 +33,11 @@ import org.slf4j.LoggerFactory;
|
||||||
*/
|
*/
|
||||||
public class SolrExampleJettyTest extends SolrExampleTests {
|
public class SolrExampleJettyTest extends SolrExampleTests {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(SolrExampleJettyTest.class);
|
|
||||||
|
|
||||||
private static boolean manageSslProps = true;
|
|
||||||
|
|
||||||
private static final File TEST_KEYSTORE = new File(ExternalPaths.SOURCE_HOME,
|
|
||||||
"example/etc/solrtest.keystore");
|
|
||||||
|
|
||||||
private static final Map<String,String> SSL_PROPS = new HashMap<String,String>();
|
|
||||||
static {
|
|
||||||
SSL_PROPS.put("tests.jettySsl","false");
|
|
||||||
SSL_PROPS.put("tests.jettySsl.clientAuth","false");
|
|
||||||
SSL_PROPS.put("javax.net.ssl.keyStore", TEST_KEYSTORE.getAbsolutePath());
|
|
||||||
SSL_PROPS.put("javax.net.ssl.keyStorePassword","secret");
|
|
||||||
SSL_PROPS.put("javax.net.ssl.trustStore", TEST_KEYSTORE.getAbsolutePath());
|
|
||||||
SSL_PROPS.put("javax.net.ssl.trustStorePassword","secret");
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeTest() throws Exception {
|
public static void beforeTest() throws Exception {
|
||||||
|
|
||||||
// // //
|
|
||||||
|
|
||||||
// :TODO: SOLR-4394 promote SSL up to SolrJettyTestBase?
|
|
||||||
|
|
||||||
// consume the same amount of random no matter what
|
|
||||||
final boolean trySsl = random().nextBoolean();
|
|
||||||
final boolean trySslClientAuth = random().nextBoolean();
|
|
||||||
|
|
||||||
// only randomize SSL if none of the SSL_PROPS are already set
|
|
||||||
final Map<Object,Object> sysprops = System.getProperties();
|
|
||||||
for (String prop : SSL_PROPS.keySet()) {
|
|
||||||
if (sysprops.containsKey(prop)) {
|
|
||||||
log.info("System property explicitly set, so skipping randomized ssl properties: " + prop);
|
|
||||||
manageSslProps = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assertTrue("test keystore does not exist, can't be used for randomized " +
|
|
||||||
"ssl testing: " + TEST_KEYSTORE.getAbsolutePath(),
|
|
||||||
TEST_KEYSTORE.exists() );
|
|
||||||
|
|
||||||
if (manageSslProps) {
|
|
||||||
log.info("Randomized ssl ({}) and clientAuth ({})", trySsl, trySslClientAuth);
|
|
||||||
for (String prop : SSL_PROPS.keySet()) {
|
|
||||||
System.setProperty(prop, SSL_PROPS.get(prop));
|
|
||||||
}
|
|
||||||
// now explicitly re-set the two random values
|
|
||||||
System.setProperty("tests.jettySsl", String.valueOf(trySsl));
|
|
||||||
System.setProperty("tests.jettySsl.clientAuth", String.valueOf(trySslClientAuth));
|
|
||||||
}
|
|
||||||
// // //
|
|
||||||
|
|
||||||
|
|
||||||
createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
|
createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
|
||||||
public static void afterTest() throws Exception {
|
|
||||||
if (manageSslProps) {
|
|
||||||
for (String prop : SSL_PROPS.keySet()) {
|
|
||||||
System.clearProperty(prop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBadSetup()
|
public void testBadSetup()
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,7 +55,8 @@ public class SolrExampleStreamingTest extends SolrExampleTests {
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// setup the server...
|
// setup the server...
|
||||||
String url = "http://127.0.0.1:"+port+context; // smaller queue size hits locks more often
|
String url = jetty.getBaseUrl().toString();
|
||||||
|
// smaller queue size hits locks more often
|
||||||
ConcurrentUpdateSolrServer s = new ConcurrentUpdateSolrServer( url, 2, 5 ) {
|
ConcurrentUpdateSolrServer s = new ConcurrentUpdateSolrServer( url, 2, 5 ) {
|
||||||
|
|
||||||
public Throwable lastError = null;
|
public Throwable lastError = null;
|
||||||
|
@ -79,7 +80,7 @@ public class SolrExampleStreamingTest extends SolrExampleTests {
|
||||||
// SOLR-3903
|
// SOLR-3903
|
||||||
final List<Throwable> failures = new ArrayList<Throwable>();
|
final List<Throwable> failures = new ArrayList<Throwable>();
|
||||||
ConcurrentUpdateSolrServer s = new ConcurrentUpdateSolrServer
|
ConcurrentUpdateSolrServer s = new ConcurrentUpdateSolrServer
|
||||||
("http://127.0.0.1:"+port+context, 2, 2) {
|
(jetty.getBaseUrl().toString(), 2, 2) {
|
||||||
@Override
|
@Override
|
||||||
public void handleError(Throwable ex) {
|
public void handleError(Throwable ex) {
|
||||||
failures.add(ex);
|
failures.add(ex);
|
||||||
|
|
|
@ -147,8 +147,8 @@ public class BasicHttpSolrServerTest extends SolrJettyTestBase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTimeout() throws Exception {
|
public void testTimeout() throws Exception {
|
||||||
HttpSolrServer server = new HttpSolrServer("http://127.0.0.1:"
|
HttpSolrServer server = new HttpSolrServer(jetty.getBaseUrl().toString() +
|
||||||
+ jetty.getLocalPort() + "/solr/slow/foo");
|
"/slow/foo");
|
||||||
SolrQuery q = new SolrQuery("*:*");
|
SolrQuery q = new SolrQuery("*:*");
|
||||||
server.setSoTimeout(2000);
|
server.setSoTimeout(2000);
|
||||||
try {
|
try {
|
||||||
|
@ -163,8 +163,8 @@ public class BasicHttpSolrServerTest extends SolrJettyTestBase {
|
||||||
@Test
|
@Test
|
||||||
public void testQuery(){
|
public void testQuery(){
|
||||||
DebugServlet.clear();
|
DebugServlet.clear();
|
||||||
HttpSolrServer server = new HttpSolrServer("http://127.0.0.1:"
|
HttpSolrServer server = new HttpSolrServer(jetty.getBaseUrl().toString() +
|
||||||
+ jetty.getLocalPort() + "/solr/debug/foo");
|
"/debug/foo");
|
||||||
SolrQuery q = new SolrQuery("foo");
|
SolrQuery q = new SolrQuery("foo");
|
||||||
q.setParam("a", "\u1234");
|
q.setParam("a", "\u1234");
|
||||||
try {
|
try {
|
||||||
|
@ -250,8 +250,8 @@ public class BasicHttpSolrServerTest extends SolrJettyTestBase {
|
||||||
@Test
|
@Test
|
||||||
public void testDelete(){
|
public void testDelete(){
|
||||||
DebugServlet.clear();
|
DebugServlet.clear();
|
||||||
HttpSolrServer server = new HttpSolrServer("http://127.0.0.1:"
|
HttpSolrServer server = new HttpSolrServer(jetty.getBaseUrl().toString() +
|
||||||
+ jetty.getLocalPort() + "/solr/debug/foo");
|
"/debug/foo");
|
||||||
try {
|
try {
|
||||||
server.deleteById("id");
|
server.deleteById("id");
|
||||||
} catch (Throwable t) {}
|
} catch (Throwable t) {}
|
||||||
|
@ -291,8 +291,8 @@ public class BasicHttpSolrServerTest extends SolrJettyTestBase {
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate(){
|
public void testUpdate(){
|
||||||
DebugServlet.clear();
|
DebugServlet.clear();
|
||||||
HttpSolrServer server = new HttpSolrServer("http://127.0.0.1:"
|
HttpSolrServer server = new HttpSolrServer(jetty.getBaseUrl().toString() +
|
||||||
+ jetty.getLocalPort() + "/solr/debug/foo");
|
"/debug/foo");
|
||||||
UpdateRequest req = new UpdateRequest();
|
UpdateRequest req = new UpdateRequest();
|
||||||
req.add(new SolrInputDocument());
|
req.add(new SolrInputDocument());
|
||||||
req.setParam("a", "\u1234");
|
req.setParam("a", "\u1234");
|
||||||
|
@ -352,8 +352,8 @@ public class BasicHttpSolrServerTest extends SolrJettyTestBase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRedirect() throws Exception {
|
public void testRedirect() throws Exception {
|
||||||
HttpSolrServer server = new HttpSolrServer("http://127.0.0.1:"
|
HttpSolrServer server = new HttpSolrServer(jetty.getBaseUrl().toString() +
|
||||||
+ jetty.getLocalPort() + "/solr/redirect/foo");
|
"/redirect/foo");
|
||||||
SolrQuery q = new SolrQuery("*:*");
|
SolrQuery q = new SolrQuery("*:*");
|
||||||
// default = false
|
// default = false
|
||||||
try {
|
try {
|
||||||
|
@ -373,8 +373,8 @@ public class BasicHttpSolrServerTest extends SolrJettyTestBase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompression() throws Exception {
|
public void testCompression() throws Exception {
|
||||||
HttpSolrServer server = new HttpSolrServer("http://127.0.0.1:"
|
HttpSolrServer server = new HttpSolrServer(jetty.getBaseUrl().toString() +
|
||||||
+ jetty.getLocalPort() + "/solr/debug/foo");
|
"/debug/foo");
|
||||||
SolrQuery q = new SolrQuery("*:*");
|
SolrQuery q = new SolrQuery("*:*");
|
||||||
|
|
||||||
// verify request header gets set
|
// verify request header gets set
|
||||||
|
@ -395,8 +395,8 @@ public class BasicHttpSolrServerTest extends SolrJettyTestBase {
|
||||||
assertNull(DebugServlet.headers.get("Accept-Encoding"));
|
assertNull(DebugServlet.headers.get("Accept-Encoding"));
|
||||||
|
|
||||||
// verify server compresses output
|
// verify server compresses output
|
||||||
HttpGet get = new HttpGet("http://127.0.0.1:" + jetty.getLocalPort()
|
HttpGet get = new HttpGet(jetty.getBaseUrl().toString() +
|
||||||
+ "/solr/select?q=foo&wt=xml");
|
"/select?q=foo&wt=xml");
|
||||||
get.setHeader("Accept-Encoding", "gzip");
|
get.setHeader("Accept-Encoding", "gzip");
|
||||||
HttpClient client = HttpClientUtil.createClient(null);
|
HttpClient client = HttpClientUtil.createClient(null);
|
||||||
HttpEntity entity = null;
|
HttpEntity entity = null;
|
||||||
|
@ -414,8 +414,7 @@ public class BasicHttpSolrServerTest extends SolrJettyTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify compressed response can be handled
|
// verify compressed response can be handled
|
||||||
server = new HttpSolrServer("http://127.0.0.1:" + jetty.getLocalPort()
|
server = new HttpSolrServer(jetty.getBaseUrl().toString());
|
||||||
+ "/solr");
|
|
||||||
server.setAllowCompression(true);
|
server.setAllowCompression(true);
|
||||||
q = new SolrQuery("foo");
|
q = new SolrQuery("foo");
|
||||||
QueryResponse response = server.query(q);
|
QueryResponse response = server.query(q);
|
||||||
|
@ -426,7 +425,8 @@ public class BasicHttpSolrServerTest extends SolrJettyTestBase {
|
||||||
@Test
|
@Test
|
||||||
public void testSetParametersExternalClient(){
|
public void testSetParametersExternalClient(){
|
||||||
HttpClient client = HttpClientUtil.createClient(null);
|
HttpClient client = HttpClientUtil.createClient(null);
|
||||||
HttpSolrServer server = new HttpSolrServer("http://127.0.0.1/", client);
|
HttpSolrServer server = new HttpSolrServer(jetty.getBaseUrl().toString(),
|
||||||
|
client);
|
||||||
try {
|
try {
|
||||||
server.setMaxTotalConnections(1);
|
server.setMaxTotalConnections(1);
|
||||||
fail("Operation should not succeed.");
|
fail("Operation should not succeed.");
|
||||||
|
@ -441,7 +441,8 @@ public class BasicHttpSolrServerTest extends SolrJettyTestBase {
|
||||||
@Test
|
@Test
|
||||||
public void testGetRawStream() throws SolrServerException, IOException{
|
public void testGetRawStream() throws SolrServerException, IOException{
|
||||||
HttpClient client = HttpClientUtil.createClient(null);
|
HttpClient client = HttpClientUtil.createClient(null);
|
||||||
HttpSolrServer server = new HttpSolrServer("http://127.0.0.1:" + jetty.getLocalPort() + "/solr", client, null);
|
HttpSolrServer server = new HttpSolrServer(jetty.getBaseUrl().toString(),
|
||||||
|
client, null);
|
||||||
QueryRequest req = new QueryRequest();
|
QueryRequest req = new QueryRequest();
|
||||||
NamedList response = server.request(req);
|
NamedList response = server.request(req);
|
||||||
InputStream stream = (InputStream)response.get("stream");
|
InputStream stream = (InputStream)response.get("stream");
|
||||||
|
|
|
@ -22,16 +22,71 @@ import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
|
||||||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||||
import org.apache.solr.client.solrj.impl.HttpSolrServer;
|
import org.apache.solr.client.solrj.impl.HttpSolrServer;
|
||||||
import org.apache.solr.util.ExternalPaths;
|
import org.apache.solr.util.ExternalPaths;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
abstract public class SolrJettyTestBase extends SolrTestCaseJ4
|
abstract public class SolrJettyTestBase extends SolrTestCaseJ4
|
||||||
{
|
{
|
||||||
|
private static Logger log = LoggerFactory.getLogger(SolrJettyTestBase.class);
|
||||||
|
|
||||||
// Try not introduce a dependency on the example schema or config unless you need to.
|
// Try not introduce a dependency on the example schema or config unless you need to.
|
||||||
// using configs in the test directory allows more flexibility to change "example"
|
// using configs in the test directory allows more flexibility to change "example"
|
||||||
// without breaking configs.
|
// without breaking configs.
|
||||||
|
|
||||||
public String getSolrHome() { return ExternalPaths.EXAMPLE_HOME; }
|
public String getSolrHome() { return ExternalPaths.EXAMPLE_HOME; }
|
||||||
|
|
||||||
|
private static boolean manageSslProps = true;
|
||||||
|
private static final File TEST_KEYSTORE = new File(ExternalPaths.SOURCE_HOME,
|
||||||
|
"example/etc/solrtest.keystore");
|
||||||
|
private static final Map<String,String> SSL_PROPS = new HashMap<String,String>();
|
||||||
|
static {
|
||||||
|
SSL_PROPS.put("tests.jettySsl","false");
|
||||||
|
SSL_PROPS.put("tests.jettySsl.clientAuth","false");
|
||||||
|
SSL_PROPS.put("javax.net.ssl.keyStore", TEST_KEYSTORE.getAbsolutePath());
|
||||||
|
SSL_PROPS.put("javax.net.ssl.keyStorePassword","secret");
|
||||||
|
SSL_PROPS.put("javax.net.ssl.trustStore", TEST_KEYSTORE.getAbsolutePath());
|
||||||
|
SSL_PROPS.put("javax.net.ssl.trustStorePassword","secret");
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void beforeSolrJettyTestBase() throws Exception {
|
||||||
|
|
||||||
|
// consume the same amount of random no matter what
|
||||||
|
final boolean trySsl = random().nextBoolean();
|
||||||
|
final boolean trySslClientAuth = random().nextBoolean();
|
||||||
|
|
||||||
|
// only randomize SSL if none of the SSL_PROPS are already set
|
||||||
|
final Map<Object,Object> sysprops = System.getProperties();
|
||||||
|
for (String prop : SSL_PROPS.keySet()) {
|
||||||
|
if (sysprops.containsKey(prop)) {
|
||||||
|
log.info("System property explicitly set, so skipping randomized ssl properties: " + prop);
|
||||||
|
manageSslProps = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue("test keystore does not exist, can't be used for randomized " +
|
||||||
|
"ssl testing: " + TEST_KEYSTORE.getAbsolutePath(),
|
||||||
|
TEST_KEYSTORE.exists() );
|
||||||
|
|
||||||
|
if (manageSslProps) {
|
||||||
|
log.info("Randomized ssl ({}) and clientAuth ({})", trySsl, trySslClientAuth);
|
||||||
|
for (String prop : SSL_PROPS.keySet()) {
|
||||||
|
System.setProperty(prop, SSL_PROPS.get(prop));
|
||||||
|
}
|
||||||
|
// now explicitly re-set the two random values
|
||||||
|
System.setProperty("tests.jettySsl", String.valueOf(trySsl));
|
||||||
|
System.setProperty("tests.jettySsl.clientAuth", String.valueOf(trySslClientAuth));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static JettySolrRunner jetty;
|
public static JettySolrRunner jetty;
|
||||||
public static int port;
|
public static int port;
|
||||||
public static SolrServer server = null;
|
public static SolrServer server = null;
|
||||||
|
@ -64,6 +119,11 @@ abstract public class SolrJettyTestBase extends SolrTestCaseJ4
|
||||||
jetty = null;
|
jetty = null;
|
||||||
}
|
}
|
||||||
server = null;
|
server = null;
|
||||||
|
if (manageSslProps) {
|
||||||
|
for (String prop : SSL_PROPS.keySet()) {
|
||||||
|
System.clearProperty(prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue