mirror of https://github.com/apache/lucene.git
SOLR-11793: Reduce code duplication w.r.t. RestTestHarness(es).
This commit is contained in:
parent
af41d02eae
commit
287062df37
|
@ -91,6 +91,8 @@ Other Changes
|
|||
|
||||
* SOLR-11703: Solr Should Send Log Notifications if Ulimits are too low (Kevin Cowan via Erick Eickson)
|
||||
|
||||
* SOLR-11793: Reduce code duplication w.r.t. RestTestHarness(es). (Christine Poerschke)
|
||||
|
||||
================== 7.2.0 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
|
||||
|
|
|
@ -19,12 +19,9 @@ package org.apache.solr.cloud;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.common.cloud.SolrZkClient;
|
||||
import org.apache.solr.common.util.Utils;
|
||||
|
@ -41,24 +38,6 @@ import static java.util.Arrays.asList;
|
|||
import static org.apache.solr.handler.TestSolrConfigHandlerCloud.compareValues;
|
||||
|
||||
public class TestCryptoKeys extends AbstractFullDistribZkTestBase {
|
||||
private List<RestTestHarness> restTestHarnesses = new ArrayList<>();
|
||||
|
||||
private void setupHarnesses() {
|
||||
for (final SolrClient client : clients) {
|
||||
RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient) client).getBaseURL());
|
||||
restTestHarnesses.add(harness);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void distribTearDown() throws Exception {
|
||||
super.distribTearDown();
|
||||
for (RestTestHarness r : restTestHarnesses) {
|
||||
r.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public TestCryptoKeys() {
|
||||
super();
|
||||
|
@ -68,7 +47,7 @@ public class TestCryptoKeys extends AbstractFullDistribZkTestBase {
|
|||
@Test
|
||||
public void test() throws Exception {
|
||||
System.setProperty("enable.runtime.lib", "true");
|
||||
setupHarnesses();
|
||||
setupRestTestHarnesses();
|
||||
String pk1sig = "G8LEW7uJ1is81Aqqfl3Sld3qDtOxPuVFeTLJHFJWecgDvUkmJNFXmf7nkHOVlXnDWahp1vqZf0W02VHXg37lBw==";
|
||||
String pk2sig = "pCyBQycB/0YvLVZfKLDIIqG1tFwM/awqzkp2QNpO7R3ThTqmmrj11wEJFDRLkY79efuFuQPHt40EE7jrOKoj9jLNELsfEqvU3jw9sZKiDONY+rV9Bj9QPeW8Pgt+F9Y1";
|
||||
String wrongKeySig = "xTk2hTipfpb+J5s4x3YZGOXkmHWtnJz05Vvd8RTm/Q1fbQVszR7vMk6dQ1URxX08fcg4HvxOo8g9bG2TSMOGjg==";
|
||||
|
@ -123,7 +102,7 @@ public class TestCryptoKeys extends AbstractFullDistribZkTestBase {
|
|||
String payload = "{\n" +
|
||||
"'create-requesthandler' : { 'name' : '/runtime', 'class': 'org.apache.solr.core.RuntimeLibReqHandler' , 'runtimeLib':true }" +
|
||||
"}";
|
||||
RestTestHarness client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
RestTestHarness client = randomRestTestHarness();
|
||||
TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
|
||||
|
||||
TestSolrConfigHandler.testForResponseElement(client,
|
||||
|
@ -137,7 +116,7 @@ public class TestCryptoKeys extends AbstractFullDistribZkTestBase {
|
|||
payload = "{\n" +
|
||||
"'add-runtimelib' : { 'name' : 'signedjar' ,'version':1}\n" +
|
||||
"}";
|
||||
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
client = randomRestTestHarness();
|
||||
TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
|
||||
TestSolrConfigHandler.testForResponseElement(client,
|
||||
null,
|
||||
|
@ -156,7 +135,7 @@ public class TestCryptoKeys extends AbstractFullDistribZkTestBase {
|
|||
payload = "{\n" +
|
||||
"'update-runtimelib' : { 'name' : 'signedjar' ,'version':1, 'sig': 'QKqHtd37QN02iMW9UEgvAO9g9qOOuG5vEBNkbUsN7noc2hhXKic/ABFIOYJA9PKw61mNX2EmNFXOcO3WClYdSw=='}\n" +
|
||||
"}";
|
||||
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
client = randomRestTestHarness();
|
||||
TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
|
||||
TestSolrConfigHandler.testForResponseElement(client,
|
||||
null,
|
||||
|
@ -175,7 +154,7 @@ public class TestCryptoKeys extends AbstractFullDistribZkTestBase {
|
|||
payload = "{\n" +
|
||||
"'update-runtimelib' : { 'name' : 'signedjar' ,'version':1, 'sig': 'YkTQgOtvcM/H/5EQdABGl3wjjrPhonAGlouIx59vppBy2cZEofX3qX1yZu5sPNRmJisNXEuhHN2149dxeUmk2Q=='}\n" +
|
||||
"}";
|
||||
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
client = randomRestTestHarness();
|
||||
TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
|
||||
TestSolrConfigHandler.testForResponseElement(client,
|
||||
null,
|
||||
|
@ -196,7 +175,7 @@ public class TestCryptoKeys extends AbstractFullDistribZkTestBase {
|
|||
payload = "{\n" +
|
||||
"'update-runtimelib' : { 'name' : 'signedjar' ,'version':1, 'sig': 'VJPMTxDf8Km3IBj2B5HWkIOqeM/o+HHNobOYCNA3WjrEVfOMZbMMqS1Lo7uLUUp//RZwOGkOhrUhuPNY1z2CGEIKX2/m8VGH64L14d52oSvFiwhoTDDuuyjW1TFGu35D'}\n" +
|
||||
"}";
|
||||
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
client = randomRestTestHarness();
|
||||
TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
|
||||
TestSolrConfigHandler.testForResponseElement(client,
|
||||
null,
|
||||
|
|
|
@ -17,11 +17,8 @@
|
|||
|
||||
package org.apache.solr.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
|
||||
import org.apache.solr.handler.TestBlobHandler;
|
||||
|
@ -33,32 +30,16 @@ import org.junit.Test;
|
|||
* Created by caomanhdat on 6/3/16.
|
||||
*/
|
||||
public class TestCustomStream extends AbstractFullDistribZkTestBase {
|
||||
private List<RestTestHarness> restTestHarnesses = new ArrayList<>();
|
||||
|
||||
private void setupHarnesses() {
|
||||
for (final SolrClient client : clients) {
|
||||
RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient)client).getBaseURL());
|
||||
restTestHarnesses.add(harness);
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void enableRuntimeLib() throws Exception {
|
||||
System.setProperty("enable.runtime.lib", "true");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void distribTearDown() throws Exception {
|
||||
super.distribTearDown();
|
||||
for (RestTestHarness r : restTestHarnesses) {
|
||||
r.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDynamicLoadingCustomStream() throws Exception {
|
||||
System.setProperty("enable.runtime.lib", "true");
|
||||
setupHarnesses();
|
||||
setupRestTestHarnesses();
|
||||
|
||||
String blobName = "colltest";
|
||||
|
||||
|
@ -73,7 +54,7 @@ public class TestCustomStream extends AbstractFullDistribZkTestBase {
|
|||
"'create-expressible' : { 'name' : 'hello', 'class': 'org.apache.solr.core.HelloStream' }\n" +
|
||||
"}";
|
||||
|
||||
RestTestHarness client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
RestTestHarness client = randomRestTestHarness();
|
||||
TestSolrConfigHandler.runConfigCommand(client,"/config",payload);
|
||||
TestSolrConfigHandler.testForResponseElement(client,
|
||||
null,
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.solr.core;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
|
||||
import org.apache.solr.handler.TestBlobHandler;
|
||||
|
@ -30,9 +29,7 @@ import java.io.FileInputStream;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
@ -41,32 +38,16 @@ import static java.util.Arrays.asList;
|
|||
import static org.apache.solr.handler.TestSolrConfigHandlerCloud.compareValues;
|
||||
|
||||
public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
|
||||
private List<RestTestHarness> restTestHarnesses = new ArrayList<>();
|
||||
|
||||
private void setupHarnesses() {
|
||||
for (final SolrClient client : clients) {
|
||||
RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient)client).getBaseURL());
|
||||
restTestHarnesses.add(harness);
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void enableRuntimeLib() throws Exception {
|
||||
System.setProperty("enable.runtime.lib", "true");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void distribTearDown() throws Exception {
|
||||
super.distribTearDown();
|
||||
for (RestTestHarness r : restTestHarnesses) {
|
||||
r.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDynamicLoading() throws Exception {
|
||||
System.setProperty("enable.runtime.lib", "true");
|
||||
setupHarnesses();
|
||||
setupRestTestHarnesses();
|
||||
|
||||
String blobName = "colltest";
|
||||
boolean success = false;
|
||||
|
@ -78,7 +59,7 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
|
|||
String payload = "{\n" +
|
||||
"'add-runtimelib' : { 'name' : 'colltest' ,'version':1}\n" +
|
||||
"}";
|
||||
RestTestHarness client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
RestTestHarness client = randomRestTestHarness();
|
||||
TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
|
||||
TestSolrConfigHandler.testForResponseElement(client,
|
||||
null,
|
||||
|
@ -92,7 +73,7 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
|
|||
"'create-requesthandler' : { 'name' : '/test1', 'class': 'org.apache.solr.core.BlobStoreTestRequestHandler' ,registerPath: '/solr,/v2', 'runtimeLib' : true }\n" +
|
||||
"}";
|
||||
|
||||
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
client = randomRestTestHarness();
|
||||
TestSolrConfigHandler.runConfigCommand(client,"/config",payload);
|
||||
TestSolrConfigHandler.testForResponseElement(client,
|
||||
null,
|
||||
|
@ -156,7 +137,7 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
|
|||
"'create-searchcomponent' : { 'name' : 'get', 'class': 'org.apache.solr.core.RuntimeLibSearchComponent' , 'runtimeLib':true }," +
|
||||
"'create-queryResponseWriter' : { 'name' : 'json1', 'class': 'org.apache.solr.core.RuntimeLibResponseWriter' , 'runtimeLib':true }" +
|
||||
"}";
|
||||
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
client = randomRestTestHarness();
|
||||
TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
|
||||
|
||||
Map result = TestSolrConfigHandler.testForResponseElement(client,
|
||||
|
@ -197,7 +178,7 @@ public class TestDynamicLoading extends AbstractFullDistribZkTestBase {
|
|||
payload = "{\n" +
|
||||
"'update-runtimelib' : { 'name' : 'colltest' ,'version':2}\n" +
|
||||
"}";
|
||||
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
client = randomRestTestHarness();
|
||||
TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
|
||||
TestSolrConfigHandler.testForResponseElement(client,
|
||||
null,
|
||||
|
|
|
@ -31,8 +31,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
|
||||
import org.apache.solr.common.cloud.DocCollection;
|
||||
import org.apache.solr.common.cloud.Replica;
|
||||
|
@ -42,7 +40,6 @@ import org.apache.solr.common.cloud.ZkConfigManager;
|
|||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.core.SolrConfig;
|
||||
import org.apache.solr.util.RestTestHarness;
|
||||
import org.apache.zookeeper.CreateMode;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
import org.apache.zookeeper.data.Stat;
|
||||
|
@ -55,32 +52,14 @@ import org.slf4j.LoggerFactory;
|
|||
public class TestConfigReload extends AbstractFullDistribZkTestBase {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
private List<RestTestHarness> restTestHarnesses = new ArrayList<>();
|
||||
|
||||
private void setupHarnesses() {
|
||||
for (final SolrClient client : clients) {
|
||||
RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient)client).getBaseURL());
|
||||
restTestHarnesses.add(harness);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void distribTearDown() throws Exception {
|
||||
super.distribTearDown();
|
||||
for (RestTestHarness h : restTestHarnesses) {
|
||||
h.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
setupHarnesses();
|
||||
setupRestTestHarnesses();
|
||||
try {
|
||||
reloadTest();
|
||||
} finally {
|
||||
for (RestTestHarness h : restTestHarnesses) {
|
||||
h.close();
|
||||
}
|
||||
closeRestTestHarnesses();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,7 @@ import java.util.Map;
|
|||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.request.LukeRequest;
|
||||
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
|
||||
import org.apache.solr.common.cloud.DocCollection;
|
||||
|
@ -44,26 +42,10 @@ import static java.util.Arrays.asList;
|
|||
import static org.apache.solr.handler.TestBlobHandler.getAsString;
|
||||
|
||||
public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
||||
private List<RestTestHarness> restTestHarnesses = new ArrayList<>();
|
||||
|
||||
private void setupHarnesses() {
|
||||
for (final SolrClient client : clients) {
|
||||
RestTestHarness harness = new RestTestHarness(((HttpSolrClient) client)::getBaseURL);
|
||||
restTestHarnesses.add(harness);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void distribTearDown() throws Exception {
|
||||
super.distribTearDown();
|
||||
for (RestTestHarness r : restTestHarnesses) {
|
||||
r.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
setupHarnesses();
|
||||
setupRestTestHarnesses();
|
||||
testReqHandlerAPIs();
|
||||
testReqParams();
|
||||
testAdminPath();
|
||||
|
@ -71,7 +53,7 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
|||
|
||||
private void testAdminPath() throws Exception{
|
||||
String testServerBaseUrl = getRandomServer(cloudClient,"collection1");
|
||||
RestTestHarness writeHarness = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
RestTestHarness writeHarness = randomRestTestHarness();
|
||||
String payload = "{\n" +
|
||||
"'create-requesthandler' : { 'name' : '/admin/luke', " +
|
||||
"'class': 'org.apache.solr.handler.DumpRequestHandler'}}";
|
||||
|
@ -93,7 +75,7 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
|||
|
||||
private void testReqHandlerAPIs() throws Exception {
|
||||
String testServerBaseUrl = getRandomServer(cloudClient,"collection1");
|
||||
RestTestHarness writeHarness = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
RestTestHarness writeHarness = randomRestTestHarness();
|
||||
TestSolrConfigHandler.reqhandlertests(writeHarness, testServerBaseUrl , cloudClient);
|
||||
}
|
||||
|
||||
|
@ -115,7 +97,7 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
|||
urls.add(""+replica.get(ZkStateReader.BASE_URL_PROP) + "/"+replica.get(ZkStateReader.CORE_NAME_PROP));
|
||||
}
|
||||
|
||||
RestTestHarness writeHarness = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
RestTestHarness writeHarness = randomRestTestHarness();
|
||||
String payload = " {\n" +
|
||||
" 'set' : {'x': {" +
|
||||
" 'a':'A val',\n" +
|
||||
|
@ -190,7 +172,7 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
|
|||
|
||||
|
||||
|
||||
writeHarness = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
writeHarness = randomRestTestHarness();
|
||||
payload = " {\n" +
|
||||
" 'set' : {'y':{\n" +
|
||||
" 'c':'CY val',\n" +
|
||||
|
|
|
@ -34,9 +34,7 @@ import org.apache.http.HttpEntity;
|
|||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
|
||||
import org.apache.solr.common.cloud.DocCollection;
|
||||
import org.apache.solr.common.cloud.Replica;
|
||||
|
@ -55,29 +53,13 @@ import org.slf4j.LoggerFactory;
|
|||
public class TestSolrConfigHandlerConcurrent extends AbstractFullDistribZkTestBase {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
private List<RestTestHarness> restTestHarnesses = new ArrayList<>();
|
||||
|
||||
private void setupHarnesses() {
|
||||
for (final SolrClient client : clients) {
|
||||
RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient)client).getBaseURL());
|
||||
restTestHarnesses.add(harness);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void distribTearDown() throws Exception {
|
||||
super.distribTearDown();
|
||||
for (RestTestHarness h : restTestHarnesses) {
|
||||
h.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
Map editable_prop_map = (Map) Utils.fromJSONResource("EditableSolrConfigAttributes.json");
|
||||
Map caches = (Map) editable_prop_map.get("query");
|
||||
|
||||
setupHarnesses();
|
||||
setupRestTestHarnesses();
|
||||
List<Thread> threads = new ArrayList<>(caches.size());
|
||||
final List<List> collectErrors = new ArrayList<>();
|
||||
|
||||
|
@ -129,7 +111,7 @@ public class TestSolrConfigHandlerConcurrent extends AbstractFullDistribZkTestBa
|
|||
|
||||
Set<String> errmessages = new HashSet<>();
|
||||
for(int i =1;i<2;i++){//make it ahigher number
|
||||
RestTestHarness publisher = restTestHarnesses.get(r.nextInt(restTestHarnesses.size()));
|
||||
RestTestHarness publisher = randomRestTestHarness(r);
|
||||
String response;
|
||||
String val1;
|
||||
String val2;
|
||||
|
|
|
@ -30,8 +30,6 @@ import java.util.Set;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.common.util.Utils;
|
||||
|
@ -45,7 +43,6 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
private List<RestTestHarness> restTestHarnesses = new ArrayList<>();
|
||||
|
||||
@BeforeClass
|
||||
public static void initSysProperties() {
|
||||
|
@ -57,26 +54,11 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
|
|||
return "solrconfig-managed-schema.xml";
|
||||
}
|
||||
|
||||
private void setupHarnesses() {
|
||||
for (final SolrClient client : clients) {
|
||||
RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient)client).getBaseURL());
|
||||
restTestHarnesses.add(harness);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void distribTearDown() throws Exception {
|
||||
super.distribTearDown();
|
||||
for (RestTestHarness r : restTestHarnesses) {
|
||||
r.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
|
||||
final int threadCount = 5;
|
||||
setupHarnesses();
|
||||
setupRestTestHarnesses();
|
||||
Thread[] threads = new Thread[threadCount];
|
||||
final List<List> collectErrors = new ArrayList<>();
|
||||
|
||||
|
@ -148,7 +130,7 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
|
|||
payload = payload.replace("replaceDynamicCopyFieldDest", dynamicCopyFldDest);
|
||||
payload = payload.replace("myNewFieldTypeName", newFieldTypeName);
|
||||
|
||||
RestTestHarness publisher = restTestHarnesses.get(r.nextInt(restTestHarnesses.size()));
|
||||
RestTestHarness publisher = randomRestTestHarness(r);
|
||||
String response = publisher.post("/schema", SolrTestCaseJ4.json(payload));
|
||||
Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
|
||||
Object errors = map.get("errors");
|
||||
|
@ -159,7 +141,7 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
|
|||
|
||||
//get another node
|
||||
Set<String> errmessages = new HashSet<>();
|
||||
RestTestHarness harness = restTestHarnesses.get(r.nextInt(restTestHarnesses.size()));
|
||||
RestTestHarness harness = randomRestTestHarness(r);
|
||||
try {
|
||||
long startTime = System.nanoTime();
|
||||
long maxTimeoutMillis = 100000;
|
||||
|
@ -218,7 +200,7 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
|
|||
payload = payload.replace("replaceDynamicField", dynamicFldName);
|
||||
payload = payload.replace("myNewFieldTypeName", newFieldTypeName);
|
||||
|
||||
RestTestHarness publisher = restTestHarnesses.get(r.nextInt(restTestHarnesses.size()));
|
||||
RestTestHarness publisher = randomRestTestHarness(r);
|
||||
String response = publisher.post("/schema", SolrTestCaseJ4.json(payload));
|
||||
Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
|
||||
Object errors = map.get("errors");
|
||||
|
@ -229,7 +211,7 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
|
|||
|
||||
//get another node
|
||||
Set<String> errmessages = new HashSet<>();
|
||||
RestTestHarness harness = restTestHarnesses.get(r.nextInt(restTestHarnesses.size()));
|
||||
RestTestHarness harness = randomRestTestHarness(r);
|
||||
try {
|
||||
long startTime = System.nanoTime();
|
||||
long maxTimeoutMillis = 100000;
|
||||
|
@ -280,7 +262,7 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
|
|||
payload = payload.replace("replaceDynamicCopyFieldDest",dynamicCopyFldDest);
|
||||
payload = payload.replace("myNewFieldTypeName", newFieldTypeName);
|
||||
|
||||
RestTestHarness publisher = restTestHarnesses.get(r.nextInt(restTestHarnesses.size()));
|
||||
RestTestHarness publisher = randomRestTestHarness(r);
|
||||
String response = publisher.post("/schema", SolrTestCaseJ4.json(payload));
|
||||
Map map = (Map) ObjectBuilder.getVal(new JSONParser(new StringReader(response)));
|
||||
Object errors = map.get("errors");
|
||||
|
@ -291,7 +273,7 @@ public class TestBulkSchemaConcurrent extends AbstractFullDistribZkTestBase {
|
|||
|
||||
//get another node
|
||||
Set<String> errmessages = new HashSet<>();
|
||||
RestTestHarness harness = restTestHarnesses.get(r.nextInt(restTestHarnesses.size()));
|
||||
RestTestHarness harness = randomRestTestHarness(r);
|
||||
try {
|
||||
long startTime = System.nanoTime();
|
||||
long maxTimeoutMillis = 100000;
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.solr.schema;
|
|||
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.SolrException.ErrorCode;
|
||||
|
@ -39,6 +38,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
/**
|
||||
* Tests a schemaless collection configuration with SolrCloud
|
||||
|
@ -51,9 +51,7 @@ public class TestCloudSchemaless extends AbstractFullDistribZkTestBase {
|
|||
@After
|
||||
public void teardDown() throws Exception {
|
||||
super.tearDown();
|
||||
for (RestTestHarness h : restTestHarnesses) {
|
||||
h.close();
|
||||
}
|
||||
closeRestTestHarnesses();
|
||||
}
|
||||
|
||||
public TestCloudSchemaless() {
|
||||
|
@ -75,15 +73,6 @@ public class TestCloudSchemaless extends AbstractFullDistribZkTestBase {
|
|||
return extraServlets;
|
||||
}
|
||||
|
||||
private List<RestTestHarness> restTestHarnesses = new ArrayList<>();
|
||||
|
||||
private void setupHarnesses() {
|
||||
for (final SolrClient client : clients) {
|
||||
RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient)client).getBaseURL());
|
||||
restTestHarnesses.add(harness);
|
||||
}
|
||||
}
|
||||
|
||||
private String[] getExpectedFieldResponses(int numberOfDocs) {
|
||||
String[] expectedAddFields = new String[1 + numberOfDocs];
|
||||
expectedAddFields[0] = SUCCESS_XPATH;
|
||||
|
@ -99,7 +88,7 @@ public class TestCloudSchemaless extends AbstractFullDistribZkTestBase {
|
|||
@Test
|
||||
@ShardsFixed(num = 8)
|
||||
public void test() throws Exception {
|
||||
setupHarnesses();
|
||||
setupRestTestHarnesses();
|
||||
|
||||
// First, add a bunch of documents in a single update with the same new field.
|
||||
// This tests that the replicas properly handle schema additions.
|
||||
|
@ -127,16 +116,24 @@ public class TestCloudSchemaless extends AbstractFullDistribZkTestBase {
|
|||
|
||||
String [] expectedFields = getExpectedFieldResponses(docNumber);
|
||||
// Check that all the fields were added
|
||||
for (RestTestHarness client : restTestHarnesses) {
|
||||
String request = "/schema/fields?wt=xml";
|
||||
String response = client.query(request);
|
||||
String result = BaseTestHarness.validateXPath(response, expectedFields);
|
||||
if (result != null) {
|
||||
String msg = "QUERY FAILED: xpath=" + result + " request=" + request + " response=" + response;
|
||||
log.error(msg);
|
||||
fail(msg);
|
||||
forAllRestTestHarnesses( new UnaryOperator<RestTestHarness>() {
|
||||
@Override
|
||||
public RestTestHarness apply(RestTestHarness client) {
|
||||
try {
|
||||
String request = "/schema/fields?wt=xml";
|
||||
String response = client.query(request);
|
||||
String result = BaseTestHarness.validateXPath(response, expectedFields);
|
||||
if (result != null) {
|
||||
String msg = "QUERY FAILED: xpath=" + result + " request=" + request + " response=" + response;
|
||||
log.error(msg);
|
||||
fail(msg);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
fail("Caught exception: "+ex);
|
||||
}
|
||||
return client;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Now, let's ensure that writing the same field with two different types fails
|
||||
int failTrials = 50;
|
||||
|
|
|
@ -20,14 +20,12 @@ import java.io.FileInputStream;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.request.UpdateRequest;
|
||||
|
@ -44,28 +42,11 @@ import org.apache.solr.util.SimplePostTool;
|
|||
import org.junit.Test;
|
||||
|
||||
public class TestNamedUpdateProcessors extends AbstractFullDistribZkTestBase {
|
||||
private List<RestTestHarness> restTestHarnesses = new ArrayList<>();
|
||||
|
||||
private void setupHarnesses() {
|
||||
for (final SolrClient client : clients) {
|
||||
RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient) client).getBaseURL());
|
||||
restTestHarnesses.add(harness);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void distribTearDown() throws Exception {
|
||||
super.distribTearDown();
|
||||
for (RestTestHarness r : restTestHarnesses) {
|
||||
r.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
System.setProperty("enable.runtime.lib", "true");
|
||||
setupHarnesses();
|
||||
setupRestTestHarnesses();
|
||||
|
||||
String blobName = "colltest";
|
||||
|
||||
|
@ -81,7 +62,7 @@ public class TestNamedUpdateProcessors extends AbstractFullDistribZkTestBase {
|
|||
String payload = "{\n" +
|
||||
"'add-runtimelib' : { 'name' : 'colltest' ,'version':1}\n" +
|
||||
"}";
|
||||
RestTestHarness client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
RestTestHarness client = randomRestTestHarness();
|
||||
TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
|
||||
TestSolrConfigHandler.testForResponseElement(client,
|
||||
null,
|
||||
|
@ -96,16 +77,24 @@ public class TestNamedUpdateProcessors extends AbstractFullDistribZkTestBase {
|
|||
"'create-updateprocessor' : { 'name' : 'maxFld', 'class': 'solr.MaxFieldValueUpdateProcessorFactory', 'fieldName':'mul_s'} \n" +
|
||||
"}";
|
||||
|
||||
client = restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
client = randomRestTestHarness();
|
||||
TestSolrConfigHandler.runConfigCommand(client, "/config", payload);
|
||||
for (RestTestHarness restTestHarness : restTestHarnesses) {
|
||||
TestSolrConfigHandler.testForResponseElement(restTestHarness,
|
||||
null,
|
||||
"/config/overlay",
|
||||
null,
|
||||
Arrays.asList("overlay", "updateProcessor", "firstFld", "fieldName"),
|
||||
"test_s", 10);
|
||||
}
|
||||
forAllRestTestHarnesses( new UnaryOperator<RestTestHarness>() {
|
||||
@Override
|
||||
public RestTestHarness apply(RestTestHarness restTestHarness) {
|
||||
try {
|
||||
TestSolrConfigHandler.testForResponseElement(restTestHarness,
|
||||
null,
|
||||
"/config/overlay",
|
||||
null,
|
||||
Arrays.asList("overlay", "updateProcessor", "firstFld", "fieldName"),
|
||||
"test_s", 10);
|
||||
} catch (Exception ex) {
|
||||
fail("Caught exception: "+ex);
|
||||
}
|
||||
return restTestHarness;
|
||||
}
|
||||
});
|
||||
|
||||
SolrInputDocument doc = new SolrInputDocument();
|
||||
doc.addField("id", "123");
|
||||
|
|
|
@ -33,9 +33,11 @@ import java.util.Locale;
|
|||
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.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import org.apache.lucene.util.LuceneTestCase.Slow;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
|
@ -83,6 +85,7 @@ import org.apache.solr.update.SolrCmdDistributor;
|
|||
import org.apache.solr.update.SolrIndexWriter;
|
||||
import org.apache.solr.util.RTimer;
|
||||
import org.apache.solr.util.RefCounted;
|
||||
import org.apache.solr.util.RestTestHarness;
|
||||
import org.apache.solr.util.TimeOut;
|
||||
import org.apache.zookeeper.CreateMode;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
|
@ -136,6 +139,8 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
|
|||
private boolean cloudInit;
|
||||
protected boolean useJettyDataDir = true;
|
||||
|
||||
private List<RestTestHarness> restTestHarnesses = new ArrayList<>();
|
||||
|
||||
protected Map<URI,SocketProxy> proxies = new HashMap<>();
|
||||
|
||||
public static class CloudJettyRunner {
|
||||
|
@ -1552,6 +1557,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
|
|||
if (VERBOSE || printLayoutOnTearDown) {
|
||||
super.printLayout();
|
||||
}
|
||||
closeRestTestHarnesses(); // TODO: close here or later?
|
||||
if (commonCloudSolrClient != null) {
|
||||
commonCloudSolrClient.close();
|
||||
}
|
||||
|
@ -2239,4 +2245,31 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
|
|||
return CollectionAdminRequest.requestStatus(requestId).process(client);
|
||||
}
|
||||
|
||||
protected void setupRestTestHarnesses() {
|
||||
for (final SolrClient client : clients) {
|
||||
RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient) client).getBaseURL());
|
||||
restTestHarnesses.add(harness);
|
||||
}
|
||||
}
|
||||
|
||||
protected void closeRestTestHarnesses() throws IOException {
|
||||
for (RestTestHarness h : restTestHarnesses) {
|
||||
h.close();
|
||||
}
|
||||
}
|
||||
|
||||
protected RestTestHarness randomRestTestHarness() {
|
||||
return restTestHarnesses.get(random().nextInt(restTestHarnesses.size()));
|
||||
}
|
||||
|
||||
protected RestTestHarness randomRestTestHarness(Random random) {
|
||||
return restTestHarnesses.get(random.nextInt(restTestHarnesses.size()));
|
||||
}
|
||||
|
||||
protected void forAllRestTestHarnesses(UnaryOperator<RestTestHarness> op) {
|
||||
for (RestTestHarness h : restTestHarnesses) {
|
||||
op.apply(h);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue