You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/02/25 19:45:21 UTC
[GitHub] [solr] risdenk commented on a change in pull request #711: SOLR-14920: Spotless formatting for core - test only
risdenk commented on a change in pull request #711:
URL: https://github.com/apache/solr/pull/711#discussion_r815012553
##########
File path: solr/core/src/test/org/apache/solr/SolrTestCaseJ4Test.java
##########
@@ -17,33 +17,36 @@
package org.apache.solr;
import java.io.File;
-
import org.apache.commons.io.FileUtils;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-
public class SolrTestCaseJ4Test extends SolrTestCaseJ4 {
private static String tmpSolrHome;
@BeforeClass
public static void beforeClass() throws Exception {
- // Create a temporary directory that holds a core NOT named "collection1". Use the smallest configuration sets
+ // Create a temporary directory that holds a core NOT named "collection1". Use the smallest
+ // configuration sets
// we can so we don't copy that much junk around.
tmpSolrHome = createTempDir().toFile().getAbsolutePath();
File subHome = new File(new File(tmpSolrHome, "core0"), "conf");
assertTrue("Failed to make subdirectory ", subHome.mkdirs());
String top = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf";
FileUtils.copyFile(new File(top, "schema-tiny.xml"), new File(subHome, "schema-tiny.xml"));
- FileUtils.copyFile(new File(top, "solrconfig-minimal.xml"), new File(subHome, "solrconfig-minimal.xml"));
- FileUtils.copyFile(new File(top, "solrconfig.snippet.randomindexconfig.xml"), new File(subHome, "solrconfig.snippet.randomindexconfig.xml"));
+ FileUtils.copyFile(
+ new File(top, "solrconfig-minimal.xml"), new File(subHome, "solrconfig-minimal.xml"));
+ FileUtils.copyFile(
+ new File(top, "solrconfig.snippet.randomindexconfig.xml"),
+ new File(subHome, "solrconfig.snippet.randomindexconfig.xml"));
FileUtils.copyDirectory(new File(tmpSolrHome, "core0"), new File(tmpSolrHome, "core1"));
- // Core discovery will default to the name of the dir the core.properties file is in. So if everything else is
+ // Core discovery will default to the name of the dir the core.properties file is in. So if
+ // everything else is
// OK as defaults, just the _presence_ of this file is sufficient.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/TestHighlightDedupGrouping.java
##########
@@ -84,37 +93,59 @@ private void randomizedTest() throws Exception {
handle.clear();
handle.put("timestamp", SKIPVAL);
- handle.put("grouped", UNORDERED); // distrib grouping doesn't guarantee order of top level group commands
+ handle.put(
+ "grouped",
+ UNORDERED); // distrib grouping doesn't guarantee order of top level group commands
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java
##########
@@ -480,60 +539,110 @@ public void testDeleteAliasWithExistingCollectionName() throws Exception {
res = cluster.getSolrClient().query("collection_old_reserve", new SolrQuery("*:*"));
assertEquals(1, res.getResults().getNumFound());
- // Now delete the old collection. This should fail since the collection_old_reserve points to collection_old
- RequestStatusState delResp = CollectionAdminRequest.deleteCollection("collection_old").processAndWait(cluster.getSolrClient(), 60);
+ // Now delete the old collection. This should fail since the collection_old_reserve points to
+ // collection_old
+ RequestStatusState delResp =
+ CollectionAdminRequest.deleteCollection("collection_old")
+ .processAndWait(cluster.getSolrClient(), 60);
assertEquals("Should have failed to delete collection: ", delResp, RequestStatusState.FAILED);
// assure ourselves that the old colletion is, indeed, still there.
- assertNotNull("collection_old should exist!", cluster.getSolrClient().getZkStateReader().getClusterState().getCollectionOrNull("collection_old"));
+ assertNotNull(
+ "collection_old should exist!",
+ cluster
+ .getSolrClient()
+ .getZkStateReader()
+ .getClusterState()
+ .getCollectionOrNull("collection_old"));
// Now we should still succeed using the alias collection_old which points to collection_new
- // aliase: collection_old -> collection_new, collection_old_reserve -> collection_old -> collection_new
+ // aliase: collection_old -> collection_new, collection_old_reserve -> collection_old ->
+ // collection_new
// collections: collection_old, collection_new
res = cluster.getSolrClient().query("collection_old", new SolrQuery("*:*"));
assertEquals(1, res.getResults().getNumFound());
Aliases aliases = cluster.getSolrClient().getZkStateReader().getAliases();
- assertTrue("collection_old should point to collection_new", aliases.resolveAliases("collection_old").contains("collection_new"));
- assertTrue("collection_old_reserve should point to collection_new", aliases.resolveAliases("collection_old_reserve").contains("collection_new"));
+ assertTrue(
+ "collection_old should point to collection_new",
+ aliases.resolveAliases("collection_old").contains("collection_new"));
+ assertTrue(
+ "collection_old_reserve should point to collection_new",
+ aliases.resolveAliases("collection_old_reserve").contains("collection_new"));
// Clean up
- CollectionAdminRequest.deleteAlias("collection_old_reserve").processAndWait(cluster.getSolrClient(), 60);
+ CollectionAdminRequest.deleteAlias("collection_old_reserve")
+ .processAndWait(cluster.getSolrClient(), 60);
lastVersion = waitForAliasesUpdate(lastVersion, zkStateReader);
- CollectionAdminRequest.deleteAlias("collection_old").processAndWait(cluster.getSolrClient(), 60);
+ CollectionAdminRequest.deleteAlias("collection_old")
+ .processAndWait(cluster.getSolrClient(), 60);
lastVersion = waitForAliasesUpdate(lastVersion, zkStateReader);
- CollectionAdminRequest.deleteCollection("collection_new").processAndWait(cluster.getSolrClient(), 60);
- CollectionAdminRequest.deleteCollection("collection_old").processAndWait(cluster.getSolrClient(), 60);
+ CollectionAdminRequest.deleteCollection("collection_new")
+ .processAndWait(cluster.getSolrClient(), 60);
+ CollectionAdminRequest.deleteCollection("collection_old")
+ .processAndWait(cluster.getSolrClient(), 60);
// collection_old already deleted as well as collection_old_reserve
- assertNull("collection_old_reserve should be gone", cluster.getSolrClient().getZkStateReader().getAliases().getCollectionAliasMap().get("collection_old_reserve"));
- assertNull("collection_old should be gone", cluster.getSolrClient().getZkStateReader().getAliases().getCollectionAliasMap().get("collection_old"));
-
- assertFalse("collection_new should be gone",
- cluster.getSolrClient().getZkStateReader().getClusterState().hasCollection("collection_new"));
-
- assertFalse("collection_old should be gone",
- cluster.getSolrClient().getZkStateReader().getClusterState().hasCollection("collection_old"));
+ assertNull(
+ "collection_old_reserve should be gone",
+ cluster
+ .getSolrClient()
+ .getZkStateReader()
+ .getAliases()
+ .getCollectionAliasMap()
+ .get("collection_old_reserve"));
+ assertNull(
+ "collection_old should be gone",
+ cluster
+ .getSolrClient()
+ .getZkStateReader()
+ .getAliases()
+ .getCollectionAliasMap()
+ .get("collection_old"));
+
+ assertFalse(
+ "collection_new should be gone",
+ cluster
+ .getSolrClient()
+ .getZkStateReader()
+ .getClusterState()
+ .hasCollection("collection_new"));
+
+ assertFalse(
+ "collection_old should be gone",
+ cluster
+ .getSolrClient()
+ .getZkStateReader()
+ .getClusterState()
+ .hasCollection("collection_old"));
}
- // While writing the above test I wondered what happens when an alias points to two collections and one of them
+ // While writing the above test I wondered what happens when an alias points to two collections
+ // and one of them
// is deleted.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ClusterStateMockUtil.java
##########
@@ -36,84 +35,59 @@
import org.apache.solr.handler.admin.ConfigSetsHandler;
/**
- * A utility class that can create mock ZkStateReader objects with custom ClusterState objects created
- * using a simple string based description. See {@link #buildClusterState(String, int, String...)} for
- * details on how the cluster state can be created.
+ * A utility class that can create mock ZkStateReader objects with custom ClusterState objects
+ * created using a simple string based description. See {@link #buildClusterState(String, int,
+ * String...)} for details on how the cluster state can be created.
*
* @lucene.experimental
*/
public class ClusterStateMockUtil {
- private final static Pattern BLUEPRINT = Pattern.compile("([a-z])(\\d+)?(?:(['A','R','D','F']))?(\\*)?");
+ private static final Pattern BLUEPRINT =
+ Pattern.compile("([a-z])(\\d+)?(?:(['A','R','D','F']))?(\\*)?");
- public static ZkStateReader buildClusterState(String clusterDescription, String ... liveNodes) {
+ public static ZkStateReader buildClusterState(String clusterDescription, String... liveNodes) {
return buildClusterState(clusterDescription, 1, liveNodes);
}
/**
- * This method lets you construct a complex ClusterState object by using simple strings of letters.
- *
- * c = collection, s = slice, r = replica (nrt type, default), n = nrt replica, t = tlog replica, p = pull replica, \d = node number (r2 means the replica is on node 2),
- * state = [A,R,D,F], * = replica to replace, binds to the left.
+ * This method lets you construct a complex ClusterState object by using simple strings of
+ * letters.
*
- * For example:
- * csrr2rD*sr2csr
+ * <p>c = collection, s = slice, r = replica (nrt type, default), n = nrt replica, t = tlog
+ * replica, p = pull replica, \d = node number (r2 means the replica is on node 2), state =
+ * [A,R,D,F], * = replica to replace, binds to the left.
*
- * Creates:
+ * <p>For example: csrr2rD*sr2csr
*
- * 'csrr2rD*'
- * A collection, a shard, a replica on node 1 (the default) that is active (the default), a replica on node 2, and a replica on node 1
- * that has a state of down and is the replica we will be looking to put somewhere else (the *).
+ * <p>Creates:
*
- * 'sr2'
- * Then, another shard that has a replica on node 2.
+ * <p>'csrr2rD*' A collection, a shard, a replica on node 1 (the default) that is active (the
+ * default), a replica on node 2, and a replica on node 1 that has a state of down and is the
+ * replica we will be looking to put somewhere else (the *).
*
- * 'csr'
- * Then, another collection that has a shard with a single active replica on node 1.
+ * <p>'sr2' Then, another shard that has a replica on node 2.
*
- * Result:
- * {
- * "collection2":{
- * "replicationFactor":"1",
- * "shards":{"slice1":{
- * "state":"active",
- * "replicas":{"replica5":{
- * "state":"active",
- * "node_name":"baseUrl1_",
- * "base_url":"http://baseUrl1"}}}}},
- * "collection1":{
- * "replicationFactor":"1",
- * "shards":{
- * "slice1":{
- * "state":"active",
- * "replicas":{
- * "replica3 (bad)":{
- * "state":"down",
- * "node_name":"baseUrl1_",
- * "base_url":"http://baseUrl1"},
- * "replica2":{
- * "state":"active",
- * "node_name":"baseUrl2_",
- * "base_url":"http://baseUrl2"},
- * "replica1":{
- * "state":"active",
- * "node_name":"baseUrl1_",
- * "base_url":"http://baseUrl1"}}},
- * "slice2":{
- * "state":"active",
- * "replicas":{"replica4":{
- * "state":"active",
- * "node_name":"baseUrl2_",
- * "base_url":"http://baseUrl2"}}}}}}
+ * <p>'csr' Then, another collection that has a shard with a single active replica on node 1.
*
+ * <p>Result: { "collection2":{ "replicationFactor":"1", "shards":{"slice1":{ "state":"active",
+ * "replicas":{"replica5":{ "state":"active", "node_name":"baseUrl1_",
+ * "base_url":"http://baseUrl1"}}}}}, "collection1":{ "replicationFactor":"1", "shards":{
+ * "slice1":{ "state":"active", "replicas":{ "replica3 (bad)":{ "state":"down",
+ * "node_name":"baseUrl1_", "base_url":"http://baseUrl1"}, "replica2":{ "state":"active",
+ * "node_name":"baseUrl2_", "base_url":"http://baseUrl2"}, "replica1":{ "state":"active",
+ * "node_name":"baseUrl1_", "base_url":"http://baseUrl1"}}}, "slice2":{ "state":"active",
+ * "replicas":{"replica4":{ "state":"active", "node_name":"baseUrl2_",
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
##########
@@ -64,23 +62,24 @@
public static void setupCluster() throws Exception {
System.setProperty("solr.zkclienttimeout", "45000");
System.setProperty("distribUpdateSoTimeout", "15000");
-
}
-
+
@Before
@Override
public void setUp() throws Exception {
super.setUp();
System.setProperty("solr.zkclienttimeout", "45000");
System.setProperty("distribUpdateSoTimeout", "15000");
-
+
// these tests need to be isolated, so we dont share the minicluster
configureCluster(4)
.addConfig("conf", configset("cloud-minimal"))
- .useOtherCollectionConfigSetExecution() // Some tests (this one) use "the other" cluster Collection API execution strategy to increase coverage
+ .useOtherCollectionConfigSetExecution() // Some tests (this one) use "the other" cluster
+ // Collection API execution strategy to increase
+ // coverage
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/TestRandomDVFaceting.java
##########
@@ -87,31 +97,40 @@ void init() {
indexSize = rand.nextBoolean() ? (rand.nextInt(10) + 1) : (rand.nextInt(100) + 10);
types = new ArrayList<>();
- types.add(new FldType("id",ONE_ONE, new SVal('A','Z',4,4)));
- types.add(new FldType("score_f",ONE_ONE, new FVal(1,100)));
- types.add(new FldType("score_d",ONE_ONE, new FVal(1,100)));
- types.add(new FldType("foo_i",ZERO_ONE, new IRange(0,indexSize)));
- types.add(new FldType("foo_l",ZERO_ONE, new IRange(0,indexSize)));
- types.add(new FldType("small_s",ZERO_ONE, new SVal('a',(char)('c'+indexSize/3),1,1)));
- types.add(new FldType("small2_s",ZERO_ONE, new SVal('a',(char)('c'+indexSize/3),1,1)));
- types.add(new FldType("small2_ss",ZERO_TWO, new SVal('a',(char)('c'+indexSize/3),1,1)));
- types.add(new FldType("small3_ss",new IRange(0,25), new SVal('A','z',1,1)));
- types.add(new FldType("small4_ss",ZERO_ONE, new SVal('a',(char)('c'+indexSize/3),1,1))); // to test specialization when a multi-valued field is actually single-valued
- types.add(new FldType("small_i",ZERO_ONE, new IRange(0,5+indexSize/3)));
- types.add(new FldType("small2_i",ZERO_ONE, new IRange(0,5+indexSize/3)));
- types.add(new FldType("small2_is",ZERO_TWO, new IRange(0,5+indexSize/3)));
- types.add(new FldType("small3_is",new IRange(0,25), new IRange(0,100)));
-
- types.add(new FldType("foo_fs", new IRange(0,25), new FVal(0,indexSize)));
- types.add(new FldType("foo_f", ZERO_ONE, new FVal(0,indexSize)));
- types.add(new FldType("foo_ds", new IRange(0,25), new FVal(0,indexSize)));
- types.add(new FldType("foo_d", ZERO_ONE, new FVal(0,indexSize)));
- types.add(new FldType("foo_ls", new IRange(0,25), new IRange(0,indexSize)));
-
- types.add(new FldType("missing_i",new IRange(0,0), new IRange(0,100)));
- types.add(new FldType("missing_is",new IRange(0,0), new IRange(0,100)));
- types.add(new FldType("missing_s",new IRange(0,0), new SVal('a','b',1,1)));
- types.add(new FldType("missing_ss",new IRange(0,0), new SVal('a','b',1,1)));
+ types.add(new FldType("id", ONE_ONE, new SVal('A', 'Z', 4, 4)));
+ types.add(new FldType("score_f", ONE_ONE, new FVal(1, 100)));
+ types.add(new FldType("score_d", ONE_ONE, new FVal(1, 100)));
+ types.add(new FldType("foo_i", ZERO_ONE, new IRange(0, indexSize)));
+ types.add(new FldType("foo_l", ZERO_ONE, new IRange(0, indexSize)));
+ types.add(new FldType("small_s", ZERO_ONE, new SVal('a', (char) ('c' + indexSize / 3), 1, 1)));
+ types.add(new FldType("small2_s", ZERO_ONE, new SVal('a', (char) ('c' + indexSize / 3), 1, 1)));
+ types.add(
+ new FldType("small2_ss", ZERO_TWO, new SVal('a', (char) ('c' + indexSize / 3), 1, 1)));
+ types.add(new FldType("small3_ss", new IRange(0, 25), new SVal('A', 'z', 1, 1)));
+ types.add(
+ new FldType(
+ "small4_ss",
+ ZERO_ONE,
+ new SVal(
+ 'a',
+ (char) ('c' + indexSize / 3),
+ 1,
+ 1))); // to test specialization when a multi-valued field is actually single-valued
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/TestRandomFaceting.java
##########
@@ -233,165 +243,193 @@ void doFacetTests(FldType ftype) throws Exception {
}
if (rand.nextBoolean()) {
- params.add("facet.enum.cache.minDf",""+ rand.nextInt(indexSize));
+ params.add("facet.enum.cache.minDf", "" + rand.nextInt(indexSize));
}
-
+
// TODO: randomly add other facet params
String key = ftype.fname;
String facet_field = ftype.fname;
if (random().nextBoolean()) {
key = "alternate_key";
- facet_field = "{!key="+key+"}"+ftype.fname;
+ facet_field = "{!key=" + key + "}" + ftype.fname;
}
params.set("facet.field", facet_field);
List<String> methods = multiValued ? multiValuedMethods : singleValuedMethods;
List<String> responses = new ArrayList<>(methods.size());
-
+
for (String method : methods) {
- for (boolean exists : new boolean[]{false, true}) {
+ for (boolean exists : new boolean[] {false, true}) {
// params.add("facet.field", "{!key="+method+"}" + ftype.fname);
// TODO: allow method to be passed on local params?
- if (method!=null) {
+ if (method != null) {
params.set("facet.method", method);
} else {
params.remove("facet.method");
}
- params.set("facet.exists", ""+exists);
+ params.set("facet.exists", "" + exists);
if (!exists && rand.nextBoolean()) {
params.remove("facet.exists");
}
-
- // if (random().nextBoolean()) params.set("facet.mincount", "1"); // uncomment to test that validation fails
- if (!(params.getInt("facet.limit", 100) == 0 &&
- !params.getBool("facet.missing", false))) {
+
+ // if (random().nextBoolean()) params.set("facet.mincount", "1"); // uncomment to test
+ // that validation fails
+ if (!(params.getInt("facet.limit", 100) == 0
+ && !params.getBool("facet.missing", false))) {
// it bypasses all processing, and we can go to empty validation
- if (exists && params.getInt("facet.mincount", 0)>1) {
- assertQEx("no mincount on facet.exists",
- rand.nextBoolean() ? "facet.exists":"facet.mincount",
- req(params), ErrorCode.BAD_REQUEST);
+ if (exists && params.getInt("facet.mincount", 0) > 1) {
+ assertQEx(
+ "no mincount on facet.exists",
+ rand.nextBoolean() ? "facet.exists" : "facet.mincount",
+ req(params),
+ ErrorCode.BAD_REQUEST);
continue;
}
- // facet.exists can't be combined with non-enum nor with enum requested for tries, because it will be flipped to FC/FCS
+ // facet.exists can't be combined with non-enum nor with enum requested for tries,
+ // because it will be flipped to FC/FCS
final boolean notEnum = method != null && !method.equals("enum");
final boolean trieField = trieFields.matcher(ftype.fname).matches();
if ((notEnum || trieField) && exists) {
- assertQEx("facet.exists only when enum or ommitted",
- "facet.exists", req(params), ErrorCode.BAD_REQUEST);
+ assertQEx(
+ "facet.exists only when enum or ommitted",
+ "facet.exists",
+ req(params),
+ ErrorCode.BAD_REQUEST);
continue;
}
if (exists && sf.getType().isPointField()) {
// PointFields don't yet support "enum" method or the "facet.exists" parameter
- assertQEx("Expecting failure, since ",
- "facet.exists=true is requested, but facet.method=enum can't be used with " + sf.getName(),
- req(params), ErrorCode.BAD_REQUEST);
+ assertQEx(
+ "Expecting failure, since ",
+ "facet.exists=true is requested, but facet.method=enum can't be used with "
+ + sf.getName(),
+ req(params),
+ ErrorCode.BAD_REQUEST);
continue;
}
}
String strResponse = h.query(req(params));
responses.add(strResponse);
-
- if (responses.size()>1) {
+
+ if (responses.size() > 1) {
validateResponse(responses.get(0), strResponse, params, method, methods);
}
}
-
}
-
+
/**
- String strResponse = h.query(req(params));
- Object realResponse = ObjectBuilder.fromJSON(strResponse);
- **/
+ * String strResponse = h.query(req(params)); Object realResponse =
+ * ObjectBuilder.fromJSON(strResponse);
+ */
} finally {
req.close();
}
}
- private void validateResponse(String expected, String actual, ModifiableSolrParams params, String method,
- List<String> methods) throws Exception {
+
+ private void validateResponse(
+ String expected,
+ String actual,
+ ModifiableSolrParams params,
+ String method,
+ List<String> methods)
+ throws Exception {
if (params.getBool("facet.exists", false)) {
- if (isSortByCount(params)) { // it's challenged with facet.sort=count
- expected = getExpectationForSortByCount(params, methods);// that requires to recalculate expactation
+ if (isSortByCount(params)) { // it's challenged with facet.sort=count
+ expected =
+ getExpectationForSortByCount(
+ params, methods); // that requires to recalculate expactation
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
##########
@@ -301,77 +355,104 @@ public void raceConditionOnDeleteAndRegisterReplica() throws Exception {
Semaphore waitingForReplicaGetDeleted = new Semaphore(0);
// for safety, we only want this hook get triggered one time
AtomicInteger times = new AtomicInteger(0);
- ZkContainer.testing_beforeRegisterInZk = cd -> {
- if (cd.getCloudDescriptor() == null) return false;
- if (replica1.getName().equals(cd.getCloudDescriptor().getCoreNodeName())
- && collectionName.equals(cd.getCloudDescriptor().getCollectionName())) {
- if (times.incrementAndGet() > 1) {
- return false;
- }
- log.info("Running delete core {}",cd);
-
- try {
- ZkController replica1ZkController = replica1Jetty.getCoreContainer().getZkController();
- ZkNodeProps m = new ZkNodeProps(
- Overseer.QUEUE_OPERATION, OverseerAction.DELETECORE.toLower(),
- ZkStateReader.CORE_NAME_PROP, replica1.getCoreName(),
- ZkStateReader.NODE_NAME_PROP, replica1.getNodeName(),
- ZkStateReader.BASE_URL_PROP, replica1ZkController.getZkStateReader().getBaseUrlForNodeName(replica1.getNodeName()),
- ZkStateReader.COLLECTION_PROP, collectionName,
- ZkStateReader.CORE_NODE_NAME_PROP, replica1.getName());
-
- if (replica1ZkController.getDistributedClusterStateUpdater().isDistributedStateUpdate()) {
- cluster.getOpenOverseer().getDistributedClusterStateUpdater().doSingleStateUpdate(
- DistributedClusterStateUpdater.MutatingCommand.SliceRemoveReplica, m,
- cluster.getOpenOverseer().getSolrCloudManager(),
- cluster.getOpenOverseer().getZkStateReader());
- } else {
- cluster.getOpenOverseer().getStateUpdateQueue().offer(Utils.toJSON(m));
- }
+ ZkContainer.testing_beforeRegisterInZk =
+ cd -> {
+ if (cd.getCloudDescriptor() == null) return false;
+ if (replica1.getName().equals(cd.getCloudDescriptor().getCoreNodeName())
+ && collectionName.equals(cd.getCloudDescriptor().getCollectionName())) {
+ if (times.incrementAndGet() > 1) {
+ return false;
+ }
+ log.info("Running delete core {}", cd);
- boolean replicaDeleted = false;
- TimeOut timeOut = new TimeOut(20, TimeUnit.SECONDS, TimeSource.NANO_TIME);
- while (!timeOut.hasTimedOut()) {
try {
- ZkStateReader stateReader = replica1Jetty.getCoreContainer().getZkController().getZkStateReader();
- stateReader.forceUpdateCollection(collectionName);
- Slice shard = stateReader.getClusterState().getCollection(collectionName).getSlice("shard1");
- if (shard.getReplicas().size() == 1) {
- replicaDeleted = true;
- waitingForReplicaGetDeleted.release();
- break;
+ ZkController replica1ZkController =
+ replica1Jetty.getCoreContainer().getZkController();
+ ZkNodeProps m =
+ new ZkNodeProps(
+ Overseer.QUEUE_OPERATION, OverseerAction.DELETECORE.toLower(),
+ ZkStateReader.CORE_NAME_PROP, replica1.getCoreName(),
+ ZkStateReader.NODE_NAME_PROP, replica1.getNodeName(),
+ ZkStateReader.BASE_URL_PROP,
+ replica1ZkController
+ .getZkStateReader()
+ .getBaseUrlForNodeName(replica1.getNodeName()),
+ ZkStateReader.COLLECTION_PROP, collectionName,
+ ZkStateReader.CORE_NODE_NAME_PROP, replica1.getName());
+
+ if (replica1ZkController
+ .getDistributedClusterStateUpdater()
+ .isDistributedStateUpdate()) {
+ cluster
+ .getOpenOverseer()
+ .getDistributedClusterStateUpdater()
+ .doSingleStateUpdate(
+ DistributedClusterStateUpdater.MutatingCommand.SliceRemoveReplica,
+ m,
+ cluster.getOpenOverseer().getSolrCloudManager(),
+ cluster.getOpenOverseer().getZkStateReader());
+ } else {
+ cluster.getOpenOverseer().getStateUpdateQueue().offer(Utils.toJSON(m));
+ }
+
+ boolean replicaDeleted = false;
+ TimeOut timeOut = new TimeOut(20, TimeUnit.SECONDS, TimeSource.NANO_TIME);
+ while (!timeOut.hasTimedOut()) {
+ try {
+ ZkStateReader stateReader =
+ replica1Jetty.getCoreContainer().getZkController().getZkStateReader();
+ stateReader.forceUpdateCollection(collectionName);
+ Slice shard =
+ stateReader
+ .getClusterState()
+ .getCollection(collectionName)
+ .getSlice("shard1");
+ if (shard.getReplicas().size() == 1) {
+ replicaDeleted = true;
+ waitingForReplicaGetDeleted.release();
+ break;
+ }
+ Thread.sleep(500);
+ } catch (NullPointerException | SolrException e) {
+ e.printStackTrace();
+ Thread.sleep(500);
+ }
+ }
+ if (!replicaDeleted) {
+ fail("Timeout for waiting replica get deleted");
}
- Thread.sleep(500);
- } catch (NullPointerException | SolrException e) {
+ } catch (Exception e) {
e.printStackTrace();
- Thread.sleep(500);
+ fail("Failed to delete replica");
+ } finally {
+ // avoiding deadlock
+ waitingForReplicaGetDeleted.release();
}
+ return true;
}
- if (!replicaDeleted) {
- fail("Timeout for waiting replica get deleted");
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail("Failed to delete replica");
- } finally {
- //avoiding deadlock
- waitingForReplicaGetDeleted.release();
- }
- return true;
- }
- return false;
- };
+ return false;
+ };
try {
replica1Jetty.stop();
waitForNodeLeave(replica1JettyNodeName);
- // There is a race condition: the replica might be marked down before we get here, in which case we never get notified
- // So we check before waiting... Not eliminating but significantly reducing the race window - eliminating would require
+ // There is a race condition: the replica might be marked down before we get here, in which
+ // case we never get notified
+ // So we check before waiting... Not eliminating but significantly reducing the race window -
+ // eliminating would require
// deeper changes in the code where the watcher is set.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/TestHighlightDedupGrouping.java
##########
@@ -55,24 +54,34 @@ private void basicTest() throws Exception {
handle.clear();
handle.put("timestamp", SKIPVAL);
- handle.put("grouped", UNORDERED); // distrib grouping doesn't guarantee order of top level group commands
+ handle.put(
+ "grouped",
+ UNORDERED); // distrib grouping doesn't guarantee order of top level group commands
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/analysis/CommonGramsPhraseQueryTest.java
##########
@@ -49,53 +54,59 @@ public void testCommonGrams() throws Exception {
testCommonQueries("x_commongrams");
// individual stop words should also match in this field....
for (String word : Arrays.asList("the", "and")) {
- assertQ(req("x_commongrams:" + word)
- ,"//*[@numFound='2']"
- ,"//str[@name='id' and .='1']"
- ,"//str[@name='id' and .='2']"
- );
+ assertQ(
+ req("x_commongrams:" + word),
+ "//*[@numFound='2']",
+ "//str[@name='id' and .='1']",
+ "//str[@name='id' and .='2']");
}
- assertQ(req("x_commongrams:a")
- ,"//*[@numFound='2']"
- ,"//str[@name='id' and .='2']"
- ,"//str[@name='id' and .='3']"
- );
- assertQ(req("x_commongrams:not")
- ,"//*[@numFound='1']"
- ,"//str[@name='id' and .='3']"
- );
+ assertQ(
+ req("x_commongrams:a"),
+ "//*[@numFound='2']",
+ "//str[@name='id' and .='2']",
+ "//str[@name='id' and .='3']");
+ assertQ(req("x_commongrams:not"), "//*[@numFound='1']", "//str[@name='id' and .='3']");
}
+
public void testCommonGramsStop() throws Exception {
testCommonQueries("x_commongrams_stop");
// individual stop words should not match anything in this field...
for (String word : Arrays.asList("the", "and", "not", "a")) {
- assertQ(req("x_commongrams_stop:" + word)
- ,"//*[@numFound='0']");
+ assertQ(req("x_commongrams_stop:" + word), "//*[@numFound='0']");
}
}
-
+
protected void testCommonQueries(final String f) throws Exception {
// match 2...
- for (String phrase : Arrays.asList("the quick and the dead", "the quick", "and the dead", "and the", "the dead man", "quick")) {
- assertQ(req(f + ":\""+phrase+"\"")
- ,"//*[@numFound='2']"
- ,"//str[@name='id' and .='1']"
- ,"//str[@name='id' and .='2']"
- );
+ for (String phrase :
+ Arrays.asList(
+ "the quick and the dead",
+ "the quick",
+ "and the dead",
+ "and the",
+ "the dead man",
+ "quick")) {
+ assertQ(
+ req(f + ":\"" + phrase + "\""),
+ "//*[@numFound='2']",
+ "//str[@name='id' and .='1']",
+ "//str[@name='id' and .='2']");
}
- assertQ(req(f + ":quick") // just for the hell of it, let's also check this as a term and not a phase
- ,"//*[@numFound='2']"
- ,"//str[@name='id' and .='1']"
- ,"//str[@name='id' and .='2']"
- );
+ assertQ(
+ req(f + ":quick") // just for the hell of it, let's also check this as a term and not a
+ // phase
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/TestRandomFaceting.java
##########
@@ -57,17 +56,19 @@
@BeforeClass
public static void beforeTests() throws Exception {
// we need DVs on point fields to compute stats & facets
- if (Boolean.getBoolean(NUMERIC_POINTS_SYSPROP)) System.setProperty(NUMERIC_DOCVALUES_SYSPROP,"true");
-
+ if (Boolean.getBoolean(NUMERIC_POINTS_SYSPROP))
+ System.setProperty(NUMERIC_DOCVALUES_SYSPROP, "true");
Review comment:
Add brackets
##########
File path: solr/core/src/test/org/apache/solr/TestRandomFaceting.java
##########
@@ -233,165 +243,193 @@ void doFacetTests(FldType ftype) throws Exception {
}
if (rand.nextBoolean()) {
- params.add("facet.enum.cache.minDf",""+ rand.nextInt(indexSize));
+ params.add("facet.enum.cache.minDf", "" + rand.nextInt(indexSize));
}
-
+
// TODO: randomly add other facet params
String key = ftype.fname;
String facet_field = ftype.fname;
if (random().nextBoolean()) {
key = "alternate_key";
- facet_field = "{!key="+key+"}"+ftype.fname;
+ facet_field = "{!key=" + key + "}" + ftype.fname;
}
params.set("facet.field", facet_field);
List<String> methods = multiValued ? multiValuedMethods : singleValuedMethods;
List<String> responses = new ArrayList<>(methods.size());
-
+
for (String method : methods) {
- for (boolean exists : new boolean[]{false, true}) {
+ for (boolean exists : new boolean[] {false, true}) {
// params.add("facet.field", "{!key="+method+"}" + ftype.fname);
// TODO: allow method to be passed on local params?
- if (method!=null) {
+ if (method != null) {
params.set("facet.method", method);
} else {
params.remove("facet.method");
}
- params.set("facet.exists", ""+exists);
+ params.set("facet.exists", "" + exists);
if (!exists && rand.nextBoolean()) {
params.remove("facet.exists");
}
-
- // if (random().nextBoolean()) params.set("facet.mincount", "1"); // uncomment to test that validation fails
- if (!(params.getInt("facet.limit", 100) == 0 &&
- !params.getBool("facet.missing", false))) {
+
+ // if (random().nextBoolean()) params.set("facet.mincount", "1"); // uncomment to test
+ // that validation fails
+ if (!(params.getInt("facet.limit", 100) == 0
+ && !params.getBool("facet.missing", false))) {
// it bypasses all processing, and we can go to empty validation
- if (exists && params.getInt("facet.mincount", 0)>1) {
- assertQEx("no mincount on facet.exists",
- rand.nextBoolean() ? "facet.exists":"facet.mincount",
- req(params), ErrorCode.BAD_REQUEST);
+ if (exists && params.getInt("facet.mincount", 0) > 1) {
+ assertQEx(
+ "no mincount on facet.exists",
+ rand.nextBoolean() ? "facet.exists" : "facet.mincount",
+ req(params),
+ ErrorCode.BAD_REQUEST);
continue;
}
- // facet.exists can't be combined with non-enum nor with enum requested for tries, because it will be flipped to FC/FCS
+ // facet.exists can't be combined with non-enum nor with enum requested for tries,
+ // because it will be flipped to FC/FCS
final boolean notEnum = method != null && !method.equals("enum");
final boolean trieField = trieFields.matcher(ftype.fname).matches();
if ((notEnum || trieField) && exists) {
- assertQEx("facet.exists only when enum or ommitted",
- "facet.exists", req(params), ErrorCode.BAD_REQUEST);
+ assertQEx(
+ "facet.exists only when enum or ommitted",
+ "facet.exists",
+ req(params),
+ ErrorCode.BAD_REQUEST);
continue;
}
if (exists && sf.getType().isPointField()) {
// PointFields don't yet support "enum" method or the "facet.exists" parameter
- assertQEx("Expecting failure, since ",
- "facet.exists=true is requested, but facet.method=enum can't be used with " + sf.getName(),
- req(params), ErrorCode.BAD_REQUEST);
+ assertQEx(
+ "Expecting failure, since ",
+ "facet.exists=true is requested, but facet.method=enum can't be used with "
+ + sf.getName(),
+ req(params),
+ ErrorCode.BAD_REQUEST);
continue;
}
}
String strResponse = h.query(req(params));
responses.add(strResponse);
-
- if (responses.size()>1) {
+
+ if (responses.size() > 1) {
validateResponse(responses.get(0), strResponse, params, method, methods);
}
}
-
}
-
+
/**
- String strResponse = h.query(req(params));
- Object realResponse = ObjectBuilder.fromJSON(strResponse);
- **/
+ * String strResponse = h.query(req(params)); Object realResponse =
+ * ObjectBuilder.fromJSON(strResponse);
+ */
} finally {
req.close();
}
}
- private void validateResponse(String expected, String actual, ModifiableSolrParams params, String method,
- List<String> methods) throws Exception {
+
+ private void validateResponse(
+ String expected,
+ String actual,
+ ModifiableSolrParams params,
+ String method,
+ List<String> methods)
+ throws Exception {
if (params.getBool("facet.exists", false)) {
- if (isSortByCount(params)) { // it's challenged with facet.sort=count
- expected = getExpectationForSortByCount(params, methods);// that requires to recalculate expactation
+ if (isSortByCount(params)) { // it's challenged with facet.sort=count
+ expected =
+ getExpectationForSortByCount(
+ params, methods); // that requires to recalculate expactation
} else { // facet.sort=index
expected = capFacetCountsTo1(expected);
}
}
-
+
String err = JSONTestUtil.match("/", actual, expected, 0.0);
if (err != null) {
- log.error("ERROR: mismatch facet response: {}\n expected ={}\n response = {}\n request = {}"
- , err, expected, actual, params);
+ log.error(
+ "ERROR: mismatch facet response: {}\n expected ={}\n response = {}\n request = {}",
+ err,
+ expected,
+ actual,
+ params);
fail(err);
}
}
- /** if facet.exists=true with facet.sort=counts,
- * it should return all values with 1 hits ordered by label index
- * then all vals with 0 , and then missing count with null label,
- * in the implementation below they are called three stratas
- * */
+ /**
+ * if facet.exists=true with facet.sort=counts, it should return all values with 1 hits ordered by
+ * label index then all vals with 0 , and then missing count with null label, in the
+ * implementation below they are called three stratas
+ */
@SuppressWarnings({"unchecked"})
- private String getExpectationForSortByCount( ModifiableSolrParams params, List<String> methods) throws Exception {
+ private String getExpectationForSortByCount(ModifiableSolrParams params, List<String> methods)
+ throws Exception {
String indexSortedResponse = getIndexSortedAllFacetValues(params, methods);
-
- return transformFacetFields(indexSortedResponse, e -> {
- List<Object> facetSortedByIndex = (List<Object>) e.getValue();
- Map<Integer,List<Object>> stratas = new HashMap<Integer,List<Object>>(){
- @Override // poor man multimap, I won't do that anymore, I swear.
- public List<Object> get(Object key) {
- if (!containsKey(key)) {
- put((Integer) key, new ArrayList<>());
- }
- return super.get(key);
- }
- };
-
- for (@SuppressWarnings({"rawtypes"})Iterator iterator = facetSortedByIndex.iterator(); iterator.hasNext();) {
- Object label = iterator.next();
- Long count = (Long) iterator.next();
- final Integer strata;
- if (label==null) { // missing (here "stratas" seems like overengineering )
- strata = null;
- }else {
- if (count>0) {
- count = 1L; // capping here
- strata = 1; // non-zero count become zero
- } else {
- strata = 0; // zero-count
+
+ return transformFacetFields(
+ indexSortedResponse,
+ e -> {
+ List<Object> facetSortedByIndex = (List<Object>) e.getValue();
+ Map<Integer, List<Object>> stratas =
+ new HashMap<Integer, List<Object>>() {
+ @Override // poor man multimap, I won't do that anymore, I swear.
+ public List<Object> get(Object key) {
+ if (!containsKey(key)) {
+ put((Integer) key, new ArrayList<>());
+ }
+ return super.get(key);
+ }
+ };
+
+ for (@SuppressWarnings({"rawtypes"}) Iterator iterator = facetSortedByIndex.iterator();
+ iterator.hasNext(); ) {
+ Object label = iterator.next();
+ Long count = (Long) iterator.next();
+ final Integer strata;
+ if (label == null) { // missing (here "stratas" seems like overengineering )
+ strata = null;
+ } else {
+ if (count > 0) {
+ count = 1L; // capping here
+ strata = 1; // non-zero count become zero
+ } else {
+ strata = 0; // zero-count
+ }
+ }
+ final List<Object> facet = stratas.get(strata);
+ facet.add(label);
+ facet.add(count);
}
- }
- final List<Object> facet = stratas.get(strata);
- facet.add(label);
- facet.add(count);
- }
- @SuppressWarnings({"rawtypes"})
- List stratified =new ArrayList<>();
- for(Integer s : new Integer[]{1, 0}) { // non-zero capped to one goes first, zeroes go then
- stratified.addAll(stratas.get(s));
- }// cropping them now
- int offset=params.getInt("facet.offset", 0) * 2;
- int end = offset + params.getInt("facet.limit", 100) * 2 ;
- int fromIndex = offset > stratified.size() ? stratified.size() : offset;
- stratified = stratified.subList(fromIndex,
- end > stratified.size() ? stratified.size() : end);
-
- stratified.addAll(stratas.get(null));
-
- facetSortedByIndex.clear();
- facetSortedByIndex.addAll(stratified);
- });
+ @SuppressWarnings({"rawtypes"})
+ List stratified = new ArrayList<>();
+ for (Integer s :
+ new Integer[] {1, 0}) { // non-zero capped to one goes first, zeroes go then
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerSchemaAPI.java
##########
@@ -50,58 +50,68 @@
@BeforeClass
public static void initClass() throws Exception {
assertNull("no system props clash please", System.getProperty("managed.schema.mutable"));
- System.setProperty("managed.schema.mutable", ""+//true
- random().nextBoolean()
- );
+ System.setProperty(
+ "managed.schema.mutable",
+ ""
+ + // true
+ random().nextBoolean());
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/DocValuesNotIndexedTest.java
##########
@@ -343,7 +377,8 @@ private void doGroupingDvOnly(List<FieldProps> fieldProps, String boolName) thro
}
docs.add(doc);
- // Every fifth time through we add a doc with no values in any of the "fields of interest", so there should be
+ // Every fifth time through we add a doc with no values in any of the "fields of interest", so
+ // there should be
// 10 docs with nulls
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerSchemaAPI.java
##########
@@ -50,58 +50,68 @@
@BeforeClass
public static void initClass() throws Exception {
assertNull("no system props clash please", System.getProperty("managed.schema.mutable"));
- System.setProperty("managed.schema.mutable", ""+//true
- random().nextBoolean()
- );
+ System.setProperty(
+ "managed.schema.mutable",
+ ""
+ + // true
+ random().nextBoolean());
Path tmpHome = createTempDir("tmp-home");
Path coreDir = tmpHome.resolve(DEFAULT_TEST_CORENAME);
copyMinConf(coreDir.toFile(), null, "solrconfig-managed-schema.xml");
- initCore("solrconfig.xml" /*it's renamed to to*/, "schema.xml", tmpHome.toAbsolutePath().toString());
-
+ initCore(
+ "solrconfig.xml" /*it's renamed to to*/, "schema.xml", tmpHome.toAbsolutePath().toString());
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/SolrTestCaseJ4Test.java
##########
@@ -17,33 +17,36 @@
package org.apache.solr;
import java.io.File;
-
import org.apache.commons.io.FileUtils;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-
public class SolrTestCaseJ4Test extends SolrTestCaseJ4 {
private static String tmpSolrHome;
@BeforeClass
public static void beforeClass() throws Exception {
- // Create a temporary directory that holds a core NOT named "collection1". Use the smallest configuration sets
+ // Create a temporary directory that holds a core NOT named "collection1". Use the smallest
+ // configuration sets
// we can so we don't copy that much junk around.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/AssignBackwardCompatibilityTest.java
##########
@@ -36,9 +35,8 @@
import org.slf4j.LoggerFactory;
/**
- * Test for backward compatibility when users update from 6.x or 7.0 to 7.1,
- * then the counter of collection does not exist in Zk
- * TODO Remove in Solr 9.0
+ * Test for backward compatibility when users update from 6.x or 7.0 to 7.1, then the counter of
+ * collection does not exist in Zk TODO Remove in Solr 9.0
Review comment:
Review this
##########
File path: solr/core/src/test/org/apache/solr/TestRandomFaceting.java
##########
@@ -233,165 +243,193 @@ void doFacetTests(FldType ftype) throws Exception {
}
if (rand.nextBoolean()) {
- params.add("facet.enum.cache.minDf",""+ rand.nextInt(indexSize));
+ params.add("facet.enum.cache.minDf", "" + rand.nextInt(indexSize));
}
-
+
// TODO: randomly add other facet params
String key = ftype.fname;
String facet_field = ftype.fname;
if (random().nextBoolean()) {
key = "alternate_key";
- facet_field = "{!key="+key+"}"+ftype.fname;
+ facet_field = "{!key=" + key + "}" + ftype.fname;
}
params.set("facet.field", facet_field);
List<String> methods = multiValued ? multiValuedMethods : singleValuedMethods;
List<String> responses = new ArrayList<>(methods.size());
-
+
for (String method : methods) {
- for (boolean exists : new boolean[]{false, true}) {
+ for (boolean exists : new boolean[] {false, true}) {
// params.add("facet.field", "{!key="+method+"}" + ftype.fname);
// TODO: allow method to be passed on local params?
- if (method!=null) {
+ if (method != null) {
params.set("facet.method", method);
} else {
params.remove("facet.method");
}
- params.set("facet.exists", ""+exists);
+ params.set("facet.exists", "" + exists);
if (!exists && rand.nextBoolean()) {
params.remove("facet.exists");
}
-
- // if (random().nextBoolean()) params.set("facet.mincount", "1"); // uncomment to test that validation fails
- if (!(params.getInt("facet.limit", 100) == 0 &&
- !params.getBool("facet.missing", false))) {
+
+ // if (random().nextBoolean()) params.set("facet.mincount", "1"); // uncomment to test
+ // that validation fails
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java
##########
@@ -759,13 +928,16 @@ private void searchSeveralWays(String collectionList, SolrParams solrQuery, Cons
}
}
- // note: collectionList could be null when we randomly recurse and put the actual collection list into the
- // "collection" param and some bugs value into collectionList (including null). Only CloudSolrClient supports null.
+ // note: collectionList could be null when we randomly recurse and put the actual collection
+ // list into the
+ // "collection" param and some bugs value into collectionList (including null). Only
+ // CloudSolrClient supports null.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
##########
@@ -20,21 +20,21 @@
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.junit.Test;
-
/**
- * This test simply does a bunch of basic things in solrcloud mode and asserts things
- * work as expected.
- * Implementation moved to AbstractBasicDistributedZkTestBase as it is used by many HDFS contrib tests.
+ * This test simply does a bunch of basic things in solrcloud mode and asserts things work as
+ * expected. Implementation moved to AbstractBasicDistributedZkTestBase as it is used by many HDFS
+ * contrib tests.
*/
-@Slow
+@Slow
@SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776")
public class BasicDistributedZkTest extends AbstractBasicDistributedZkTestBase {
-
@Test
@Override
@ShardsFixed(num = 4)
- // commented out on: 17-Feb-2019 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on: 24-Dec-2018
+ // commented out on: 17-Feb-2019
+ // @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on:
+ // 24-Dec-2018
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java
##########
@@ -432,19 +478,29 @@ private void assertSuccess(HttpUriRequest msg) throws IOException {
//
// What happens when they delete old_collection now?
//
- // Current behavior is that delete "does the right thing" and deletes old_collection rather than new_collection,
- // but if this behavior changes it could be disastrous for users so this test insures that this behavior.
+ // Current behavior is that delete "does the right thing" and deletes old_collection rather than
+ // new_collection,
+ // but if this behavior changes it could be disastrous for users so this test insures that this
+ // behavior.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/HttpPartitionOnCommitTest.java
##########
@@ -57,7 +56,8 @@ public HttpPartitionOnCommitTest() {
@Override
protected boolean useTlogReplicas() {
- return false; // TODO: tlog replicas makes commits take way to long due to what is likely a bug and it's TestInjection use
+ return false; // TODO: tlog replicas makes commits take way to long due to what is likely a bug
+ // and it's TestInjection use
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/TestJoin.java
##########
@@ -45,29 +44,93 @@ public static void beforeTests() throws Exception {
System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
System.setProperty("solr.filterCache.async", "true");
- if (System.getProperty("solr.tests.IntegerFieldType").contains("Point")) { // all points change at the same time
+ if (System.getProperty("solr.tests.IntegerFieldType")
+ .contains("Point")) { // all points change at the same time
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderWithPullReplicasTest.java
##########
@@ -43,27 +42,29 @@
@Slow
public class ChaosMonkeySafeLeaderWithPullReplicasTest extends AbstractFullDistribZkTestBase {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
- private static final Integer RUN_LENGTH = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.runlength", "-1"));
-
+
+ private static final Integer RUN_LENGTH =
+ Integer.parseInt(System.getProperty("solr.tests.cloud.cm.runlength", "-1"));
+
private final boolean useTlogReplicas = random().nextBoolean();
-
+
private final int numPullReplicas;
private final int numRealtimeOrTlogReplicas;
-
+
@Override
protected int getPullReplicaCount() {
return numPullReplicas;
}
-
+
@Override
protected boolean useTlogReplicas() {
- return false; // TODO: tlog replicas makes commits take way to long due to what is likely a bug and it's TestInjection use
+ return false; // TODO: tlog replicas makes commits take way to long due to what is likely a bug
+ // and it's TestInjection use
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java
##########
@@ -417,10 +461,12 @@ private void assertSuccess(HttpUriRequest msg) throws IOException {
}
}
}
- // Rather a long title, but it's common to recommend when people need to re-index for any reason that they:
+ // Rather a long title, but it's common to recommend when people need to re-index for any reason
+ // that they:
// 1> create a new collection
// 2> index the corpus to the new collection and verify it
- // 3> create an alias pointing to the new collection WITH THE SAME NAME as their original collection
+ // 3> create an alias pointing to the new collection WITH THE SAME NAME as their original
+ // collection
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/TestRandomDVFaceting.java
##########
@@ -254,14 +278,15 @@ void doFacetTests(FldType ftype) throws Exception {
List<String> responses = new ArrayList<>(methods.size());
for (String method : methods) {
if (method.equals("dv")) {
- params.set("facet.field", "{!key="+facet_field+"}"+facet_field+"_dv");
- params.set("facet.method",(String) null);
+ params.set("facet.field", "{!key=" + facet_field + "}" + facet_field + "_dv");
+ params.set("facet.method", (String) null);
} else {
params.set("facet.field", facet_field);
params.set("facet.method", method);
}
- // if (random().nextBoolean()) params.set("facet.mincount", "1"); // uncomment to test that validation fails
+ // if (random().nextBoolean()) params.set("facet.mincount", "1"); // uncomment to test that
+ // validation fails
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/analysis/ProtectedTermFilterFactoryTest.java
##########
@@ -32,53 +31,61 @@
@BeforeClass
public static void beforeClass() throws Exception {
- initCore("solrconfig.xml","schema-protected-term.xml");
+ initCore("solrconfig.xml", "schema-protected-term.xml");
}
public void testBasic() throws Exception {
String text = "Wuthering FooBar distant goldeN ABC compote";
- Map<String,String> args = new HashMap<>();
+ Map<String, String> args = new HashMap<>();
args.put("ignoreCase", "true");
- args.put("protected", "protected-1.txt,protected-2.txt"); // Protected: foobar, jaxfopbuz, golden, compote
+ args.put(
+ "protected",
+ "protected-1.txt,protected-2.txt"); // Protected: foobar, jaxfopbuz, golden, compote
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPullReplicasTest.java
##########
@@ -132,36 +132,48 @@ public ChaosMonkeyNothingIsSafeWithPullReplicasTest() {
@Override
protected boolean useTlogReplicas() {
- return false; // TODO: tlog replicas makes commits take way to long due to what is likely a bug and it's TestInjection use
+ return false; // TODO: tlog replicas makes commits take way to long due to what is likely a bug
+ // and it's TestInjection use
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/HttpPartitionOnCommitTest.java
##########
@@ -147,7 +156,9 @@ private void oneShardTest() throws Exception {
sendCommitWithRetry(replica);
Thread.sleep(sleepMsBeforeHealPartition);
- cloudClient.getZkStateReader().forceUpdateCollection(testCollectionName); // get the latest state
+ cloudClient
+ .getZkStateReader()
+ .forceUpdateCollection(testCollectionName); // get the latest state
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderWithPullReplicasTest.java
##########
@@ -110,51 +111,70 @@ public ChaosMonkeySafeLeaderWithPullReplicasTest() {
fixShardCount(numNodes);
log.info("Starting ChaosMonkey test with {} shards and {} nodes", sliceCount, numNodes);
}
-
+
@Test
- //2018-06-18 (commented) @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028")
+ // 2018-06-18 (commented) @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028")
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
##########
@@ -66,17 +66,17 @@
import org.slf4j.LoggerFactory;
/**
- * Simulates HTTP partitions between a leader and replica but the replica does
- * not lose its ZooKeeper connection.
+ * Simulates HTTP partitions between a leader and replica but the replica does not lose its
+ * ZooKeeper connection.
*/
-
@Slow
@SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776")
-// commented out on: 24-Dec-2018 @LuceneTestCase.BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // 2018-06-18
+// commented out on: 24-Dec-2018
+// @LuceneTestCase.BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // 2018-06-18
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java
##########
@@ -43,26 +42,28 @@ public static void beforeClass() {
@Override
public void setUp() throws Exception {
super.setUp();
- configureCluster(6)
- .addConfig("conf", configset("cloud-minimal"))
- .configure();
+ configureCluster(6).addConfig("conf", configset("cloud-minimal")).configure();
}
-
private void createCollection(String collection) throws IOException, SolrServerException {
- assertEquals(0, CollectionAdminRequest.createCollection(collection,
- "conf", 2, 1)
- .process(cluster.getSolrClient()).getStatus());
+ assertEquals(
+ 0,
+ CollectionAdminRequest.createCollection(collection, "conf", 2, 1)
+ .process(cluster.getSolrClient())
+ .getStatus());
for (int i = 1; i < NUM_REPLICAS_OF_SHARD1; i++) {
assertTrue(
- CollectionAdminRequest.addReplicaToShard(collection, "shard1").process(cluster.getSolrClient()).isSuccess()
- );
+ CollectionAdminRequest.addReplicaToShard(collection, "shard1")
+ .process(cluster.getSolrClient())
+ .isSuccess());
}
}
@Test
// 12-Jun-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // 04-May-2018
- // commented 4-Sep-2018 @LuceneTestCase.BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // 2-Aug-2018
+ // commented 4-Sep-2018
+ // @LuceneTestCase.BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") //
+ // 2-Aug-2018
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ConcurrentCreateRoutedAliasTest.java
##########
@@ -59,35 +59,48 @@ public void tearDown() throws Exception {
}
@Test
- public void testConcurrentCreateRoutedAliasMinimal() throws IOException, KeeperException.NoNodeException {
+ public void testConcurrentCreateRoutedAliasMinimal()
+ throws IOException, KeeperException.NoNodeException {
// this is the test where be blow out a bunch of create commands all out at once.
// other tests are more functionality based, and just use a single thread.
- // Failure of this test very occasionally due to overseer overload would not be worrisome (just bothersome).
- // Any use case creating large numbers of time routed aliases concurrently would be an EXTREMELY odd
+ // Failure of this test very occasionally due to overseer overload would not be worrisome (just
+ // bothersome).
+ // Any use case creating large numbers of time routed aliases concurrently would be an EXTREMELY
+ // odd
// if not fundamentally broken use case. This test method is just here to guard against any race
// conditions in the code that could crop up rarely in lower volume usage.
- // That said any failures involving about NPE's or missing parameters or oddities other than overwhelming
- // the overseer queue with retry races emanating from this test should be investigated. Also if it fails
+ // That said any failures involving about NPE's or missing parameters or oddities other than
+ // overwhelming
+ // the overseer queue with retry races emanating from this test should be investigated. Also if
+ // it fails
// frequently that needs to be investigated of course.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/CleanupOldIndexTest.java
##########
@@ -62,12 +61,15 @@ public void test() throws Exception {
CollectionAdminRequest.createCollection(COLLECTION, "conf1", 1, 2)
.processAndWait(cluster.getSolrClient(), DEFAULT_TIMEOUT);
- cluster.getSolrClient().setDefaultCollection(COLLECTION); // TODO make this configurable on StoppableIndexingThread
+ cluster
+ .getSolrClient()
+ .setDefaultCollection(COLLECTION); // TODO make this configurable on StoppableIndexingThread
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/CollectionPropsTest.java
##########
@@ -132,54 +132,79 @@ public boolean onStateChanged(Map<String,String> collectionProperties) {
collectionProps.setCollectionProperty(collectionName, "property2", "newValue");
waitForValue("property1", null, 5000);
waitForValue("property2", "newValue", 5000);
-
+
collectionProps.setCollectionProperty(collectionName, "property2", null);
waitForValue("property2", null, 5000);
-
+
collectionProps.setCollectionProperty(collectionName, "property2", null); // no change
checkValue("property2", null);
- assertTrue("Gave up waitng an excessive amount of time for watcher to see final expected props",
- sawExpectedProps.tryAcquire(1, 120, TimeUnit.SECONDS));
+ assertTrue(
+ "Gave up waitng an excessive amount of time for watcher to see final expected props",
+ sawExpectedProps.tryAcquire(1, 120, TimeUnit.SECONDS));
cluster.getSolrClient().getZkStateReader().removeCollectionPropsWatcher(collectionName, w);
-
+
collectionProps.setCollectionProperty(collectionName, "property1", "value1");
- checkValue("property1", "value1"); //Should be no cache, so the change should take effect immediately
-
+ checkValue(
+ "property1", "value1"); // Should be no cache, so the change should take effect immediately
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ClusterStateMockUtil.java
##########
@@ -126,20 +100,30 @@ public static ZkStateReader buildClusterState(String clusterDescription, int rep
switch (m.group(1)) {
case "c":
slices = new HashMap<>();
- collectionProps.put(ZkStateReader.CONFIGNAME_PROP, ConfigSetsHandler.DEFAULT_CONFIGSET_NAME);
- docCollection = new DocCollection(collName = "collection" + (collectionStates.size() + 1), slices, collectionProps, DocRouter.DEFAULT);
+ collectionProps.put(
+ ZkStateReader.CONFIGNAME_PROP, ConfigSetsHandler.DEFAULT_CONFIGSET_NAME);
+ docCollection =
+ new DocCollection(
+ collName = "collection" + (collectionStates.size() + 1),
+ slices,
+ collectionProps,
+ DocRouter.DEFAULT);
collectionStates.put(docCollection.getName(), docCollection);
break;
case "s":
replicas = new HashMap<>();
- if(collName == null) collName = "collection" + (collectionStates.size() + 1);
- slice = new Slice(sliceName = "slice" + (slices.size() + 1), replicas, null, collName);
+ if (collName == null) collName = "collection" + (collectionStates.size() + 1);
+ slice = new Slice(sliceName = "slice" + (slices.size() + 1), replicas, null, collName);
slices.put(slice.getName(), slice);
- // hack alert: the DocCollection constructor copies over active slices to its active slice map in the constructor
- // but here we construct the DocCollection before creating the slices which breaks code that calls DocCollection.getActiveSlices
- // so here we re-create doc collection with the latest slices map to workaround this problem
- // todo: a better fix would be to have a builder class for DocCollection that builds the final object once all the slices and replicas have been created.
+ // hack alert: the DocCollection constructor copies over active slices to its active slice
+ // map in the constructor
+ // but here we construct the DocCollection before creating the slices which breaks code
+ // that calls DocCollection.getActiveSlices
+ // so here we re-create doc collection with the latest slices map to workaround this
+ // problem
+ // todo: a better fix would be to have a builder class for DocCollection that builds the
+ // final object once all the slices and replicas have been created.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
##########
@@ -90,42 +90,46 @@ public static void setupSysProps() {
System.setProperty("distribUpdateSoTimeout", "10000");
System.setProperty("solr.httpclient.retries", "0");
System.setProperty("solr.retries.on.forward", "0");
- System.setProperty("solr.retries.to.followers", "0");
+ System.setProperty("solr.retries.to.followers", "0");
}
-
+
public HttpPartitionTest() {
super();
sliceCount = 2;
fixShardCount(3);
}
- /**
- * We need to turn off directUpdatesToLeadersOnly due to SOLR-9512
- */
+ /** We need to turn off directUpdatesToLeadersOnly due to SOLR-9512 */
@Override
protected CloudSolrClient createCloudClient(String defaultCollection) {
- CloudSolrClient client = new CloudSolrClient.Builder(Collections.singletonList(zkServer.getZkAddress()), Optional.empty())
- .sendDirectUpdatesToAnyShardReplica()
- .withConnectionTimeout(5000)
- .withSocketTimeout(10000)
- .build();
+ CloudSolrClient client =
+ new CloudSolrClient.Builder(
+ Collections.singletonList(zkServer.getZkAddress()), Optional.empty())
+ .sendDirectUpdatesToAnyShardReplica()
+ .withConnectionTimeout(5000)
+ .withSocketTimeout(10000)
+ .build();
if (defaultCollection != null) client.setDefaultCollection(defaultCollection);
return client;
}
- /**
- * Overrides the parent implementation to install a SocketProxy in-front of the Jetty server.
- */
+ /** Overrides the parent implementation to install a SocketProxy in-front of the Jetty server. */
@Override
- public JettySolrRunner createJetty(File solrHome, String dataDir,
- String shardList, String solrConfigOverride, String schemaOverride, Replica.Type replicaType)
- throws Exception
- {
- return createProxiedJetty(solrHome, dataDir, shardList, solrConfigOverride, schemaOverride, replicaType);
+ public JettySolrRunner createJetty(
+ File solrHome,
+ String dataDir,
+ String shardList,
+ String solrConfigOverride,
+ String schemaOverride,
+ Replica.Type replicaType)
+ throws Exception {
+ return createProxiedJetty(
+ solrHome, dataDir, shardList, solrConfigOverride, schemaOverride, replicaType);
}
@Test
- // commented out on: 24-Dec-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028")
+ // commented out on: 24-Dec-2018
+ // @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028")
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ConfigSetApiLockingTest.java
##########
@@ -84,41 +91,57 @@ private void monothreadedTests(ConfigSetApiLockFactory apiLockingHelper) throws
private void multithreadedTests(ConfigSetApiLockFactory apiLockingHelper) throws Exception {
// This lock does have a base config set
- DistributedMultiLock cs2Lock = apiLockingHelper.createConfigSetApiLock(CONFIG_SET_NAME_2, BASE_CONFIG_SET_NAME);
+ DistributedMultiLock cs2Lock =
+ apiLockingHelper.createConfigSetApiLock(CONFIG_SET_NAME_2, BASE_CONFIG_SET_NAME);
assertTrue("cs2Lock should have been acquired", cs2Lock.isAcquired());
// But we shouldn't be able to lock at this stage the base config set
- DistributedMultiLock csBaseLock = apiLockingHelper.createConfigSetApiLock(BASE_CONFIG_SET_NAME, null);
+ DistributedMultiLock csBaseLock =
+ apiLockingHelper.createConfigSetApiLock(BASE_CONFIG_SET_NAME, null);
assertFalse("csBaseLock should not have been acquired", csBaseLock.isAcquired());
- // Wait for acquisition of the base config set lock on another thread (and be notified via a latch)
+ // Wait for acquisition of the base config set lock on another thread (and be notified via a
+ // latch)
final CountDownLatch latch = new CountDownLatch(1);
- new Thread(() -> {
- csBaseLock.waitUntilAcquired();
- // countDown() will not be called if waitUntilAcquired() threw exception of any kind
- latch.countDown();
- }).start();
+ new Thread(
+ () -> {
+ csBaseLock.waitUntilAcquired();
+ // countDown() will not be called if waitUntilAcquired() threw exception of any kind
+ latch.countDown();
+ })
+ .start();
// Wait for the thread to start and to get blocked in waitUntilAcquired()
- // (thread start could have been checked more reliably using another latch, and verifying the thread is in waitUntilAcquired
- // done through that thread stacktrace, but that would be overkill compared to the very slight race condition of waiting 30ms,
- // but a race that would not cause the test to fail since we're testing... that nothing happened yet).
+ // (thread start could have been checked more reliably using another latch, and verifying the
+ // thread is in waitUntilAcquired
+ // done through that thread stacktrace, but that would be overkill compared to the very slight
+ // race condition of waiting 30ms,
+ // but a race that would not cause the test to fail since we're testing... that nothing happened
+ // yet).
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ConcurrentCreateRoutedAliasTest.java
##########
@@ -34,7 +33,8 @@
import org.slf4j.LoggerFactory;
@LuceneTestCase.Slow
-@LuceneTestCase.AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-12386") // "Can't find resource"
+@LuceneTestCase.AwaitsFix(
+ bugUrl = "https://issues.apache.org/jira/browse/SOLR-12386") // "Can't find resource"
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ConcurrentCreateRoutedAliasTest.java
##########
@@ -59,35 +59,48 @@ public void tearDown() throws Exception {
}
@Test
- public void testConcurrentCreateRoutedAliasMinimal() throws IOException, KeeperException.NoNodeException {
+ public void testConcurrentCreateRoutedAliasMinimal()
+ throws IOException, KeeperException.NoNodeException {
// this is the test where be blow out a bunch of create commands all out at once.
// other tests are more functionality based, and just use a single thread.
- // Failure of this test very occasionally due to overseer overload would not be worrisome (just bothersome).
- // Any use case creating large numbers of time routed aliases concurrently would be an EXTREMELY odd
+ // Failure of this test very occasionally due to overseer overload would not be worrisome (just
+ // bothersome).
+ // Any use case creating large numbers of time routed aliases concurrently would be an EXTREMELY
+ // odd
// if not fundamentally broken use case. This test method is just here to guard against any race
// conditions in the code that could crop up rarely in lower volume usage.
- // That said any failures involving about NPE's or missing parameters or oddities other than overwhelming
- // the overseer queue with retry races emanating from this test should be investigated. Also if it fails
+ // That said any failures involving about NPE's or missing parameters or oddities other than
+ // overwhelming
+ // the overseer queue with retry races emanating from this test should be investigated. Also if
+ // it fails
// frequently that needs to be investigated of course.
-
final AtomicReference<Exception> failure = new AtomicReference<>();
- // Note: this number of threads seems to work regularly with the up-tweaked number of retries (50) in
+ // Note: this number of threads seems to work regularly with the up-tweaked number of retries
+ // (50) in
// org.apache.solr.common.cloud.ZkStateReader.AliasesManager.applyModificationAndExportToZk()
- // with the original 5 retries this wouldn't reliably pass with 10 threads, but with 50 retries it seems
+ // with the original 5 retries this wouldn't reliably pass with 10 threads, but with 50 retries
+ // it seems
// to handle 50 threads about a dozen times without any failure (on a 32 thread processor)
// it also passed 3/3 at 150 threads and 2/3 with 250 threads on both 1 node and 4 nodes...
- // the failure mode seems to be overseer tasks that are not found. I suspect this happens when enough
- // threads get into retry races and the spam overwhelms the overseer. (that this can happen might imply
- // an issue over there, but I'm not sure, since there is an intentional hard limit on the overseer queue
- // and I haven't tried to count the retries up and figure out if the requests are actually exceeding that
- // limit or not, but the speed of retries might indicate an effectively hot loop, but again, a separate issue.
-
- // The hope is that the level of concurrency supported by create routed alias and the code it uses is such
- // that this test wouldn't spuriously fail more than once a year. If that's true users should never see
+ // the failure mode seems to be overseer tasks that are not found. I suspect this happens when
+ // enough
+ // threads get into retry races and the spam overwhelms the overseer. (that this can happen
+ // might imply
+ // an issue over there, but I'm not sure, since there is an intentional hard limit on the
+ // overseer queue
+ // and I haven't tried to count the retries up and figure out if the requests are actually
+ // exceeding that
+ // limit or not, but the speed of retries might indicate an effectively hot loop, but again, a
+ // separate issue.
+
+ // The hope is that the level of concurrency supported by create routed alias and the code it
+ // uses is such
+ // that this test wouldn't spuriously fail more than once a year. If that's true users should
+ // never see
// an issue in the wild unless they are doing something we probably don't want to support anyway
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
##########
@@ -227,71 +264,88 @@ public void deleteReplicaFromClusterState() throws Exception {
Slice shard = getCollectionState(collectionName).getSlice("shard1");
// don't choose the leader to shutdown, it just complicates things unnecessarily
- Replica replica = getRandomReplica(shard, (r) ->
- ( r.getState() == Replica.State.ACTIVE &&
- ! r.equals(shard.getLeader())));
-
+ Replica replica =
+ getRandomReplica(
+ shard, (r) -> (r.getState() == Replica.State.ACTIVE && !r.equals(shard.getLeader())));
+
JettySolrRunner replicaJetty = cluster.getReplicaJetty(replica);
ZkController replicaZkController = replicaJetty.getCoreContainer().getZkController();
- ZkStateReaderAccessor accessor = new ZkStateReaderAccessor(replicaZkController.getZkStateReader());
-
- final long preDeleteWatcherCount = countUnloadCoreOnDeletedWatchers
- (accessor.getStateWatchers(collectionName));
-
- ZkNodeProps m = new ZkNodeProps(
- Overseer.QUEUE_OPERATION, OverseerAction.DELETECORE.toLower(),
- ZkStateReader.CORE_NAME_PROP, replica.getCoreName(),
- ZkStateReader.NODE_NAME_PROP, replica.getNodeName(),
- ZkStateReader.BASE_URL_PROP, replicaZkController.getZkStateReader().getBaseUrlForNodeName(replica.getNodeName()),
- ZkStateReader.COLLECTION_PROP, collectionName,
- ZkStateReader.CORE_NODE_NAME_PROP, replica.getName());
+ ZkStateReaderAccessor accessor =
+ new ZkStateReaderAccessor(replicaZkController.getZkStateReader());
+
+ final long preDeleteWatcherCount =
+ countUnloadCoreOnDeletedWatchers(accessor.getStateWatchers(collectionName));
+
+ ZkNodeProps m =
+ new ZkNodeProps(
+ Overseer.QUEUE_OPERATION, OverseerAction.DELETECORE.toLower(),
+ ZkStateReader.CORE_NAME_PROP, replica.getCoreName(),
+ ZkStateReader.NODE_NAME_PROP, replica.getNodeName(),
+ ZkStateReader.BASE_URL_PROP,
+ replicaZkController.getZkStateReader().getBaseUrlForNodeName(replica.getNodeName()),
+ ZkStateReader.COLLECTION_PROP, collectionName,
+ ZkStateReader.CORE_NODE_NAME_PROP, replica.getName());
if (replicaZkController.getDistributedClusterStateUpdater().isDistributedStateUpdate()) {
- cluster.getOpenOverseer().getDistributedClusterStateUpdater().doSingleStateUpdate(
- DistributedClusterStateUpdater.MutatingCommand.SliceRemoveReplica, m,
- cluster.getOpenOverseer().getSolrCloudManager(),
- cluster.getOpenOverseer().getZkStateReader());
+ cluster
+ .getOpenOverseer()
+ .getDistributedClusterStateUpdater()
+ .doSingleStateUpdate(
+ DistributedClusterStateUpdater.MutatingCommand.SliceRemoveReplica,
+ m,
+ cluster.getOpenOverseer().getSolrCloudManager(),
+ cluster.getOpenOverseer().getZkStateReader());
} else {
cluster.getOpenOverseer().getStateUpdateQueue().offer(Utils.toJSON(m));
}
- waitForState("Timeout waiting for replica get deleted", collectionName,
- (liveNodes, collectionState) -> collectionState.getSlice("shard1").getReplicas().size() == 2);
+ waitForState(
+ "Timeout waiting for replica get deleted",
+ collectionName,
+ (liveNodes, collectionState) ->
+ collectionState.getSlice("shard1").getReplicas().size() == 2);
TimeOut timeOut = new TimeOut(60, TimeUnit.SECONDS, TimeSource.NANO_TIME);
- timeOut.waitFor("Waiting for replica get unloaded", () ->
- replicaJetty.getCoreContainer().getCoreDescriptor(replica.getCoreName()) == null
- );
-
+ timeOut.waitFor(
+ "Waiting for replica get unloaded",
+ () -> replicaJetty.getCoreContainer().getCoreDescriptor(replica.getCoreName()) == null);
+
// the core should no longer have a watch collection state since it was removed
timeOut = new TimeOut(60, TimeUnit.SECONDS, TimeSource.NANO_TIME);
- timeOut.waitFor("Waiting for core's watcher to be removed", () -> {
- final long postDeleteWatcherCount = countUnloadCoreOnDeletedWatchers
- (accessor.getStateWatchers(collectionName));
- log.info("preDeleteWatcherCount={} vs postDeleteWatcherCount={}",
- preDeleteWatcherCount, postDeleteWatcherCount);
- return (preDeleteWatcherCount - 1L == postDeleteWatcherCount);
- });
-
+ timeOut.waitFor(
+ "Waiting for core's watcher to be removed",
+ () -> {
+ final long postDeleteWatcherCount =
+ countUnloadCoreOnDeletedWatchers(accessor.getStateWatchers(collectionName));
+ log.info(
+ "preDeleteWatcherCount={} vs postDeleteWatcherCount={}",
+ preDeleteWatcherCount,
+ postDeleteWatcherCount);
+ return (preDeleteWatcherCount - 1L == postDeleteWatcherCount);
+ });
+
CollectionAdminRequest.deleteCollection(collectionName).process(cluster.getSolrClient());
}
@Test
@Slow
- // commented out on: 17-Feb-2019 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on: 24-Dec-2018
+ // commented out on: 17-Feb-2019
+ // @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on:
+ // 24-Dec-2018
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/CreateRoutedAliasTest.java
##########
@@ -88,7 +85,8 @@ public void doAfter() throws Exception {
}
}
- // This is a fairly complete test where we set many options and see that it both affected the created
+ // This is a fairly complete test where we set many options and see that it both affected the
+ // created
// collection and that the alias metadata was saved accordingly
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
##########
@@ -89,135 +88,173 @@ public void tearDown() throws Exception {
}
@Test
- // commented out on: 01-Apr-2019 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on: 24-Dec-2018
+ // commented out on: 01-Apr-2019
+ // @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on:
+ // 24-Dec-2018
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/DocValuesNotIndexedTest.java
##########
@@ -182,17 +183,18 @@ public void clean() throws IOException, SolrServerException {
resetFields(fieldsToTestMulti);
resetFields(fieldsToTestGroupSortFirst);
resetFields(fieldsToTestGroupSortLast);
-
}
void resetFields(List<FieldProps> fieldProps) {
for (FieldProps prop : fieldProps) {
prop.resetBase();
}
}
+
@Test
public void testDistribFaceting() throws IOException, SolrServerException {
- // For this test, I want to insure that there are shards that do _not_ have a doc with any of the DV_only
+ // For this test, I want to insure that there are shards that do _not_ have a doc with any of
+ // the DV_only
// fields, see SOLR-5260. So I'll add exactly 1 document to a 4 shard collection.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
##########
@@ -89,135 +88,173 @@ public void tearDown() throws Exception {
}
@Test
- // commented out on: 01-Apr-2019 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on: 24-Dec-2018
+ // commented out on: 01-Apr-2019
+ // @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on:
+ // 24-Dec-2018
public void deleteLiveReplicaTest() throws Exception {
final String collectionName = "delLiveColl";
Create req = CollectionAdminRequest.createCollection(collectionName, "conf", 2, 2);
req.process(cluster.getSolrClient());
-
+
cluster.waitForActiveCollection(collectionName, 2, 4);
DocCollection state = getCollectionState(collectionName);
Slice shard = getRandomShard(state);
-
+
// don't choose the leader to shutdown, it just complicates things unneccessarily
- Replica replica = getRandomReplica(shard, (r) ->
- ( r.getState() == Replica.State.ACTIVE &&
- ! r.equals(shard.getLeader())));
+ Replica replica =
+ getRandomReplica(
+ shard, (r) -> (r.getState() == Replica.State.ACTIVE && !r.equals(shard.getLeader())));
CoreStatus coreStatus = getCoreStatus(replica);
Path dataDir = Paths.get(coreStatus.getDataDirectory());
- Exception e = expectThrows(Exception.class, () -> {
- CollectionAdminRequest.deleteReplica(collectionName, shard.getName(), replica.getName())
- .setOnlyIfDown(true)
- .process(cluster.getSolrClient());
- });
- assertTrue("Unexpected error message: " + e.getMessage(), e.getMessage().contains("state is 'active'"));
- assertTrue("Data directory for " + replica.getName() + " should not have been deleted", Files.exists(dataDir));
+ Exception e =
+ expectThrows(
+ Exception.class,
+ () -> {
+ CollectionAdminRequest.deleteReplica(
+ collectionName, shard.getName(), replica.getName())
+ .setOnlyIfDown(true)
+ .process(cluster.getSolrClient());
+ });
+ assertTrue(
+ "Unexpected error message: " + e.getMessage(),
+ e.getMessage().contains("state is 'active'"));
+ assertTrue(
+ "Data directory for " + replica.getName() + " should not have been deleted",
+ Files.exists(dataDir));
JettySolrRunner replicaJetty = cluster.getReplicaJetty(replica);
- ZkStateReaderAccessor accessor = new ZkStateReaderAccessor(replicaJetty.getCoreContainer().getZkController().getZkStateReader());
+ ZkStateReaderAccessor accessor =
+ new ZkStateReaderAccessor(
+ replicaJetty.getCoreContainer().getZkController().getZkStateReader());
+
+ final long preDeleteWatcherCount =
+ countUnloadCoreOnDeletedWatchers(accessor.getStateWatchers(collectionName));
- final long preDeleteWatcherCount = countUnloadCoreOnDeletedWatchers
- (accessor.getStateWatchers(collectionName));
-
CollectionAdminRequest.deleteReplica(collectionName, shard.getName(), replica.getName())
.process(cluster.getSolrClient());
- waitForState("Expected replica " + replica.getName() + " to have been removed", collectionName, (n, c) -> {
- Slice testShard = c.getSlice(shard.getName());
- return testShard.getReplica(replica.getName()) == null;
- });
-
+ waitForState(
+ "Expected replica " + replica.getName() + " to have been removed",
+ collectionName,
+ (n, c) -> {
+ Slice testShard = c.getSlice(shard.getName());
+ return testShard.getReplica(replica.getName()) == null;
+ });
+
// the core should no longer have a watch collection state since it was removed
// the core should no longer have a watch collection state since it was removed
TimeOut timeOut = new TimeOut(60, TimeUnit.SECONDS, TimeSource.NANO_TIME);
- timeOut.waitFor("Waiting for core's watcher to be removed", () -> {
- final long postDeleteWatcherCount = countUnloadCoreOnDeletedWatchers
- (accessor.getStateWatchers(collectionName));
- log.info("preDeleteWatcherCount={} vs postDeleteWatcherCount={}",
- preDeleteWatcherCount, postDeleteWatcherCount);
- return (preDeleteWatcherCount - 1L == postDeleteWatcherCount);
- });
-
- assertFalse("Data directory for " + replica.getName() + " should have been removed", Files.exists(dataDir));
-
+ timeOut.waitFor(
+ "Waiting for core's watcher to be removed",
+ () -> {
+ final long postDeleteWatcherCount =
+ countUnloadCoreOnDeletedWatchers(accessor.getStateWatchers(collectionName));
+ log.info(
+ "preDeleteWatcherCount={} vs postDeleteWatcherCount={}",
+ preDeleteWatcherCount,
+ postDeleteWatcherCount);
+ return (preDeleteWatcherCount - 1L == postDeleteWatcherCount);
+ });
+
+ assertFalse(
+ "Data directory for " + replica.getName() + " should have been removed",
+ Files.exists(dataDir));
}
@Test
public void deleteReplicaAndVerifyDirectoryCleanup() throws Exception {
final String collectionName = "deletereplica_test";
- CollectionAdminRequest.createCollection(collectionName, "conf", 1, 2).process(cluster.getSolrClient());
+ CollectionAdminRequest.createCollection(collectionName, "conf", 1, 2)
+ .process(cluster.getSolrClient());
- Replica leader = cluster.getSolrClient().getZkStateReader().getLeaderRetry(collectionName, "shard1");
+ Replica leader =
+ cluster.getSolrClient().getZkStateReader().getLeaderRetry(collectionName, "shard1");
- //Confirm that the instance and data directory exist
+ // Confirm that the instance and data directory exist
CoreStatus coreStatus = getCoreStatus(leader);
- assertTrue("Instance directory doesn't exist", Files.exists(Paths.get(coreStatus.getInstanceDirectory())));
- assertTrue("DataDirectory doesn't exist", Files.exists(Paths.get(coreStatus.getDataDirectory())));
+ assertTrue(
+ "Instance directory doesn't exist",
+ Files.exists(Paths.get(coreStatus.getInstanceDirectory())));
+ assertTrue(
+ "DataDirectory doesn't exist", Files.exists(Paths.get(coreStatus.getDataDirectory())));
- CollectionAdminRequest.deleteReplica(collectionName, "shard1",leader.getName())
+ CollectionAdminRequest.deleteReplica(collectionName, "shard1", leader.getName())
.process(cluster.getSolrClient());
- Replica newLeader = cluster.getSolrClient().getZkStateReader().getLeaderRetry(collectionName, "shard1");
+ Replica newLeader =
+ cluster.getSolrClient().getZkStateReader().getLeaderRetry(collectionName, "shard1");
assertFalse(leader.equals(newLeader));
- //Confirm that the instance and data directory were deleted by default
- assertFalse("Instance directory still exists", Files.exists(Paths.get(coreStatus.getInstanceDirectory())));
- assertFalse("DataDirectory still exists", Files.exists(Paths.get(coreStatus.getDataDirectory())));
+ // Confirm that the instance and data directory were deleted by default
+ assertFalse(
+ "Instance directory still exists",
+ Files.exists(Paths.get(coreStatus.getInstanceDirectory())));
+ assertFalse(
+ "DataDirectory still exists", Files.exists(Paths.get(coreStatus.getDataDirectory())));
}
@Test
public void deleteReplicaByCount() throws Exception {
final String collectionName = "deleteByCount";
- CollectionAdminRequest.createCollection(collectionName, "conf", 1, 3).process(cluster.getSolrClient());
+ CollectionAdminRequest.createCollection(collectionName, "conf", 1, 3)
+ .process(cluster.getSolrClient());
waitForState("Expected a single shard with three replicas", collectionName, clusterShape(1, 3));
- CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 2).process(cluster.getSolrClient());
- waitForState("Expected a single shard with a single replica", collectionName, clusterShape(1, 1));
-
- SolrException e = expectThrows(SolrException.class,
- "Can't delete the last replica by count",
- () -> CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 1).process(cluster.getSolrClient())
- );
+ CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 2)
+ .process(cluster.getSolrClient());
+ waitForState(
+ "Expected a single shard with a single replica", collectionName, clusterShape(1, 1));
+
+ SolrException e =
+ expectThrows(
+ SolrException.class,
+ "Can't delete the last replica by count",
+ () ->
+ CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 1)
+ .process(cluster.getSolrClient()));
assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, e.code());
assertTrue(e.getMessage().contains("There is only one replica available"));
DocCollection docCollection = getCollectionState(collectionName);
// We know that since leaders are preserved, PULL replicas should not be left alone in the shard
- assertEquals(0, docCollection.getSlice("shard1").getReplicas(EnumSet.of(Replica.Type.PULL)).size());
+ assertEquals(
+ 0, docCollection.getSlice("shard1").getReplicas(EnumSet.of(Replica.Type.PULL)).size());
}
@Test
- // commented out on: 17-Feb-2019 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on: 24-Dec-2018
+ // commented out on: 17-Feb-2019
+ // @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on:
+ // 24-Dec-2018
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/DocValuesNotIndexedTest.java
##########
@@ -291,36 +321,39 @@ public void testGroupingDocAbsent() throws IOException, SolrServerException {
docs.add(doc);
CloudSolrClient client = cluster.getSolrClient();
- new UpdateRequest()
- .add(docs)
- .commit(client, COLLECTION);
+ new UpdateRequest().add(docs).commit(client, COLLECTION);
- // when grouping on any of these DV-only (not indexed) fields we expect exactly 4 groups except for Boolean.
+ // when grouping on any of these DV-only (not indexed) fields we expect exactly 4 groups except
+ // for Boolean.
for (FieldProps prop : fieldsToTestGroupSortFirst) {
// Special handling until SOLR-9802 is fixed
if (prop.getName().startsWith("date")) continue;
// SOLR-9802 to here
- final SolrQuery solrQuery = new SolrQuery("q", "*:*",
- "group", "true",
- "group.field", prop.getName());
+ final SolrQuery solrQuery =
+ new SolrQuery("q", "*:*", "group", "true", "group.field", prop.getName());
final QueryResponse rsp = client.query(COLLECTION, solrQuery);
GroupResponse groupResponse = rsp.getGroupResponse();
List<GroupCommand> commands = groupResponse.getValues();
GroupCommand fieldCommand = commands.get(0);
int expected = 4;
- if (prop.getName().startsWith("bool")) expected = 3; //true, false and null
+ if (prop.getName().startsWith("bool")) expected = 3; // true, false and null
List<Group> fieldCommandGroups = fieldCommand.getValues();
- assertEquals("Did not find the expected number of groups for field " + prop.getName(), expected, fieldCommandGroups.size());
+ assertEquals(
+ "Did not find the expected number of groups for field " + prop.getName(),
+ expected,
+ fieldCommandGroups.size());
}
}
@Test
- // Verify that we actually form groups that are "expected". Most of the processing takes some care to
- // make sure all the values for each field are unique. We need to have docs that have values that are _not_
+ // Verify that we actually form groups that are "expected". Most of the processing takes some care
+ // to
+ // make sure all the values for each field are unique. We need to have docs that have values that
+ // are _not_
// unique.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/DocValuesNotIndexedTest.java
##########
@@ -354,30 +389,29 @@ private void doGroupingDvOnly(List<FieldProps> fieldProps, String boolName) thro
CloudSolrClient client = cluster.getSolrClient();
- new UpdateRequest()
- .add(docs)
- .commit(client, COLLECTION);
+ new UpdateRequest().add(docs).commit(client, COLLECTION);
- // OK, we should have one group with 10 entries for null, a group with 1 entry and 7 groups with 7
+ // OK, we should have one group with 10 entries for null, a group with 1 entry and 7 groups with
+ // 7
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java
##########
@@ -152,80 +173,89 @@ private void runTest() throws Exception {
final SolrInputDocument doc = sdoc("id", i);
if (random().nextBoolean()) {
- doc.addField("should_expire_s","yup");
- doc.addField("tTl_s","+1SECONDS");
+ doc.addField("should_expire_s", "yup");
+ doc.addField("tTl_s", "+1SECONDS");
} else {
numDocsThatNeverExpire++;
}
-
+
req.add(doc);
}
req.commit(cluster.getSolrClient(), COLLECTION);
}
-
- // NOTE: don't assume we can find exactly totalNumDocs right now, some may have already been deleted...
-
- // it should not take long for us to get to the point where all 'should_expire_s:yup' docs are gone
- waitForNoResults(30, params("q","should_expire_s:yup","rows","0","_trace","init_batch_check"));
+
+ // NOTE: don't assume we can find exactly totalNumDocs right now, some may have already been
+ // deleted...
+
+ // it should not take long for us to get to the point where all 'should_expire_s:yup' docs are
+ // gone
+ waitForNoResults(
+ 30, params("q", "should_expire_s:yup", "rows", "0", "_trace", "init_batch_check"));
{
// ...*NOW* we can assert that exactly numDocsThatNeverExpire should exist...
- final QueryRequest req = setAuthIfNeeded(new QueryRequest
- (params("q", "*:*",
- "rows", "0",
- "_trace", "count_non_expire_docs")));
+ final QueryRequest req =
+ setAuthIfNeeded(
+ new QueryRequest(
+ params(
+ "q", "*:*",
+ "rows", "0",
+ "_trace", "count_non_expire_docs")));
// NOTE: it's possible that replicas could be out of sync but this query may get lucky and
// only hit leaders. we'll compare the counts of every replica in every shard later on...
- assertEquals(numDocsThatNeverExpire,
- req.process(cluster.getSolrClient(), COLLECTION).getResults().getNumFound());
+ assertEquals(
+ numDocsThatNeverExpire,
+ req.process(cluster.getSolrClient(), COLLECTION).getResults().getNumFound());
}
-
+
//
// now that we've confrmed the basics work, let's check some fine grain stuff...
//
-
+
// first off, sanity check that this special docId doesn't some how already exist
- waitForNoResults(0, params("q","id:special99","rows","0","_trace","sanity_check99"));
+ waitForNoResults(0, params("q", "id:special99", "rows", "0", "_trace", "sanity_check99"));
{
- // force a hard commit on all shards (the prior auto-expire would have only done a soft commit)
+ // force a hard commit on all shards (the prior auto-expire would have only done a soft
+ // commit)
// so we can ensure our indexVersion won't change uncessisarily on the un-affected
// shard when we add & (hard) commit our special doc...
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/MockSolrSource.java
##########
@@ -22,13 +22,15 @@
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkStateReader;
-public class MockSolrSource {
+public class MockSolrSource {
- public static ZkController makeSimpleMock(Overseer overseer, ZkStateReader reader, SolrZkClient zkClient) {
+ public static ZkController makeSimpleMock(
+ Overseer overseer, ZkStateReader reader, SolrZkClient zkClient) {
ZkController zkControllerMock = mock(ZkController.class);
final DistributedClusterStateUpdater distributedClusterStateUpdater;
if (overseer == null) {
- // When no overseer is passed, the Overseer queue does nothing. Replicate this in how we handle distributed state
+ // When no overseer is passed, the Overseer queue does nothing. Replicate this in how we
+ // handle distributed state
// updates by doing nothing as well...
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java
##########
@@ -383,7 +410,12 @@ public void testParallelElection() throws Exception {
List<ClientThread> replica2s = new ArrayList<>();
ElectorSetup es2 = new ElectorSetup(null);
for (int i = 1; i <= numShards; i++) {
- ClientThread thread = new ClientThread(es2, "parshard" + i, 2, 40000 / (numShards - 1) /* delay enough to timeout or expire */);
+ ClientThread thread =
+ new ClientThread(
+ es2,
+ "parshard" + i,
+ 2,
+ 40000 / (numShards - 1) /* delay enough to timeout or expire */);
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/LeaderFailoverAfterPartitionTest.java
##########
@@ -48,9 +47,8 @@ public LeaderFailoverAfterPartitionTest() {
super();
}
-
@Test
- //28-June-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028")
+ // 28-June-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028")
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/MockSolrSource.java
##########
@@ -41,17 +43,17 @@ public static ZkController makeSimpleMock(Overseer overseer, ZkStateReader reade
if (reader != null && zkClient == null) {
zkClient = reader.getZkClient();
} else {
- if (zkClient == null) {
- }
+ if (zkClient == null) {}
Review comment:
Ummmm
##########
File path: solr/core/src/test/org/apache/solr/cloud/MoveReplicaTest.java
##########
@@ -20,23 +20,30 @@
import org.junit.Test;
/**
- * Implementation moved to AbstractMoveReplicaTestBase as it is referenced by HDFS contrib module tests.
+ * Implementation moved to AbstractMoveReplicaTestBase as it is referenced by HDFS contrib module
+ * tests.
*/
public class MoveReplicaTest extends AbstractMoveReplicaTestBase {
-
@Test
- // commented out on: 17-Feb-2019 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on: 24-Dec-2018
+ // commented out on: 17-Feb-2019
+ // @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on:
+ // 24-Dec-2018
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/MoveReplicaTest.java
##########
@@ -20,23 +20,30 @@
import org.junit.Test;
/**
- * Implementation moved to AbstractMoveReplicaTestBase as it is referenced by HDFS contrib module tests.
+ * Implementation moved to AbstractMoveReplicaTestBase as it is referenced by HDFS contrib module
+ * tests.
*/
public class MoveReplicaTest extends AbstractMoveReplicaTestBase {
-
@Test
- // commented out on: 17-Feb-2019 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on: 24-Dec-2018
+ // commented out on: 17-Feb-2019
+ // @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on:
+ // 24-Dec-2018
public void test() throws Exception {
super.test();
}
- //Commented out 5-Dec-2017
+ // Commented out 5-Dec-2017
// @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-11458")
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java
##########
@@ -63,62 +60,85 @@ public void test() throws Exception {
private void testFillWorkQueue() throws Exception {
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
- // This test does not make sense when the Collection API execution is distributed. There is no queue to fill
- if (!new CollectionAdminRequest.RequestApiDistributedProcessing().process(client).getIsCollectionApiDistributed()) {
+ // This test does not make sense when the Collection API execution is distributed. There is no
+ // queue to fill
+ if (!new CollectionAdminRequest.RequestApiDistributedProcessing()
+ .process(client)
+ .getIsCollectionApiDistributed()) {
- //fill the work queue with blocked tasks by adding more than the no:of parallel tasks
+ // fill the work queue with blocked tasks by adding more than the no:of parallel tasks
for (int i = 0; i < MAX_PARALLEL_TASKS + 15; i++) {
- CollectionAdminRequest.MockCollTask mockTask = CollectionAdminRequest.mockCollTask("A_COLL");
- // third task waits for a long time, and thus blocks the queue for all other tasks for A_COLL.
+ CollectionAdminRequest.MockCollTask mockTask =
+ CollectionAdminRequest.mockCollTask("A_COLL");
+ // third task waits for a long time, and thus blocks the queue for all other tasks for
+ // A_COLL.
// Subsequent tasks as well as the first two only wait for 1ms
mockTask.setSleep(i == 2 ? "5000" : "1");
mockTask.processAsync(Integer.toString(i), client);
log.info("MOCK task added {}", i);
}
- // Wait until we see the second A_COLL task getting processed (assuming the first got processed as well)
+ // Wait until we see the second A_COLL task getting processed (assuming the first got
+ // processed as well)
Long task1CollA = waitForTaskToCompleted(client, 1);
- assertNotNull("Queue did not process first two tasks on A_COLL, can't run test", task1CollA);
+ assertNotNull(
+ "Queue did not process first two tasks on A_COLL, can't run test", task1CollA);
- // Make sure the long running task did not finish, otherwise no way the B_COLL task can be tested to run in parallel with it
- assertNull("Long running task finished too early, can't test", checkTaskHasCompleted(client, 2));
+ // Make sure the long running task did not finish, otherwise no way the B_COLL task can be
+ // tested to run in parallel with it
+ assertNull(
+ "Long running task finished too early, can't test", checkTaskHasCompleted(client, 2));
- // Enqueue a task on another collection not competing with the lock on A_COLL and see that it can be executed right away
+ // Enqueue a task on another collection not competing with the lock on A_COLL and see that
+ // it can be executed right away
- CollectionAdminRequest.MockCollTask mockTask = CollectionAdminRequest.mockCollTask("B_COLL");
+ CollectionAdminRequest.MockCollTask mockTask =
+ CollectionAdminRequest.mockCollTask("B_COLL");
mockTask.setSleep("1");
mockTask.processAsync("200", client);
- // We now check that either the B_COLL task has completed before the third (long running) task on A_COLL,
- // Or if both have completed (if this check got significantly delayed for some reason), we verify B_COLL was first.
+ // We now check that either the B_COLL task has completed before the third (long running)
+ // task on A_COLL,
+ // Or if both have completed (if this check got significantly delayed for some reason), we
+ // verify B_COLL was first.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/MoveReplicaTest.java
##########
@@ -20,23 +20,30 @@
import org.junit.Test;
/**
- * Implementation moved to AbstractMoveReplicaTestBase as it is referenced by HDFS contrib module tests.
+ * Implementation moved to AbstractMoveReplicaTestBase as it is referenced by HDFS contrib module
+ * tests.
*/
public class MoveReplicaTest extends AbstractMoveReplicaTestBase {
-
@Test
- // commented out on: 17-Feb-2019 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on: 24-Dec-2018
+ // commented out on: 17-Feb-2019
+ // @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on:
+ // 24-Dec-2018
public void test() throws Exception {
super.test();
}
- //Commented out 5-Dec-2017
+ // Commented out 5-Dec-2017
// @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-11458")
@Test
- // 12-Jun-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // 17-Mar-2018 This JIRA is fixed, but this test still fails
- //17-Aug-2018 commented @LuceneTestCase.BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // 2-Aug-2018
- // commented out on: 17-Feb-2019 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on: 24-Dec-2018
+ // 12-Jun-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // 17-Mar-2018
+ // This JIRA is fixed, but this test still fails
+ // 17-Aug-2018 commented
+ // @LuceneTestCase.BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") //
+ // 2-Aug-2018
+ // commented out on: 17-Feb-2019
+ // @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on:
+ // 24-Dec-2018
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java
##########
@@ -39,25 +38,23 @@
import org.junit.BeforeClass;
import org.junit.Test;
-public class NestedShardedAtomicUpdateTest extends SolrCloudTestCase { // used to extend AbstractFullDistribZkTestBase
+public class NestedShardedAtomicUpdateTest
+ extends SolrCloudTestCase { // used to extend AbstractFullDistribZkTestBase
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/OverseerRolesTest.java
##########
@@ -194,21 +209,24 @@ public void testDesignatedOverseerRestarts() throws Exception {
waitForNewOverseer(15, overseer1, false);
JettySolrRunner leaderJetty = getOverseerJetty();
- List<String> nodes = OverseerCollectionConfigSetProcessor.getSortedOverseerNodeNames(zkClient());
+ List<String> nodes =
+ OverseerCollectionConfigSetProcessor.getSortedOverseerNodeNames(zkClient());
nodes.remove(overseer1); // remove the designated overseer
logOverseerState();
- // kill the current overseer, and check that the next node in the election queue assumes leadership
+ // kill the current overseer, and check that the next node in the election queue assumes
+ // leadership
leaderJetty.stop();
log.info("Killing designated overseer: {}", overseer1);
- // after 5 seconds, bring back dead designated overseer and assert that it assumes leadership "right away",
+ // after 5 seconds, bring back dead designated overseer and assert that it assumes leadership
+ // "right away",
// i.e. without any other node assuming leadership before this node becomes leader.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/MultiSolrCloudTestCaseTest.java
##########
@@ -63,7 +63,8 @@ public void accept(String clusterId, MiniSolrCloudCluster cluster) {
if (random().nextBoolean()) {
doAccept(collection, cluster); // same collection name in different clouds
} else {
- doAccept(collection+"_in_"+clusterId, cluster); // globally unique collection name
+ doAccept(
+ collection + "_in_" + clusterId, cluster); // globally unique collection name
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/OverseerStatusTest.java
##########
@@ -41,56 +40,82 @@ public void test() throws Exception {
int numCollectionCreates = 0, numOverseerCreates = 0;
String collectionName = "overseer_status_test";
- CollectionAdminRequest.createCollection(collectionName, "conf", 1, 1).process(cluster.getSolrClient());
+ CollectionAdminRequest.createCollection(collectionName, "conf", 1, 1)
+ .process(cluster.getSolrClient());
- NamedList<Object> resp = new CollectionAdminRequest.OverseerStatus().process(cluster.getSolrClient()).getResponse();
- // When running with Distributed Collection API, no real data in Overseer status, but the Collection API call shouldn't fail
- if (new CollectionAdminRequest.RequestApiDistributedProcessing().process(cluster.getSolrClient()).getIsCollectionApiDistributed()) {
+ NamedList<Object> resp =
+ new CollectionAdminRequest.OverseerStatus().process(cluster.getSolrClient()).getResponse();
+ // When running with Distributed Collection API, no real data in Overseer status, but the
+ // Collection API call shouldn't fail
+ if (new CollectionAdminRequest.RequestApiDistributedProcessing()
+ .process(cluster.getSolrClient())
+ .getIsCollectionApiDistributed()) {
return;
}
NamedList<Object> collection_operations = (NamedList<Object>) resp.get("collection_operations");
NamedList<Object> overseer_operations = (NamedList<Object>) resp.get("overseer_operations");
- SimpleOrderedMap<Object> createcollection
- = (SimpleOrderedMap<Object>) collection_operations.get(CollectionParams.CollectionAction.CREATE.toLower());
- assertEquals("No stats for create in OverseerCollectionProcessor", numCollectionCreates + 1, createcollection.get("requests"));
- // When cluster state updates are distributed, Overseer doesn't see them and doesn't report stats on them.
+ SimpleOrderedMap<Object> createcollection =
+ (SimpleOrderedMap<Object>)
+ collection_operations.get(CollectionParams.CollectionAction.CREATE.toLower());
+ assertEquals(
+ "No stats for create in OverseerCollectionProcessor",
+ numCollectionCreates + 1,
+ createcollection.get("requests"));
+ // When cluster state updates are distributed, Overseer doesn't see them and doesn't report
+ // stats on them.
if (!cluster.getOpenOverseer().getDistributedClusterStateUpdater().isDistributedStateUpdate()) {
- // Note the "create" key here is in a different map from the "create" key above. Above it's Collection creation in the
- // Collection API, here it's the collection creation from the cluster state updater perspective.
- createcollection = (SimpleOrderedMap<Object>) overseer_operations.get(CollectionParams.CollectionAction.CREATE.toLower());
- assertEquals("No stats for create in Overseer", numOverseerCreates + 1, createcollection.get("requests"));
+ // Note the "create" key here is in a different map from the "create" key above. Above it's
+ // Collection creation in the
+ // Collection API, here it's the collection creation from the cluster state updater
+ // perspective.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/OverseerRolesTest.java
##########
@@ -194,21 +209,24 @@ public void testDesignatedOverseerRestarts() throws Exception {
waitForNewOverseer(15, overseer1, false);
JettySolrRunner leaderJetty = getOverseerJetty();
- List<String> nodes = OverseerCollectionConfigSetProcessor.getSortedOverseerNodeNames(zkClient());
+ List<String> nodes =
+ OverseerCollectionConfigSetProcessor.getSortedOverseerNodeNames(zkClient());
nodes.remove(overseer1); // remove the designated overseer
logOverseerState();
- // kill the current overseer, and check that the next node in the election queue assumes leadership
+ // kill the current overseer, and check that the next node in the election queue assumes
+ // leadership
leaderJetty.stop();
log.info("Killing designated overseer: {}", overseer1);
- // after 5 seconds, bring back dead designated overseer and assert that it assumes leadership "right away",
+ // after 5 seconds, bring back dead designated overseer and assert that it assumes leadership
+ // "right away",
// i.e. without any other node assuming leadership before this node becomes leader.
Thread.sleep(5);
logOverseerState();
log.info("Starting back the prioritized overseer..");
leaderJetty.start();
- waitForNewOverseer(15, overseer1, true); // assert that there is just a single leadership transition
+ waitForNewOverseer(
+ 15, overseer1, true); // assert that there is just a single leadership transition
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ParallelCommitExecutionTest.java
##########
@@ -125,7 +125,8 @@ public void processCommit(CommitUpdateCommand cmd) throws IOException {
super.processCommit(cmd);
countdown.countDown();
try {
- // NOTE: this ensures that all commits are executed in parallel; no commit can complete successfully
+ // NOTE: this ensures that all commits are executed in parallel; no commit can complete
+ // successfully
// until all commits have entered the `processCommit(...)` method.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java
##########
@@ -27,9 +27,9 @@
@Test
@Override
- //commented 2-Aug-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // 28-June-2018
+ // commented 2-Aug-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") //
+ // 28-June-2018
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ReplaceNodeTest.java
##########
@@ -85,30 +85,42 @@ public void test() throws Exception {
String emptyNode = l.remove(0);
String node2bdecommissioned = l.get(0);
CollectionAdminRequest.Create create;
- // NOTE: always using the createCollection that takes in 'int' for all types of replicas, so we never
+ // NOTE: always using the createCollection that takes in 'int' for all types of replicas, so we
+ // never
// have to worry about null checking when comparing the Create command with the final Slices
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/PackageManagerCLITest.java
##########
@@ -116,22 +146,51 @@ public void testPackageManager() throws Exception {
run(tool, new String[] {"-solrUrl", solrUrl, "install", "question-answer"});
assertPackageVersion("abc", "question-answer", "1.0.0", rhPath, "1.0.0");
- if (random().nextBoolean()) { // even if parameters are not passed in, they should be picked up from previous deployment
- run(tool, new String[] {"-solrUrl", solrUrl, "deploy", "--update", "-y", "question-answer", "-collections", "abc", "-p", "RH-HANDLER-PATH=" + rhPath});
+ if (random()
+ .nextBoolean()) { // even if parameters are not passed in, they should be picked up from
+ // previous deployment
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java
##########
@@ -155,24 +162,34 @@ protected void testRf2NotUsingDirectUpdates() throws Exception {
sendNonDirectUpdateRequestReplicaWithRetry(leader, up, 1, testCollectionName);
sendNonDirectUpdateRequestReplicaWithRetry(replicas.get(0), up, 1, testCollectionName);
- // Whether the replication factor is 1 or 2 in the delete-by-id case depends on whether the doc IDs happen to fall
+ // Whether the replication factor is 1 or 2 in the delete-by-id case depends on whether the doc
+ // IDs happen to fall
// on a single shard or not.
Set<Integer> byIDs;
byIDs = getSomeIds(2);
- sendNonDirectDeletesRequestReplicaWithRetry(leader,
- byIDs, calcByIdRf(byIDs, testCollectionName, "shard2"),
- getSomeIds(2), 1, testCollectionName);
+ sendNonDirectDeletesRequestReplicaWithRetry(
+ leader,
+ byIDs,
+ calcByIdRf(byIDs, testCollectionName, "shard2"),
+ getSomeIds(2),
+ 1,
+ testCollectionName);
byIDs = getSomeIds(2);
- sendNonDirectDeletesRequestReplicaWithRetry(replicas.get(0), byIDs,
+ sendNonDirectDeletesRequestReplicaWithRetry(
+ replicas.get(0),
+ byIDs,
calcByIdRf(byIDs, testCollectionName, "shard2"),
- getSomeIds(2), 1, testCollectionName);
+ getSomeIds(2),
+ 1,
+ testCollectionName);
// heal the partition
getProxyForReplica(shard2Replicas.get(0)).reopen();
Thread.sleep(2000);
}
- // When doing a delete by id, it's tricky, very tricky. If any document we're deleting by ID goes to shardWithOne,
+ // When doing a delete by id, it's tricky, very tricky. If any document we're deleting by ID goes
+ // to shardWithOne,
// then the replication factor we return will be 1.
//
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/RecoveryAfterSoftCommitTest.java
##########
@@ -36,14 +35,16 @@
public class RecoveryAfterSoftCommitTest extends AbstractFullDistribZkTestBase {
private static final int MAX_BUFFERED_DOCS = 2, ULOG_NUM_RECORDS_TO_KEEP = 2;
private final boolean onlyLeaderIndexes = random().nextBoolean();
+
public RecoveryAfterSoftCommitTest() {
sliceCount = 1;
fixShardCount(2);
}
@Override
protected boolean useTlogReplicas() {
- return false; // TODO: tlog replicas makes commits take way to long due to what is likely a bug and it's TestInjection use
+ return false; // TODO: tlog replicas makes commits take way to long due to what is likely a bug
+ // and it's TestInjection use
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java
##########
@@ -155,24 +162,34 @@ protected void testRf2NotUsingDirectUpdates() throws Exception {
sendNonDirectUpdateRequestReplicaWithRetry(leader, up, 1, testCollectionName);
sendNonDirectUpdateRequestReplicaWithRetry(replicas.get(0), up, 1, testCollectionName);
- // Whether the replication factor is 1 or 2 in the delete-by-id case depends on whether the doc IDs happen to fall
+ // Whether the replication factor is 1 or 2 in the delete-by-id case depends on whether the doc
+ // IDs happen to fall
// on a single shard or not.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/RollingRestartTest.java
##########
@@ -93,48 +98,71 @@ public void restartWithRolesTest() throws Exception {
log.info("Restarting {}", cloudJetty);
chaosMonkey.stopJetty(cloudJetty);
cloudClient.getZkStateReader().updateLiveNodes();
- boolean liveDesignates = CollectionUtils.intersection(cloudClient.getZkStateReader().getClusterState().getLiveNodes(), designates).size() > 0;
+ boolean liveDesignates =
+ CollectionUtils.intersection(
+ cloudClient.getZkStateReader().getClusterState().getLiveNodes(), designates)
+ .size()
+ > 0;
if (liveDesignates) {
sawLiveDesignate = true;
- boolean success = waitUntilOverseerDesignateIsLeader(cloudClient.getZkStateReader().getZkClient(), designates, MAX_WAIT_TIME);
+ boolean success =
+ waitUntilOverseerDesignateIsLeader(
+ cloudClient.getZkStateReader().getZkClient(), designates, MAX_WAIT_TIME);
if (!success) {
- leader = OverseerCollectionConfigSetProcessor.getLeaderNode(cloudClient.getZkStateReader().getZkClient());
+ leader =
+ OverseerCollectionConfigSetProcessor.getLeaderNode(
+ cloudClient.getZkStateReader().getZkClient());
if (leader == null)
- log.error("NOOVERSEER election queue is : {}"
- , OverseerCollectionConfigSetProcessor.getSortedElectionNodes(cloudClient.getZkStateReader().getZkClient(),
- "/overseer_elect/election"));
+ log.error(
+ "NOOVERSEER election queue is : {}",
+ OverseerCollectionConfigSetProcessor.getSortedElectionNodes(
+ cloudClient.getZkStateReader().getZkClient(), "/overseer_elect/election"));
fail("No overseer designate as leader found after restart #" + (i + 1) + ": " + leader);
}
}
cloudJetty.jetty.start();
- boolean success = waitUntilOverseerDesignateIsLeader(cloudClient.getZkStateReader().getZkClient(), designates, MAX_WAIT_TIME);
+ boolean success =
+ waitUntilOverseerDesignateIsLeader(
+ cloudClient.getZkStateReader().getZkClient(), designates, MAX_WAIT_TIME);
if (!success) {
- leader = OverseerCollectionConfigSetProcessor.getLeaderNode(cloudClient.getZkStateReader().getZkClient());
+ leader =
+ OverseerCollectionConfigSetProcessor.getLeaderNode(
+ cloudClient.getZkStateReader().getZkClient());
if (leader == null)
- log.error("NOOVERSEER election queue is :{}"
- , OverseerCollectionConfigSetProcessor.getSortedElectionNodes(cloudClient.getZkStateReader().getZkClient(),
- "/overseer_elect/election"));
+ log.error(
+ "NOOVERSEER election queue is :{}",
+ OverseerCollectionConfigSetProcessor.getSortedElectionNodes(
+ cloudClient.getZkStateReader().getZkClient(), "/overseer_elect/election"));
fail("No overseer leader found after restart #" + (i + 1) + ": " + leader);
}
cloudClient.getZkStateReader().updateLiveNodes();
- sawLiveDesignate = CollectionUtils.intersection(cloudClient.getZkStateReader().getClusterState().getLiveNodes(), designates).size() > 0;
-
+ sawLiveDesignate =
+ CollectionUtils.intersection(
+ cloudClient.getZkStateReader().getClusterState().getLiveNodes(), designates)
+ .size()
+ > 0;
}
}
assertTrue("Test may not be working if we never saw a live designate", sawLiveDesignate);
- leader = OverseerCollectionConfigSetProcessor.getLeaderNode(cloudClient.getZkStateReader().getZkClient());
+ leader =
+ OverseerCollectionConfigSetProcessor.getLeaderNode(
+ cloudClient.getZkStateReader().getZkClient());
assertNotNull(leader);
log.info("Current overseer leader (after restart) = {}", leader);
cloudClient.getZkStateReader().getZkClient().printLayoutToStream(System.out);
}
- static boolean waitUntilOverseerDesignateIsLeader(SolrZkClient testZkClient, List<String> overseerDesignates, long timeoutInNanos) throws KeeperException, InterruptedException {
+ static boolean waitUntilOverseerDesignateIsLeader(
+ SolrZkClient testZkClient, List<String> overseerDesignates, long timeoutInNanos)
+ throws KeeperException, InterruptedException {
long now = System.nanoTime();
- long maxTimeout = now + timeoutInNanos; // the maximum amount of time we're willing to wait to see the designate as leader
+ long maxTimeout =
+ now + timeoutInNanos; // the maximum amount of time we're willing to wait to see the
+ // designate as leader
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/SegmentTerminateEarlyTestState.java
##########
@@ -36,12 +35,17 @@
static final String KEY_FIELD = "id";
- // for historic reasons, this is refered to as a "timestamp" field, but in actuallity is just an int
+ // for historic reasons, this is refered to as a "timestamp" field, but in actuallity is just an
+ // int
// value representing a number of "minutes" between 0-60.
// aka: I decided not to rename a million things while refactoring this test
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java
##########
@@ -181,16 +198,19 @@ private int calcByIdRf(Set<Integer> byIDs, String testCollectionName, String sha
int retval = 2;
for (int id : byIDs) {
DocRouter router = coll.getRouter();
- if (shardWithOne.equals(router.getTargetSlice(Integer.toString(id), null, null, null, coll).getName())) {
+ if (shardWithOne.equals(
+ router.getTargetSlice(Integer.toString(id), null, null, null, coll).getName())) {
retval = 1;
}
}
return retval;
}
- int idFloor = random().nextInt(100) + 1000; // Get the delete tests to use disjoint documents although
+ int idFloor =
+ random().nextInt(100) + 1000; // Get the delete tests to use disjoint documents although
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java
##########
@@ -47,38 +46,44 @@
import org.slf4j.LoggerFactory;
/**
- * Tests a client application's ability to get replication factor
- * information back from the cluster after an add or update.
+ * Tests a client application's ability to get replication factor information back from the cluster
+ * after an add or update.
*/
@Slow
@SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776")
// 12-Jun-2018 @LuceneTestCase.BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-6944")
public class ReplicationFactorTest extends AbstractFullDistribZkTestBase {
-
+
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public ReplicationFactorTest() {
super();
sliceCount = 3;
fixShardCount(3);
}
-
+
/**
- * Overrides the parent implementation so that we can configure a socket proxy
- * to sit infront of each Jetty server, which gives us the ability to simulate
- * network partitions without having to fuss with IPTables (which is not very
- * cross platform friendly).
+ * Overrides the parent implementation so that we can configure a socket proxy to sit infront of
+ * each Jetty server, which gives us the ability to simulate network partitions without having to
+ * fuss with IPTables (which is not very cross platform friendly).
*/
@Override
- public JettySolrRunner createJetty(File solrHome, String dataDir,
- String shardList, String solrConfigOverride, String schemaOverride, Replica.Type replicaType)
+ public JettySolrRunner createJetty(
+ File solrHome,
+ String dataDir,
+ String shardList,
+ String solrConfigOverride,
+ String schemaOverride,
+ Replica.Type replicaType)
throws Exception {
- return createProxiedJetty(solrHome, dataDir, shardList, solrConfigOverride, schemaOverride, replicaType);
+ return createProxiedJetty(
+ solrHome, dataDir, shardList, solrConfigOverride, schemaOverride, replicaType);
}
-
+
@Test
- // commented out on: 24-Dec-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // added 20-Jul-2018
+ // commented out on: 24-Dec-2018
+ // @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // added 20-Jul-2018
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/SegmentTerminateEarlyTestState.java
##########
@@ -36,12 +35,17 @@
static final String KEY_FIELD = "id";
- // for historic reasons, this is refered to as a "timestamp" field, but in actuallity is just an int
+ // for historic reasons, this is refered to as a "timestamp" field, but in actuallity is just an
+ // int
// value representing a number of "minutes" between 0-60.
// aka: I decided not to rename a million things while refactoring this test
public static final String TIMESTAMP_FIELD = "timestamp_i_dvo";
- public static final String ODD_FIELD = "odd_l1"; // <dynamicField name="*_l1" type="long" indexed="true" stored="true" multiValued="false"/>
- public static final String QUAD_FIELD = "quad_l1"; // <dynamicField name="*_l1" type="long" indexed="true" stored="true" multiValued="false"/>
+ public static final String ODD_FIELD =
+ "odd_l1"; // <dynamicField name="*_l1" type="long" indexed="true" stored="true"
+ // multiValued="false"/>
+ public static final String QUAD_FIELD =
+ "quad_l1"; // <dynamicField name="*_l1" type="long" indexed="true" stored="true"
+ // multiValued="false"/>
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/RollingRestartTest.java
##########
@@ -46,9 +45,13 @@ public void distribSetUp() throws Exception {
}
@Test
- //commented 2-Aug-2018 @LuceneTestCase.BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // 2018-06-18
+ // commented 2-Aug-2018
+ // @LuceneTestCase.BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") //
+ // 2018-06-18
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java
##########
@@ -27,15 +26,16 @@
public class ShardRoutingCustomTest extends AbstractFullDistribZkTestBase {
- String collection = DEFAULT_COLLECTION; // enable this to be configurable (more work needs to be done)
+ String collection =
+ DEFAULT_COLLECTION; // enable this to be configurable (more work needs to be done)
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java
##########
@@ -181,16 +198,19 @@ private int calcByIdRf(Set<Integer> byIDs, String testCollectionName, String sha
int retval = 2;
for (int id : byIDs) {
DocRouter router = coll.getRouter();
- if (shardWithOne.equals(router.getTargetSlice(Integer.toString(id), null, null, null, coll).getName())) {
+ if (shardWithOne.equals(
+ router.getTargetSlice(Integer.toString(id), null, null, null, coll).getName())) {
retval = 1;
}
}
return retval;
}
- int idFloor = random().nextInt(100) + 1000; // Get the delete tests to use disjoint documents although
+ int idFloor =
+ random().nextInt(100) + 1000; // Get the delete tests to use disjoint documents although
- // Randomize documents so we exercise requests landing on replicas that have (or don't) particular documents
+ // Randomize documents so we exercise requests landing on replicas that have (or don't) particular
+ // documents
// Yeah, this will go on forever if you ask for more than 100, but it suffices.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
##########
@@ -230,66 +255,67 @@ private void doHashingTest() throws Exception {
doAddDoc("f1!f2!doc5");
doAddDoc("f1!f2!doc5/5");
commit();
- doQuery("a!b!,b!doc1,c!doc2,d!doc3,e!doc4,f1!f2!doc5,f1!f2!doc5/5", "q","*:*");
+ doQuery("a!b!,b!doc1,c!doc2,d!doc3,e!doc4,f1!f2!doc5,f1!f2!doc5/5", "q", "*:*");
}
-
public void doTestNumRequests() throws Exception {
log.info("### STARTING doTestNumRequests");
List<CloudJettyRunner> runners = shardToJetty.get(bucket1);
CloudJettyRunner leader = shardToLeaderJetty.get(bucket1);
- CloudJettyRunner replica = null;
+ CloudJettyRunner replica = null;
for (CloudJettyRunner r : runners) {
if (r != leader) replica = r;
}
long nStart = getNumRequests();
- leader.client.solrClient.add( sdoc("id","b!doc1") );
+ leader.client.solrClient.add(sdoc("id", "b!doc1"));
long nEnd = getNumRequests();
- assertEquals(2, nEnd - nStart); // one request to leader, which makes another to a replica
-
+ assertEquals(2, nEnd - nStart); // one request to leader, which makes another to a replica
nStart = getNumRequests();
- replica.client.solrClient.add( sdoc("id","b!doc1") );
+ replica.client.solrClient.add(sdoc("id", "b!doc1"));
nEnd = getNumRequests();
- assertEquals(3, nEnd - nStart); // orig request + replica forwards to leader, which forward back to replica.
+ assertEquals(
+ 3,
+ nEnd - nStart); // orig request + replica forwards to leader, which forward back to replica.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java
##########
@@ -230,25 +255,35 @@ protected void doTestConfigUpdate(String testCollectionName, String solrUrl) thr
assertNotNull(maxTimeFromConfig);
assertEquals(maxTime, maxTimeFromConfig);
- // Just check that we can access paths with slashes in them both through an intermediate method and explicitly
+ // Just check that we can access paths with slashes in them both through an intermediate method
+ // and explicitly
// using atPath.
- assertEquals("Should have been able to get a value from the /query request handler",
- "explicit", SolrCLI.asString("/config/requestHandler/\\/query/defaults/echoParams", configJson));
+ assertEquals(
+ "Should have been able to get a value from the /query request handler",
+ "explicit",
+ SolrCLI.asString("/config/requestHandler/\\/query/defaults/echoParams", configJson));
- assertEquals("Should have been able to get a value from the /query request handler",
- "explicit", SolrCLI.atPath("/config/requestHandler/\\/query/defaults/echoParams", configJson));
+ assertEquals(
+ "Should have been able to get a value from the /query request handler",
+ "explicit",
+ SolrCLI.atPath("/config/requestHandler/\\/query/defaults/echoParams", configJson));
if (log.isInfoEnabled()) {
- log.info("live_nodes_count : {}", cloudClient.getZkStateReader().getClusterState().getLiveNodes());
+ log.info(
+ "live_nodes_count : {}",
+ cloudClient.getZkStateReader().getClusterState().getLiveNodes());
}
- // Since it takes some time for this command to complete we need to make sure all the reloads for
+ // Since it takes some time for this command to complete we need to make sure all the reloads
+ // for
// all the cores have been done.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/SegmentTerminateEarlyTestState.java
##########
@@ -182,94 +217,141 @@ void queryTimestampDescendingSegmentTerminateEarlyNo(CloudSolrClient cloudSolrCl
query.set(CommonParams.SEGMENT_TERMINATE_EARLY, false);
final QueryResponse rsp = cloudSolrClient.query(query);
// check correctness of the results count
- TestSegmentSorting.assertEquals("numFound", numDocs/2, rsp.getResults().getNumFound());
+ TestSegmentSorting.assertEquals("numFound", numDocs / 2, rsp.getResults().getNumFound());
// check correctness of the first result
if (rsp.getResults().getNumFound() > 0) {
final SolrDocument solrDocument0 = rsp.getResults().get(0);
final Integer idAsInt = Integer.parseInt(solrDocument0.getFieldValue(KEY_FIELD).toString());
- TestSegmentSorting.assertTrue
- (KEY_FIELD +"="+idAsInt+" of ("+solrDocument0+") is not in maxTimestampDocKeys("+maxTimestampDocKeys+")",
- maxTimestampDocKeys.contains(idAsInt));
- TestSegmentSorting.assertEquals(ODD_FIELD, oddFieldValue, rsp.getResults().get(0).getFieldValue(ODD_FIELD));
+ TestSegmentSorting.assertTrue(
+ KEY_FIELD
+ + "="
+ + idAsInt
+ + " of ("
+ + solrDocument0
+ + ") is not in maxTimestampDocKeys("
+ + maxTimestampDocKeys
+ + ")",
+ maxTimestampDocKeys.contains(idAsInt));
+ TestSegmentSorting.assertEquals(
+ ODD_FIELD, oddFieldValue, rsp.getResults().get(0).getFieldValue(ODD_FIELD));
}
// check segmentTerminatedEarly flag
- TestSegmentSorting.assertNull("responseHeader.segmentTerminatedEarly present in "+rsp.getResponseHeader(),
- rsp.getResponseHeader().get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY));
- TestSegmentSorting.assertFalse("responseHeader.segmentTerminatedEarly present/true in "+rsp.getResponseHeader(),
- Boolean.TRUE.equals(rsp.getResponseHeader().get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY)));
+ TestSegmentSorting.assertNull(
+ "responseHeader.segmentTerminatedEarly present in " + rsp.getResponseHeader(),
+ rsp.getResponseHeader()
+ .get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY));
+ TestSegmentSorting.assertFalse(
+ "responseHeader.segmentTerminatedEarly present/true in " + rsp.getResponseHeader(),
+ Boolean.TRUE.equals(
+ rsp.getResponseHeader()
+ .get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY)));
// check shards info
final Object shardsInfo = rsp.getResponse().get(ShardParams.SHARDS_INFO);
if (!Boolean.TRUE.equals(shardsInfoWanted)) {
TestSegmentSorting.assertNull(ShardParams.SHARDS_INFO, shardsInfo);
} else {
TestSegmentSorting.assertNotNull(ShardParams.SHARDS_INFO, shardsInfo);
int segmentTerminatedEarlyShardsCount = 0;
- for (Map.Entry<String, ?> si : (SimpleOrderedMap<?>)shardsInfo) {
- if (Boolean.TRUE.equals(((SimpleOrderedMap)si.getValue()).get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY))) {
+ for (Map.Entry<String, ?> si : (SimpleOrderedMap<?>) shardsInfo) {
+ if (Boolean.TRUE.equals(
+ ((SimpleOrderedMap) si.getValue())
+ .get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY))) {
segmentTerminatedEarlyShardsCount += 1;
}
}
- TestSegmentSorting.assertEquals("shards reporting "+SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY,
- 0, segmentTerminatedEarlyShardsCount);
+ TestSegmentSorting.assertEquals(
+ "shards reporting " + SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY,
+ 0,
+ segmentTerminatedEarlyShardsCount);
}
}
- void queryTimestampDescendingSegmentTerminateEarlyYesGrouped(CloudSolrClient cloudSolrClient) throws Exception {
+ void queryTimestampDescendingSegmentTerminateEarlyYesGrouped(CloudSolrClient cloudSolrClient)
+ throws Exception {
TestSegmentSorting.assertFalse(maxTimestampDocKeys.isEmpty());
- TestSegmentSorting.assertTrue("numDocs="+numDocs+" is not even", (numDocs%2)==0);
+ TestSegmentSorting.assertTrue("numDocs=" + numDocs + " is not even", (numDocs % 2) == 0);
final Long oddFieldValue = (long) (maxTimestampDocKeys.iterator().next().intValue() % 2);
- final SolrQuery query = new SolrQuery(ODD_FIELD +":"+oddFieldValue);
+ final SolrQuery query = new SolrQuery(ODD_FIELD + ":" + oddFieldValue);
query.setSort(TIMESTAMP_FIELD, SolrQuery.ORDER.desc);
query.setFields(KEY_FIELD, ODD_FIELD, TIMESTAMP_FIELD);
query.setRows(1);
query.set(CommonParams.SEGMENT_TERMINATE_EARLY, true);
- TestSegmentSorting.assertTrue("numDocs="+numDocs+" is not quad-able", (numDocs%4)==0);
+ TestSegmentSorting.assertTrue("numDocs=" + numDocs + " is not quad-able", (numDocs % 4) == 0);
query.add("group.field", QUAD_FIELD);
query.set("group", true);
final QueryResponse rsp = cloudSolrClient.query(query);
// check correctness of the results count
- TestSegmentSorting.assertEquals("matches", numDocs/2, rsp.getGroupResponse().getValues().get(0).getMatches());
+ TestSegmentSorting.assertEquals(
+ "matches", numDocs / 2, rsp.getGroupResponse().getValues().get(0).getMatches());
// check correctness of the first result
if (rsp.getGroupResponse().getValues().get(0).getMatches() > 0) {
- final SolrDocument solrDocument = rsp.getGroupResponse().getValues().get(0).getValues().get(0).getResult().get(0);
+ final SolrDocument solrDocument =
+ rsp.getGroupResponse().getValues().get(0).getValues().get(0).getResult().get(0);
final Integer idAsInt = Integer.parseInt(solrDocument.getFieldValue(KEY_FIELD).toString());
- TestSegmentSorting.assertTrue
- (KEY_FIELD +"="+idAsInt+" of ("+solrDocument+") is not in maxTimestampDocKeys("+maxTimestampDocKeys+")",
- maxTimestampDocKeys.contains(idAsInt));
- TestSegmentSorting.assertEquals(ODD_FIELD, oddFieldValue, solrDocument.getFieldValue(ODD_FIELD));
+ TestSegmentSorting.assertTrue(
+ KEY_FIELD
+ + "="
+ + idAsInt
+ + " of ("
+ + solrDocument
+ + ") is not in maxTimestampDocKeys("
+ + maxTimestampDocKeys
+ + ")",
+ maxTimestampDocKeys.contains(idAsInt));
+ TestSegmentSorting.assertEquals(
+ ODD_FIELD, oddFieldValue, solrDocument.getFieldValue(ODD_FIELD));
}
// check segmentTerminatedEarly flag
// at present segmentTerminateEarly cannot be used with grouped queries
- TestSegmentSorting.assertFalse("responseHeader.segmentTerminatedEarly present/true in "+rsp.getResponseHeader(),
- Boolean.TRUE.equals(rsp.getResponseHeader().get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY)));
+ TestSegmentSorting.assertFalse(
+ "responseHeader.segmentTerminatedEarly present/true in " + rsp.getResponseHeader(),
+ Boolean.TRUE.equals(
+ rsp.getResponseHeader()
+ .get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY)));
}
- void queryTimestampAscendingSegmentTerminateEarlyYes(CloudSolrClient cloudSolrClient) throws Exception {
+ void queryTimestampAscendingSegmentTerminateEarlyYes(CloudSolrClient cloudSolrClient)
+ throws Exception {
TestSegmentSorting.assertFalse(minTimestampDocKeys.isEmpty());
- TestSegmentSorting.assertTrue("numDocs="+numDocs+" is not even", (numDocs%2)==0);
+ TestSegmentSorting.assertTrue("numDocs=" + numDocs + " is not even", (numDocs % 2) == 0);
final Long oddFieldValue = (long) (minTimestampDocKeys.iterator().next().intValue() % 2);
- final SolrQuery query = new SolrQuery(ODD_FIELD +":"+oddFieldValue);
- query.setSort(TIMESTAMP_FIELD, SolrQuery.ORDER.asc); // a sort order that is _not_ compatible with the merge sort order
+ final SolrQuery query = new SolrQuery(ODD_FIELD + ":" + oddFieldValue);
+ query.setSort(
+ TIMESTAMP_FIELD,
+ SolrQuery.ORDER.asc); // a sort order that is _not_ compatible with the merge sort order
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
##########
@@ -230,66 +255,67 @@ private void doHashingTest() throws Exception {
doAddDoc("f1!f2!doc5");
doAddDoc("f1!f2!doc5/5");
commit();
- doQuery("a!b!,b!doc1,c!doc2,d!doc3,e!doc4,f1!f2!doc5,f1!f2!doc5/5", "q","*:*");
+ doQuery("a!b!,b!doc1,c!doc2,d!doc3,e!doc4,f1!f2!doc5,f1!f2!doc5/5", "q", "*:*");
}
-
public void doTestNumRequests() throws Exception {
log.info("### STARTING doTestNumRequests");
List<CloudJettyRunner> runners = shardToJetty.get(bucket1);
CloudJettyRunner leader = shardToLeaderJetty.get(bucket1);
- CloudJettyRunner replica = null;
+ CloudJettyRunner replica = null;
for (CloudJettyRunner r : runners) {
if (r != leader) replica = r;
}
long nStart = getNumRequests();
- leader.client.solrClient.add( sdoc("id","b!doc1") );
+ leader.client.solrClient.add(sdoc("id", "b!doc1"));
long nEnd = getNumRequests();
- assertEquals(2, nEnd - nStart); // one request to leader, which makes another to a replica
-
+ assertEquals(2, nEnd - nStart); // one request to leader, which makes another to a replica
nStart = getNumRequests();
- replica.client.solrClient.add( sdoc("id","b!doc1") );
+ replica.client.solrClient.add(sdoc("id", "b!doc1"));
nEnd = getNumRequests();
- assertEquals(3, nEnd - nStart); // orig request + replica forwards to leader, which forward back to replica.
+ assertEquals(
+ 3,
+ nEnd - nStart); // orig request + replica forwards to leader, which forward back to replica.
nStart = getNumRequests();
- replica.client.solrClient.add( sdoc("id","b!doc1") );
+ replica.client.solrClient.add(sdoc("id", "b!doc1"));
nEnd = getNumRequests();
- assertEquals(3, nEnd - nStart); // orig request + replica forwards to leader, which forward back to replica.
+ assertEquals(
+ 3,
+ nEnd - nStart); // orig request + replica forwards to leader, which forward back to replica.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java
##########
@@ -230,25 +255,35 @@ protected void doTestConfigUpdate(String testCollectionName, String solrUrl) thr
assertNotNull(maxTimeFromConfig);
assertEquals(maxTime, maxTimeFromConfig);
- // Just check that we can access paths with slashes in them both through an intermediate method and explicitly
+ // Just check that we can access paths with slashes in them both through an intermediate method
+ // and explicitly
// using atPath.
- assertEquals("Should have been able to get a value from the /query request handler",
- "explicit", SolrCLI.asString("/config/requestHandler/\\/query/defaults/echoParams", configJson));
+ assertEquals(
+ "Should have been able to get a value from the /query request handler",
+ "explicit",
+ SolrCLI.asString("/config/requestHandler/\\/query/defaults/echoParams", configJson));
- assertEquals("Should have been able to get a value from the /query request handler",
- "explicit", SolrCLI.atPath("/config/requestHandler/\\/query/defaults/echoParams", configJson));
+ assertEquals(
+ "Should have been able to get a value from the /query request handler",
+ "explicit",
+ SolrCLI.atPath("/config/requestHandler/\\/query/defaults/echoParams", configJson));
if (log.isInfoEnabled()) {
- log.info("live_nodes_count : {}", cloudClient.getZkStateReader().getClusterState().getLiveNodes());
+ log.info(
+ "live_nodes_count : {}",
+ cloudClient.getZkStateReader().getClusterState().getLiveNodes());
}
- // Since it takes some time for this command to complete we need to make sure all the reloads for
+ // Since it takes some time for this command to complete we need to make sure all the reloads
+ // for
// all the cores have been done.
boolean allGood = false;
Map<String, Long> curSoftCommitInterval = null;
for (int idx = 0; idx < 600 && allGood == false; ++idx) {
curSoftCommitInterval = getSoftAutocommitInterval(testCollectionName);
- if (curSoftCommitInterval.size() > 0 && curSoftCommitInterval.size() == startTimes.size()) { // no point in even trying if they're not the same size!
+ if (curSoftCommitInterval.size() > 0
+ && curSoftCommitInterval.size()
+ == startTimes.size()) { // no point in even trying if they're not the same size!
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/SolrCLIZkUtilsTest.java
##########
@@ -165,149 +199,235 @@ public void testCp() throws Exception {
AbstractDistribZkTestBase.copyConfigUp(configSet, "cloud-subdirs", "cp1", zkAddr);
// Now copy it somewhere else on ZK.
- String[] args = new String[]{
- "-src", "zk:/configs/cp1",
- "-dst", "zk:/cp2",
- "-recurse", "true",
- "-zkHost", zkAddr,
- };
+ String[] args =
+ new String[] {
+ "-src", "zk:/configs/cp1",
+ "-dst", "zk:/cp2",
+ "-recurse", "true",
+ "-zkHost", zkAddr,
+ };
SolrCLI.ZkCpTool cpTool = new SolrCLI.ZkCpTool();
- int res = cpTool.runTool(SolrCLI.processCommandLineArgs(SolrCLI.joinCommonAndToolOptions(cpTool.getOptions()), args));
+ int res =
+ cpTool.runTool(
+ SolrCLI.processCommandLineArgs(
+ SolrCLI.joinCommonAndToolOptions(cpTool.getOptions()), args));
assertEquals("Copy from zk -> zk should have succeeded.", 0, res);
verifyZnodesMatch("/configs/cp1", "/cp2");
-
// try with zk->local
Path tmp = createTempDir("tmpNewPlace2");
- args = new String[]{
- "-src", "zk:/configs/cp1",
- "-dst", "file:" + tmp.toAbsolutePath().toString(),
- "-recurse", "true",
- "-zkHost", zkAddr,
- };
-
- res = cpTool.runTool(SolrCLI.processCommandLineArgs(SolrCLI.joinCommonAndToolOptions(cpTool.getOptions()), args));
+ args =
+ new String[] {
+ "-src",
+ "zk:/configs/cp1",
+ "-dst",
+ "file:" + tmp.toAbsolutePath().toString(),
+ "-recurse",
+ "true",
+ "-zkHost",
+ zkAddr,
+ };
+
+ res =
+ cpTool.runTool(
+ SolrCLI.processCommandLineArgs(
+ SolrCLI.joinCommonAndToolOptions(cpTool.getOptions()), args));
assertEquals("Copy should have succeeded.", 0, res);
verifyZkLocalPathsMatch(tmp, "/configs/cp1");
-
// try with zk->local no file: prefix
tmp = createTempDir("tmpNewPlace3");
- args = new String[]{
- "-src", "zk:/configs/cp1",
- "-dst", tmp.toAbsolutePath().toString(),
- "-recurse", "true",
- "-zkHost", zkAddr,
- };
-
- res = cpTool.runTool(SolrCLI.processCommandLineArgs(SolrCLI.joinCommonAndToolOptions(cpTool.getOptions()), args));
+ args =
+ new String[] {
+ "-src",
+ "zk:/configs/cp1",
+ "-dst",
+ tmp.toAbsolutePath().toString(),
+ "-recurse",
+ "true",
+ "-zkHost",
+ zkAddr,
+ };
+
+ res =
+ cpTool.runTool(
+ SolrCLI.processCommandLineArgs(
+ SolrCLI.joinCommonAndToolOptions(cpTool.getOptions()), args));
assertEquals("Copy should have succeeded.", 0, res);
verifyZkLocalPathsMatch(tmp, "/configs/cp1");
-
// try with local->zk
- args = new String[]{
- "-src", srcPathCheck.toAbsolutePath().toString(),
- "-dst", "zk:/cp3",
- "-recurse", "true",
- "-zkHost", zkAddr,
- };
-
- res = cpTool.runTool(SolrCLI.processCommandLineArgs(SolrCLI.joinCommonAndToolOptions(cpTool.getOptions()), args));
+ args =
+ new String[] {
+ "-src",
+ srcPathCheck.toAbsolutePath().toString(),
+ "-dst",
+ "zk:/cp3",
+ "-recurse",
+ "true",
+ "-zkHost",
+ zkAddr,
+ };
+
+ res =
+ cpTool.runTool(
+ SolrCLI.processCommandLineArgs(
+ SolrCLI.joinCommonAndToolOptions(cpTool.getOptions()), args));
assertEquals("Copy should have succeeded.", 0, res);
verifyZkLocalPathsMatch(srcPathCheck, "/cp3");
// try with local->zk, file: specified
- args = new String[]{
- "-src", "file:" + srcPathCheck.toAbsolutePath().toString(),
- "-dst", "zk:/cp4",
- "-recurse", "true",
- "-zkHost", zkAddr,
- };
-
- res = cpTool.runTool(SolrCLI.processCommandLineArgs(SolrCLI.joinCommonAndToolOptions(cpTool.getOptions()), args));
+ args =
+ new String[] {
+ "-src",
+ "file:" + srcPathCheck.toAbsolutePath().toString(),
+ "-dst",
+ "zk:/cp4",
+ "-recurse",
+ "true",
+ "-zkHost",
+ zkAddr,
+ };
+
+ res =
+ cpTool.runTool(
+ SolrCLI.processCommandLineArgs(
+ SolrCLI.joinCommonAndToolOptions(cpTool.getOptions()), args));
assertEquals("Copy should have succeeded.", 0, res);
verifyZkLocalPathsMatch(srcPathCheck, "/cp4");
// try with recurse not specified
- args = new String[]{
- "-src", "file:" + srcPathCheck.toAbsolutePath().toString(),
- "-dst", "zk:/cp5Fail",
- "-zkHost", zkAddr,
- };
-
- res = cpTool.runTool(SolrCLI.processCommandLineArgs(SolrCLI.joinCommonAndToolOptions(cpTool.getOptions()), args));
+ args =
+ new String[] {
+ "-src",
+ "file:" + srcPathCheck.toAbsolutePath().toString(),
+ "-dst",
+ "zk:/cp5Fail",
+ "-zkHost",
+ zkAddr,
+ };
+
+ res =
+ cpTool.runTool(
+ SolrCLI.processCommandLineArgs(
+ SolrCLI.joinCommonAndToolOptions(cpTool.getOptions()), args));
assertTrue("Copy should NOT have succeeded, recurse not specified.", 0 != res);
// try with recurse = false
- args = new String[]{
- "-src", "file:" + srcPathCheck.toAbsolutePath().toString(),
- "-dst", "zk:/cp6Fail",
- "-recurse", "false",
- "-zkHost", zkAddr,
- };
-
- res = cpTool.runTool(SolrCLI.processCommandLineArgs(SolrCLI.joinCommonAndToolOptions(cpTool.getOptions()), args));
+ args =
+ new String[] {
+ "-src",
+ "file:" + srcPathCheck.toAbsolutePath().toString(),
+ "-dst",
+ "zk:/cp6Fail",
+ "-recurse",
+ "false",
+ "-zkHost",
+ zkAddr,
+ };
+
+ res =
+ cpTool.runTool(
+ SolrCLI.processCommandLineArgs(
+ SolrCLI.joinCommonAndToolOptions(cpTool.getOptions()), args));
assertTrue("Copy should NOT have succeeded, recurse set to false.", 0 != res);
-
- // NOTE: really can't test copying to '.' because the test framework doesn't allow altering the source tree
+ // NOTE: really can't test copying to '.' because the test framework doesn't allow altering the
+ // source tree
// and at least IntelliJ's CWD is in the source tree.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java
##########
@@ -230,25 +255,35 @@ protected void doTestConfigUpdate(String testCollectionName, String solrUrl) thr
assertNotNull(maxTimeFromConfig);
assertEquals(maxTime, maxTimeFromConfig);
- // Just check that we can access paths with slashes in them both through an intermediate method and explicitly
+ // Just check that we can access paths with slashes in them both through an intermediate method
+ // and explicitly
// using atPath.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/api/collections/ReplicaPropertiesBase.java
##########
@@ -66,23 +68,36 @@ public static void verifyPropertyNotPresent(CloudSolrClient client, String colle
if (StringUtils.isBlank(replica.getProperty(property))) return;
Thread.sleep(100);
}
- fail("Property " + property + " not set correctly for collection/replica pair: " +
- collectionName + "/" + replicaName + ". Replica props: " + replica.getProperties().toString() +
- ". Cluster state is " + clusterState.toString());
-
+ fail(
+ "Property "
+ + property
+ + " not set correctly for collection/replica pair: "
+ + collectionName
+ + "/"
+ + replicaName
+ + ". Replica props: "
+ + replica.getProperties().toString()
+ + ". Cluster state is "
+ + clusterState.toString());
}
// The params are triplets,
// collection
// shard
// replica
- public static void verifyPropertyVal(CloudSolrClient client, String collectionName,
- String replicaName, String property, String val)
+ public static void verifyPropertyVal(
+ CloudSolrClient client,
+ String collectionName,
+ String replicaName,
+ String property,
+ String val)
throws InterruptedException, KeeperException {
Replica replica = null;
ClusterState clusterState = null;
- for (int idx = 0; idx < 300; ++idx) { // Keep trying while Overseer writes the ZK state for up to 30 seconds.
+ for (int idx = 0;
+ idx < 300;
+ ++idx) { // Keep trying while Overseer writes the ZK state for up to 30 seconds.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
##########
@@ -134,215 +133,166 @@ public void testSomeStuff() throws Exception {
assertTrue(metrics.containsKey("CORE.coreName"));
assertTrue(metrics.containsKey("CORE.refCount"));
@SuppressWarnings({"unchecked"})
- Gauge<Number> g = (Gauge<Number>)metrics.get("CORE.refCount");
+ Gauge<Number> g = (Gauge<Number>) metrics.get("CORE.refCount");
assertTrue(g.getValue().intValue() > 0);
- lrf.args.put(CommonParams.VERSION,"2.2");
- assertQ("test query on empty index",
- req("qlkciyopsbgzyvkylsjhchghjrdf")
- ,"//result[@numFound='0']"
- );
+ lrf.args.put(CommonParams.VERSION, "2.2");
+ assertQ(
+ "test query on empty index",
+ req("qlkciyopsbgzyvkylsjhchghjrdf"),
+ "//result[@numFound='0']");
// test escaping of ";"
- assertU("deleting 42 for no reason at all",
- delI("42"));
- assertU("adding doc#42",
- adoc("id", "42", "val_s", "aa;bb"));
- assertU("does commit work?",
- commit());
-
- assertQ("backslash escaping semicolon",
- req("id:42 AND val_s:aa\\;bb")
- ,"//*[@numFound='1']"
- ,"//str[@name='id'][.='42']"
- );
-
- assertQ("quote escaping semicolon",
- req("id:42 AND val_s:\"aa;bb\"")
- ,"//*[@numFound='1']"
- ,"//str[@name='id'][.='42']"
- );
-
- assertQ("no escaping semicolon",
- req("id:42 AND val_s:aa")
- ,"//*[@numFound='0']"
- );
+ assertU("deleting 42 for no reason at all", delI("42"));
+ assertU("adding doc#42", adoc("id", "42", "val_s", "aa;bb"));
+ assertU("does commit work?", commit());
+
+ assertQ(
+ "backslash escaping semicolon",
+ req("id:42 AND val_s:aa\\;bb"),
+ "//*[@numFound='1']",
+ "//str[@name='id'][.='42']");
+
+ assertQ(
+ "quote escaping semicolon",
+ req("id:42 AND val_s:\"aa;bb\""),
+ "//*[@numFound='1']",
+ "//str[@name='id'][.='42']");
+
+ assertQ("no escaping semicolon", req("id:42 AND val_s:aa"), "//*[@numFound='0']");
assertU(delI("42"));
assertU(commit());
- assertQ(req("id:42")
- ,"//*[@numFound='0']"
- );
+ assertQ(req("id:42"), "//*[@numFound='0']");
// test overwrite default of true
assertU(adoc("id", "42", "val_s", "AAA"));
assertU(adoc("id", "42", "val_s", "BBB"));
assertU(commit());
- assertQ(req("id:42")
- ,"//*[@numFound='1']"
- ,"//str[.='BBB']"
- );
+ assertQ(req("id:42"), "//*[@numFound='1']", "//str[.='BBB']");
assertU(adoc("id", "42", "val_s", "CCC"));
assertU(adoc("id", "42", "val_s", "DDD"));
assertU(commit());
- assertQ(req("id:42")
- ,"//*[@numFound='1']"
- ,"//str[.='DDD']"
- );
+ assertQ(req("id:42"), "//*[@numFound='1']", "//str[.='DDD']");
// test deletes
- String [] adds = new String[] {
- add( doc("id","101"), "overwrite", "true" ),
- add( doc("id","101"), "overwrite", "true" ),
- add( doc("id","105"), "overwrite", "false" ),
- add( doc("id","102"), "overwrite", "true" ),
- add( doc("id","103"), "overwrite", "false" ),
- add( doc("id","101"), "overwrite", "true" ),
- };
+ String[] adds =
+ new String[] {
+ add(doc("id", "101"), "overwrite", "true"),
+ add(doc("id", "101"), "overwrite", "true"),
+ add(doc("id", "105"), "overwrite", "false"),
+ add(doc("id", "102"), "overwrite", "true"),
+ add(doc("id", "103"), "overwrite", "false"),
+ add(doc("id", "101"), "overwrite", "true"),
+ };
for (String a : adds) {
assertU(a, a);
}
assertU(commit());
// test maxint
- assertQ(req("q","id:[100 TO 110]", "rows","2147483647")
- ,"//*[@numFound='4']"
- );
+ assertQ(req("q", "id:[100 TO 110]", "rows", "2147483647"), "//*[@numFound='4']");
// test big limit
- assertQ(req("q","id:[100 TO 111]", "rows","1147483647")
- ,"//*[@numFound='4']"
- );
+ assertQ(req("q", "id:[100 TO 111]", "rows", "1147483647"), "//*[@numFound='4']");
- assertQ(req("id:[100 TO 110]")
- ,"//*[@numFound='4']"
- );
+ assertQ(req("id:[100 TO 110]"), "//*[@numFound='4']");
assertU(delI("102"));
assertU(commit());
- assertQ(req("id:[100 TO 110]")
- ,"//*[@numFound='3']"
- );
+ assertQ(req("id:[100 TO 110]"), "//*[@numFound='3']");
assertU(delI("105"));
assertU(commit());
- assertQ(req("id:[100 TO 110]")
- ,"//*[@numFound='2']"
- );
+ assertQ(req("id:[100 TO 110]"), "//*[@numFound='2']");
assertU(delQ("id:[100 TO 110]"));
assertU(commit());
- assertQ(req("id:[100 TO 110]")
- ,"//*[@numFound='0']"
- );
-
+ assertQ(req("id:[100 TO 110]"), "//*[@numFound='0']");
+
assertU(BaseTestHarness.simpleTag("rollback"));
assertU(commit());
}
-
- /**
- * verify that delete by query works with the QParser framework and
- * pure negative queries
- */
+ /** verify that delete by query works with the QParser framework and pure negative queries */
public void testNonTrivialDeleteByQuery() throws Exception {
clearIndex();
-
+
// setup
- assertU( add(doc("id","101", "text", "red apple" )) );
- assertU( add(doc("id","102", "text", "purple grape" )) );
- assertU( add(doc("id","103", "text", "green grape" )) );
- assertU( add(doc("id","104", "text", "green pear" )) );
- assertU( add(doc("id","105", "text", "yellow banana" )) );
- assertU( add(doc("id","106", "text", "red cherry" )) );
+ assertU(add(doc("id", "101", "text", "red apple")));
+ assertU(add(doc("id", "102", "text", "purple grape")));
+ assertU(add(doc("id", "103", "text", "green grape")));
+ assertU(add(doc("id", "104", "text", "green pear")));
+ assertU(add(doc("id", "105", "text", "yellow banana")));
+ assertU(add(doc("id", "106", "text", "red cherry")));
// sanity checks
assertU(commit());
- assertQ(req("id:[100 TO 110]")
- ,"//*[@numFound='6']"
- );
- assertQ(req("*:*")
- ,"//*[@numFound='6']"
- );
- assertQ(req("text:red")
- ,"//*[@numFound='2']"
- );
- assertQ(req("-text:red")
- ,"//*[@numFound='4']"
- );
- assertQ(req("text:grape")
- ,"//*[@numFound='2']"
- );
- assertQ(req("-text:grape")
- ,"//*[@numFound='4']"
- );
- assertQ(req("-text:red -text:grape")
- ,"//*[@numFound='2']"
- );
- assertQ(req("{!lucene q.op=AND df=text}grape green")
- ,"//*[@numFound='1']"
- ,"//str[@name='id'][.='103']"
- );
- assertQ(req("-_val_:\"{!lucene q.op=AND df=text}grape green\"")
- ,"//*[@numFound='5']"
- ,"//str[@name='id'][.='101']"
- ,"//str[@name='id'][.='102']"
- ,"//str[@name='id'][.='104']"
- ,"//str[@name='id'][.='105']"
- ,"//str[@name='id'][.='106']"
- );
+ assertQ(req("id:[100 TO 110]"), "//*[@numFound='6']");
+ assertQ(req("*:*"), "//*[@numFound='6']");
+ assertQ(req("text:red"), "//*[@numFound='2']");
+ assertQ(req("-text:red"), "//*[@numFound='4']");
+ assertQ(req("text:grape"), "//*[@numFound='2']");
+ assertQ(req("-text:grape"), "//*[@numFound='4']");
+ assertQ(req("-text:red -text:grape"), "//*[@numFound='2']");
+ assertQ(
+ req("{!lucene q.op=AND df=text}grape green"),
+ "//*[@numFound='1']",
+ "//str[@name='id'][.='103']");
+ assertQ(
+ req("-_val_:\"{!lucene q.op=AND df=text}grape green\""),
+ "//*[@numFound='5']",
+ "//str[@name='id'][.='101']",
+ "//str[@name='id'][.='102']",
+ "//str[@name='id'][.='104']",
+ "//str[@name='id'][.='105']",
+ "//str[@name='id'][.='106']");
// tests
assertU(delQ("-*:*")); // NOOP
assertU(commit());
- assertQ(req("*:*")
- ,"//*[@numFound='6']"
- );
+ assertQ(req("*:*"), "//*[@numFound='6']");
assertU(delQ("-text:grape -text:red"));
assertU(commit());
- assertQ(req("*:*")
- ,"//*[@numFound='4']"
- ,"//str[@name='id'][.='101']"
- ,"//str[@name='id'][.='102']"
- ,"//str[@name='id'][.='103']"
- ,"//str[@name='id'][.='106']"
- );
+ assertQ(
+ req("*:*"),
+ "//*[@numFound='4']",
+ "//str[@name='id'][.='101']",
+ "//str[@name='id'][.='102']",
+ "//str[@name='id'][.='103']",
+ "//str[@name='id'][.='106']");
assertU(delQ("{!term f=id}106"));
assertU(commit());
- assertQ(req("*:*")
- ,"//*[@numFound='3']"
- ,"//str[@name='id'][.='101']"
- ,"//str[@name='id'][.='102']"
- ,"//str[@name='id'][.='103']"
- );
+ assertQ(
+ req("*:*"),
+ "//*[@numFound='3']",
+ "//str[@name='id'][.='101']",
+ "//str[@name='id'][.='102']",
+ "//str[@name='id'][.='103']");
assertU(delQ("-_val_:\"{!lucene q.op=AND df=text}grape green\""));
assertU(commit());
- assertQ(req("*:*")
- ,"//*[@numFound='1']"
- ,"//str[@name='id'][.='103']"
- );
+ assertQ(req("*:*"), "//*[@numFound='1']", "//str[@name='id'][.='103']");
assertU(delQ("-text:doesnotexist"));
assertU(commit());
- assertQ(req("*:*")
- ,"//*[@numFound='0']"
- );
-
+ assertQ(req("*:*"), "//*[@numFound='0']");
}
@Test
public void testHTMLStrip() {
- assertU(add(doc("id","200", "HTMLwhitetok","ABC")));
- assertU(add(doc("id","201", "HTMLwhitetok","ABC"))); // do it again to make sure reuse is working
+ assertU(add(doc("id", "200", "HTMLwhitetok", "ABC")));
+ assertU(
+ add(
+ doc(
+ "id",
+ "201",
+ "HTMLwhitetok",
+ "ABC"))); // do it again to make sure reuse is working
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/ZkShardTermsTest.java
##########
@@ -47,15 +46,19 @@
@BeforeClass
public static void setupCluster() throws Exception {
configureCluster(1)
- .addConfig("conf1", TEST_PATH().resolve("configsets").resolve("cloud-minimal").resolve("conf"))
+ .addConfig(
+ "conf1", TEST_PATH().resolve("configsets").resolve("cloud-minimal").resolve("conf"))
.configure();
}
@Test
- // commented out on: 17-Feb-2019 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // added 15-Sep-2018
- public void testParticipationOfReplicas() throws IOException, SolrServerException, InterruptedException {
+ // commented out on: 17-Feb-2019
+ // @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // added 15-Sep-2018
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
##########
@@ -783,39 +937,56 @@ protected void testTemplate(Integer numberOfNodes, Integer numberOfNodesToCreate
createNodeList.add(node);
}
}
-
- if (random().nextBoolean()) Collections.shuffle(createNodeList, random());
- underTest = new OverseerCollectionConfigSetProcessorToBeTested(zkStateReaderMock,
- "1234", shardHandlerFactoryMock, ADMIN_PATH, workQueueMock, runningMapMock,
- overseerMock, completedMapMock, failureMapMock, solrMetricsContextMock);
+ if (random().nextBoolean()) Collections.shuffle(createNodeList, random());
+ underTest =
+ new OverseerCollectionConfigSetProcessorToBeTested(
+ zkStateReaderMock,
+ "1234",
+ shardHandlerFactoryMock,
+ ADMIN_PATH,
+ workQueueMock,
+ runningMapMock,
+ overseerMock,
+ completedMapMock,
+ failureMapMock,
+ solrMetricsContextMock);
if (log.isInfoEnabled()) {
log.info("clusterstate {}", clusterStateMock.hashCode());
}
startComponentUnderTest();
-
- final List<String> createNodeListToSend = ((createNodeListOption != CreateNodeListOptions.SEND_NULL) ? createNodeList : null);
+
+ final List<String> createNodeListToSend =
+ ((createNodeListOption != CreateNodeListOptions.SEND_NULL) ? createNodeList : null);
final boolean sendCreateNodeList = (createNodeListOption != CreateNodeListOptions.DONT_SEND);
- final boolean dontShuffleCreateNodeSet = (createNodeListToSend != null) && sendCreateNodeList && random().nextBoolean();
- issueCreateJob(numberOfSlices, replicationFactor, createNodeListToSend, sendCreateNodeList, !dontShuffleCreateNodeSet);
+ final boolean dontShuffleCreateNodeSet =
+ (createNodeListToSend != null) && sendCreateNodeList && random().nextBoolean();
+ issueCreateJob(
+ numberOfSlices,
+ replicationFactor,
+ createNodeListToSend,
+ sendCreateNodeList,
+ !dontShuffleCreateNodeSet);
waitForEmptyQueue(10000);
if (collectionExceptedToBeCreated) {
assertNotNull(lastProcessMessageResult.getResponse().toString(), lastProcessMessageResult);
}
if (collectionExceptedToBeCreated) {
- verifySubmitCaptures(numberOfSlices, replicationFactor,
- createNodeList, dontShuffleCreateNodeSet);
+ verifySubmitCaptures(
+ numberOfSlices, replicationFactor, createNodeList, dontShuffleCreateNodeSet);
}
}
- // Tests below are being run twice: once with Overseer based updates and once with distributed updates.
+ // Tests below are being run twice: once with Overseer based updates and once with distributed
+ // updates.
// This is done explicitly here because these tests use mocks than can be configured directly.
- // Tests not using mocks (most other tests) but using the MiniSolrCloudCluster are randomized to sometimes use Overseer
+ // Tests not using mocks (most other tests) but using the MiniSolrCloudCluster are randomized to
+ // sometimes use Overseer
// and sometimes distributed state updates (but not both for a given test and a given test seed).
// See the SolrCloudTestCase.Builder constructor and the rest of the Builder class.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java
##########
@@ -170,25 +178,26 @@ public void testNotInZkOrOnDiskWhenRequired() throws Exception {
public void testOnDiskOnly() throws Exception {
try {
setUpZkAndDiskXml(false, true);
- assertEquals("Should have gotten the default port", cfg.getCloudConfig().getSolrHostPort(), 8983);
+ assertEquals(
+ "Should have gotten the default port", cfg.getCloudConfig().getSolrHostPort(), 8983);
} finally {
closeZK();
}
}
- // Just a random port, I'm not going to use it but just check that the Solr instance constructed from the XML
+ // Just a random port, I'm not going to use it but just check that the Solr instance constructed
+ // from the XML
// file in ZK overrides the default port.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/api/collections/TestLocalFSCloudBackupRestore.java
##########
@@ -36,35 +35,51 @@
import org.junit.Test;
/**
- * This class implements the tests for local file-system integration for Solr backup/restore capability. Note that the
- * Solr backup/restore still requires a "shared" file-system. Its just that in this case such file-system would be
- * exposed via local file-system API.
+ * This class implements the tests for local file-system integration for Solr backup/restore
+ * capability. Note that the Solr backup/restore still requires a "shared" file-system. Its just
+ * that in this case such file-system would be exposed via local file-system API.
*/
-@LuceneTestCase.SuppressCodecs({"SimpleText"}) // Backups do checksum validation against a footer value not present in 'SimpleText'
+@LuceneTestCase.SuppressCodecs({
+ "SimpleText"
+}) // Backups do checksum validation against a footer value not present in 'SimpleText'
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/overseer/ZkCollectionPropsCachingTest.java
##########
@@ -37,18 +36,18 @@
@SolrTestCaseJ4.SuppressSSL
public class ZkCollectionPropsCachingTest extends SolrCloudTestCase {
//
- // NOTE: This class can only have one test because our test for caching is to nuke the SolrZkClient to
- // verify that a cached load is going to hit the cache, not try to talk to zk. Any other ZK related test
+ // NOTE: This class can only have one test because our test for caching is to nuke the
+ // SolrZkClient to
+ // verify that a cached load is going to hit the cache, not try to talk to zk. Any other ZK
+ // related test
// method in this class will fail if it runs after testReadWriteCached, so don't add one! :)
//
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/api/collections/LocalFSCloudIncrementalBackupTest.java
##########
@@ -20,67 +20,70 @@
import org.apache.lucene.util.LuceneTestCase;
import org.junit.BeforeClass;
-@LuceneTestCase.SuppressCodecs({"SimpleText"}) // Backups do checksum validation against a footer value not present in 'SimpleText'
+@LuceneTestCase.SuppressCodecs({
+ "SimpleText"
+}) // Backups do checksum validation against a footer value not present in 'SimpleText'
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/cloud/overseer/ZkCollectionPropsCachingTest.java
##########
@@ -70,27 +70,31 @@ public void testReadWriteCached() throws InterruptedException, IOException {
CollectionProperties collectionProps = new CollectionProperties(zkClient());
collectionProps.setCollectionProperty(collectionName, "property1", "value1");
- checkValue("property1", "value1"); //Should be no cache, so the change should take effect immediately
+ checkValue(
+ "property1", "value1"); // Should be no cache, so the change should take effect immediately
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/core/BlobRepositoryCloudTest.java
##########
@@ -70,18 +74,20 @@ public static void setupCluster() throws Exception {
solrClient.add("col2", document);
solrClient.commit("col2");
Thread.sleep(2000);
-
}
@Test
public void test() throws Exception {
- // This test relies on the installation of ResourceSharingTestComponent which has 2 useful properties:
- // 1. it will fail to initialize if it doesn't find a 2 line CSV like foo,bar\nbaz,bam thus validating
+ // This test relies on the installation of ResourceSharingTestComponent which has 2 useful
+ // properties:
+ // 1. it will fail to initialize if it doesn't find a 2 line CSV like foo,bar\nbaz,bam thus
+ // validating
// that we are properly pulling data from the blob store
- // 2. It replaces any q for a query request to /select with "text:<name>" where <name> is the name
+ // 2. It replaces any q for a query request to /select with "text:<name>" where <name> is the
+ // name
// of the last collection to run a query. It does this by caching a shared resource of type
// ResourceSharingTestComponent.TestObject, and the following sequence is proof that either
- // collection can tell if it was (or was not) the last collection to issue a query by
+ // collection can tell if it was (or was not) the last collection to issue a query by
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
##########
@@ -58,72 +62,100 @@ public static void createIndex() {
@Test
public void testPrefixQuery() throws Exception {
String q = "name:a*";
- assertJQ(req("q", q, "timeAllowed", "1", "sleep", sleep), failureAssertionString);
+ assertJQ(req("q", q, "timeAllowed", "1", "sleep", sleep), failureAssertionString);
- // do the same query and test for both success, and that the number of documents matched (i.e. make sure no partial results were cached)
+ // do the same query and test for both success, and that the number of documents matched (i.e.
+ // make sure no partial results were cached)
assertJQ(req("q", q, "timeAllowed", longTimeout), assertionString);
- // this time we should get a query cache hit and hopefully no exception? this may change in the future if time checks are put into other places.
- assertJQ(req("q", q, "timeAllowed", "1", "sleep", sleep), assertionString);
+ // this time we should get a query cache hit and hopefully no exception? this may change in the
+ // future if time checks are put into other places.
+ assertJQ(req("q", q, "timeAllowed", "1", "sleep", sleep), assertionString);
// now do the same for the filter cache
- assertJQ(req("q","*:*", "fq",q, "timeAllowed", "1", "sleep", sleep), failureAssertionString);
+ assertJQ(req("q", "*:*", "fq", q, "timeAllowed", "1", "sleep", sleep), failureAssertionString);
// make sure that the result succeeds this time, and that a bad filter wasn't cached
- assertJQ(req("q","*:*", "fq",q, "timeAllowed", longTimeout), assertionString);
+ assertJQ(req("q", "*:*", "fq", q, "timeAllowed", longTimeout), assertionString);
// test that Long.MAX_VALUE works
- assertJQ(req("q","name:b*", "timeAllowed",Long.toString(Long.MAX_VALUE)), assertionString);
+ assertJQ(req("q", "name:b*", "timeAllowed", Long.toString(Long.MAX_VALUE)), assertionString);
// negative timeAllowed should disable timeouts.
assertJQ(req("q", "name:c*", "timeAllowed", "-7"), assertionString);
}
-
-
-
- // There are lots of assumptions about how/when cache entries should be changed in this method. The
+ // There are lots of assumptions about how/when cache entries should be changed in this method.
+ // The
// simple case above shows the root problem without the confusion. testFilterSimpleCase should be
// removed once it is running and this test should be un-ignored and the assumptions verified.
// With all the weirdness, I'm not going to vouch for this test. Feel free to change it.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java
##########
@@ -44,25 +43,29 @@ public void setUp() throws Exception {
System.setProperty("solr.directoryFactory", "org.apache.solr.core.NIOFSDirectoryFactory");
// test tests native and simple in the same jvm in the same exact directory:
- // the file will remain after the native test (it cannot safely be deleted without the risk of deleting another guys lock)
- // it's ok, these aren't "compatible" anyway: really this test should not re-use the same directory at all.
- Files.deleteIfExists(new File(new File(initAndGetDataDir(), "index"), IndexWriter.WRITE_LOCK_NAME).toPath());
+ // the file will remain after the native test (it cannot safely be deleted without the risk of
+ // deleting another guys lock)
+ // it's ok, these aren't "compatible" anyway: really this test should not re-use the same
+ // directory at all.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
##########
@@ -58,72 +62,100 @@ public static void createIndex() {
@Test
public void testPrefixQuery() throws Exception {
String q = "name:a*";
- assertJQ(req("q", q, "timeAllowed", "1", "sleep", sleep), failureAssertionString);
+ assertJQ(req("q", q, "timeAllowed", "1", "sleep", sleep), failureAssertionString);
- // do the same query and test for both success, and that the number of documents matched (i.e. make sure no partial results were cached)
+ // do the same query and test for both success, and that the number of documents matched (i.e.
+ // make sure no partial results were cached)
assertJQ(req("q", q, "timeAllowed", longTimeout), assertionString);
- // this time we should get a query cache hit and hopefully no exception? this may change in the future if time checks are put into other places.
- assertJQ(req("q", q, "timeAllowed", "1", "sleep", sleep), assertionString);
+ // this time we should get a query cache hit and hopefully no exception? this may change in the
+ // future if time checks are put into other places.
+ assertJQ(req("q", q, "timeAllowed", "1", "sleep", sleep), assertionString);
// now do the same for the filter cache
- assertJQ(req("q","*:*", "fq",q, "timeAllowed", "1", "sleep", sleep), failureAssertionString);
+ assertJQ(req("q", "*:*", "fq", q, "timeAllowed", "1", "sleep", sleep), failureAssertionString);
// make sure that the result succeeds this time, and that a bad filter wasn't cached
- assertJQ(req("q","*:*", "fq",q, "timeAllowed", longTimeout), assertionString);
+ assertJQ(req("q", "*:*", "fq", q, "timeAllowed", longTimeout), assertionString);
// test that Long.MAX_VALUE works
- assertJQ(req("q","name:b*", "timeAllowed",Long.toString(Long.MAX_VALUE)), assertionString);
+ assertJQ(req("q", "name:b*", "timeAllowed", Long.toString(Long.MAX_VALUE)), assertionString);
// negative timeAllowed should disable timeouts.
assertJQ(req("q", "name:c*", "timeAllowed", "-7"), assertionString);
}
-
-
-
- // There are lots of assumptions about how/when cache entries should be changed in this method. The
+ // There are lots of assumptions about how/when cache entries should be changed in this method.
+ // The
// simple case above shows the root problem without the confusion. testFilterSimpleCase should be
// removed once it is running and this test should be un-ignored and the assumptions verified.
// With all the weirdness, I'm not going to vouch for this test. Feel free to change it.
@Test
public void testCacheAssumptions() throws Exception {
- String fq= "name:d*";
+ String fq = "name:d*";
SolrCore core = h.getCore();
- MetricsMap filterCacheStats = (MetricsMap)((SolrMetricManager.GaugeWrapper<?>)core.getCoreMetricManager().getRegistry().getMetrics().get("CACHE.searcher.filterCache")).getGauge();
+ MetricsMap filterCacheStats =
+ (MetricsMap)
+ ((SolrMetricManager.GaugeWrapper<?>)
+ core.getCoreMetricManager()
+ .getRegistry()
+ .getMetrics()
+ .get("CACHE.searcher.filterCache"))
+ .getGauge();
long fqInserts = (long) filterCacheStats.getValue().get("inserts");
- MetricsMap queryCacheStats = (MetricsMap)((SolrMetricManager.GaugeWrapper<?>)core.getCoreMetricManager().getRegistry().getMetrics().get("CACHE.searcher.queryResultCache")).getGauge();
+ MetricsMap queryCacheStats =
+ (MetricsMap)
+ ((SolrMetricManager.GaugeWrapper<?>)
+ core.getCoreMetricManager()
+ .getRegistry()
+ .getMetrics()
+ .get("CACHE.searcher.queryResultCache"))
+ .getGauge();
long qrInserts = (long) queryCacheStats.getValue().get("inserts");
- // This gets 0 docs back. Use 10000 instead of 1 for timeAllowed and it gets 100 back and the for loop below
+ // This gets 0 docs back. Use 10000 instead of 1 for timeAllowed and it gets 100 back and the
+ // for loop below
// succeeds.
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/handler/TestSystemCollAutoCreate.java
##########
@@ -17,14 +17,17 @@
package org.apache.solr.handler;
-
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
import org.apache.solr.common.cloud.DocCollection;
public class TestSystemCollAutoCreate extends AbstractFullDistribZkTestBase {
- // commented out on: 17-Feb-2019 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on: 24-Dec-2018
+ // commented out on: 17-Feb-2019
+ // @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on:
+ // 24-Dec-2018
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java
##########
@@ -46,8 +47,8 @@ protected void assertToken(NamedList<?> token, TokenInfo info) {
}
}
-
- //================================================= Inner Classes ==================================================
+ // ================================================= Inner Classes
+ // ==================================================
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java
##########
@@ -41,22 +39,27 @@
import org.junit.Before;
import org.junit.Test;
-@SolrTestCaseJ4.SuppressSSL // Currently unknown why SSL does not work with this test
-@LuceneTestCase.SuppressCodecs("SimpleText") // Backups do checksum validation against a footer value not present in 'SimpleText'
+@SolrTestCaseJ4.SuppressSSL // Currently unknown why SSL does not work with this test
+@LuceneTestCase.SuppressCodecs(
+ "SimpleText") // Backups do checksum validation against a footer value not present in
+// 'SimpleText'
Review comment:
Fix this
##########
File path: solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java
##########
@@ -52,79 +51,84 @@ public static void beforeTest() throws Exception {
public void test404ViaHttp() throws Exception {
SolrClient client = getSolrClient();
- QueryRequest request = new QueryRequest(params("file",
- "does-not-exist-404.txt"));
+ QueryRequest request = new QueryRequest(params("file", "does-not-exist-404.txt"));
request.setPath("/admin/file");
SolrException e = expectThrows(SolrException.class, () -> request.process(client));
assertEquals(404, e.code());
}
public void test404Locally() throws Exception {
- // we need to test that executing the handler directly does not
+ // we need to test that executing the handler directly does not
// throw an exception, just sets the exception on the response.
// bypass TestHarness since it will throw any exception found in the
// response.
SolrCore core = h.getCore();
SolrQueryResponse rsp = new SolrQueryResponse();
- core.execute(core.getRequestHandler("/admin/file"),
- req("file", "does-not-exist-404.txt"), rsp);
+ core.execute(core.getRequestHandler("/admin/file"), req("file", "does-not-exist-404.txt"), rsp);
assertNotNull("no exception in response", rsp.getException());
- assertTrue("wrong type of exception: " + rsp.getException().getClass(),
+ assertTrue(
+ "wrong type of exception: " + rsp.getException().getClass(),
rsp.getException() instanceof SolrException);
- assertEquals(404, ((SolrException)rsp.getException()).code());
+ assertEquals(404, ((SolrException) rsp.getException()).code());
}
public void testDirList() throws SolrServerException, IOException {
SolrClient client = getSolrClient();
- //assertQ(req("qt", "/admin/file")); TODO file bug that SolrJettyTestBase extends SolrTestCaseJ4
+ // assertQ(req("qt", "/admin/file")); TODO file bug that SolrJettyTestBase extends
+ // SolrTestCaseJ4
QueryRequest request = new QueryRequest();
request.setPath("/admin/file");
QueryResponse resp = request.process(client);
- assertEquals(0,resp.getStatus());
- assertTrue(((NamedList) resp.getResponse().get("files")).size() > 0);//some files
+ assertEquals(0, resp.getStatus());
+ assertTrue(((NamedList) resp.getResponse().get("files")).size() > 0); // some files
}
public void testGetRawFile() throws SolrServerException, IOException {
SolrClient client = getSolrClient();
- //assertQ(req("qt", "/admin/file")); TODO file bug that SolrJettyTestBase extends SolrTestCaseJ4
+ // assertQ(req("qt", "/admin/file")); TODO file bug that SolrJettyTestBase extends
+ // SolrTestCaseJ4
QueryRequest request = new QueryRequest(params("file", "managed-schema"));
request.setPath("/admin/file");
final AtomicBoolean readFile = new AtomicBoolean();
- request.setResponseParser(new ResponseParser() {
- @Override
- public String getWriterType() {
- return "mock";//unfortunately this gets put onto params wt=mock but it apparently has no effect
- }
-
- @Override
- public NamedList<Object> processResponse(InputStream body, String encoding) {
- try {
- if (body.read() >= 0)
- readFile.set(true);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return null;
- }
-
- @Override
- public NamedList<Object> processResponse(Reader reader) {
- throw new UnsupportedOperationException("TODO unimplemented");//TODO
- }
- });
-
- client.request(request);//runs request
- //request.process(client); but we don't have a NamedList response
+ request.setResponseParser(
+ new ResponseParser() {
+ @Override
+ public String getWriterType() {
+ return "mock"; // unfortunately this gets put onto params wt=mock but it apparently has
+ // no effect
Review comment:
Fix this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org