SOLR-11035: (at least) 2 distinct failures possible when clients attempt searches during SolrCore reload. More fixes, bad test.

This commit is contained in:
Erick Erickson 2019-04-28 10:26:01 -04:00
parent 9d97ef1027
commit a6262af842
1 changed files with 43 additions and 30 deletions

View File

@ -50,8 +50,9 @@ import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.schema.SchemaResponse; import org.apache.solr.client.solrj.response.schema.SchemaResponse;
import org.apache.solr.common.SolrDocumentList; import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.SolrInputDocument;
import org.junit.After; import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.RuleChain; import org.junit.rules.RuleChain;
@ -76,8 +77,8 @@ public class DocValuesNotIndexedTest extends SolrCloudTestCase {
volatile static List<FieldProps> fieldsToTestGroupSortFirst = null; volatile static List<FieldProps> fieldsToTestGroupSortFirst = null;
volatile static List<FieldProps> fieldsToTestGroupSortLast = null; volatile static List<FieldProps> fieldsToTestGroupSortLast = null;
@Before @BeforeClass
public void createCluster() throws Exception { public static void createCluster() throws Exception {
System.setProperty("managed.schema.mutable", "true"); System.setProperty("managed.schema.mutable", "true");
configureCluster(2) configureCluster(2)
.addConfig("conf1", TEST_PATH().resolve("configsets").resolve("cloud-managed").resolve("conf")) .addConfig("conf1", TEST_PATH().resolve("configsets").resolve("cloud-managed").resolve("conf"))
@ -168,16 +169,29 @@ public class DocValuesNotIndexedTest extends SolrCloudTestCase {
} }
@After @AfterClass
public void after() throws Exception { public static void shutdown() throws Exception {
shutdownCluster(); shutdownCluster();
fieldsToTestSingle = null;
fieldsToTestMulti = null;
fieldsToTestGroupSortFirst = null;
fieldsToTestGroupSortLast = null;
} }
@Before
public void clean() throws IOException, SolrServerException {
CloudSolrClient client = cluster.getSolrClient();
client.deleteByQuery("*:*");
client.commit();
Solr11035BandAid(client, COLLECTION, "id", 0, "*:*");
resetFields(fieldsToTestSingle);
resetFields(fieldsToTestMulti);
resetFields(fieldsToTestGroupSortFirst);
resetFields(fieldsToTestGroupSortLast);
}
void resetFields(List<FieldProps> fieldProps) {
for (FieldProps prop : fieldProps) {
prop.resetBase();
}
}
@Test @Test
public void testDistribFaceting() throws IOException, SolrServerException { 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
@ -220,12 +234,10 @@ public class DocValuesNotIndexedTest extends SolrCloudTestCase {
for (FieldProps props : fieldsToTestMulti) { for (FieldProps props : fieldsToTestMulti) {
doTestFacet(props, rsp); doTestFacet(props, rsp);
} }
} }
// We should be able to sort thing with missing first/last and that are _NOT_ present at all on one server. // We should be able to sort thing with missing first/last and that are _NOT_ present at all on one server.
@Test @Test
//@AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-12028")
public void testGroupingSorting() throws IOException, SolrServerException { public void testGroupingSorting() throws IOException, SolrServerException {
CloudSolrClient client = cluster.getSolrClient(); CloudSolrClient client = cluster.getSolrClient();
@ -272,7 +284,6 @@ public class DocValuesNotIndexedTest extends SolrCloudTestCase {
} }
@Test @Test
// 12-Jun-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028")
public void testGroupingDocAbsent() throws IOException, SolrServerException { public void testGroupingDocAbsent() throws IOException, SolrServerException {
List<SolrInputDocument> docs = new ArrayList<>(4); List<SolrInputDocument> docs = new ArrayList<>(4);
docs.add(makeGSDoc(2, fieldsToTestGroupSortFirst, null)); docs.add(makeGSDoc(2, fieldsToTestGroupSortFirst, null));
@ -307,20 +318,20 @@ public class DocValuesNotIndexedTest extends SolrCloudTestCase {
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(); List<Group> fieldCommandGroups = fieldCommand.getValues();
if (!prop.getName().startsWith("intGSF")) { // TODO: can be 3 or 4
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 @Test
// Verify that we actually form groups that are "expected". Most of the processing takes some care to // 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_ // make sure all the values for each field are unique. We need to have docs that have values that are _not_
// unique. // unique.
// 12-Jun-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // 04-May-2018 public void testGroupingDVOnlySortFirst() throws IOException, SolrServerException {
// commented 15-Sep-2018 @LuceneTestCase.BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // 2-Aug-2018
public void testGroupingDVOnly() throws IOException, SolrServerException {
doGroupingDvOnly(fieldsToTestGroupSortFirst, "boolGSF"); doGroupingDvOnly(fieldsToTestGroupSortFirst, "boolGSF");
}
@Test
public void testGroupingDVOnlySortLast() throws IOException, SolrServerException {
doGroupingDvOnly(fieldsToTestGroupSortLast, "boolGSL"); doGroupingDvOnly(fieldsToTestGroupSortLast, "boolGSL");
} }
@ -336,7 +347,7 @@ public class DocValuesNotIndexedTest extends SolrCloudTestCase {
} }
docs.add(doc); docs.add(doc);
// Every fifth time through we add a doc with no values in any of the "fields of interest", so there shoule 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 // 10 docs with nulls
if ((idx % 5) == 0) { if ((idx % 5) == 0) {
doc = new SolrInputDocument(); doc = new SolrInputDocument();
@ -395,9 +406,9 @@ public class DocValuesNotIndexedTest extends SolrCloudTestCase {
break; break;
default: default:
if (!prop.getName().equals("intGSF")) { // TODO: this can be 6 or 8 as well fail("Unexpected number of elements in the group for '" + prop.getName() + "' size: '" + grp.getResult().size()
fail("Unexpected number of elements in the group for " + prop.getName() + ": " + grp.getResult().size() + " rsp: " + rsp); + "' GroupValue: '" + grp.getGroupValue()
} + "' rsp: " + rsp);
} }
} }
} }
@ -485,17 +496,19 @@ class FieldProps {
this.expectedCount = expectedCount; this.expectedCount = expectedCount;
resetBase(); resetBase();
} }
// There's a vague chance that counts will roll over, so let's insure we have some room to grow in a positive direction
void resetBase() { void resetBase() {
if (name.startsWith("int")) { if (name.startsWith("int")) {
base = Math.abs(random().nextInt()); base = Math.abs(random().nextInt()) / 2;
} else if (name.startsWith("long")) { } else if (name.startsWith("long")) {
base = Math.abs(random().nextLong()); base = Math.abs(random().nextLong()) / 2;
} else if (name.startsWith("float")) { } else if (name.startsWith("float")) {
base = Math.abs(random().nextFloat()); base = Math.abs(random().nextFloat()) / 2;
} else if (name.startsWith("double")) { } else if (name.startsWith("double")) {
base = Math.abs(random().nextDouble()); base = Math.abs(random().nextDouble()) / 2;
} else if (name.startsWith("date")) { } else if (name.startsWith("date")) {
base = Math.abs(random().nextLong()); base = Math.abs(random().nextLong()) / 2;
} else if (name.startsWith("bool")) { } else if (name.startsWith("bool")) {
base = true; // Must start with a known value since bools only have a two values.... base = true; // Must start with a known value since bools only have a two values....
} else if (name.startsWith("string") || name.startsWith("sortable")) { } else if (name.startsWith("string") || name.startsWith("sortable")) {
@ -524,7 +537,7 @@ class FieldProps {
public String getValue(boolean incrementCounter) { public String getValue(boolean incrementCounter) {
if (incrementCounter) { if (incrementCounter) {
counter += random().nextInt(10) + 10_000; counter += random().nextInt(10_000) + 1; // Must add something because nextInt could return zero
} }
if (name.startsWith("int")) { if (name.startsWith("int")) {
return Integer.toString((int) base + counter); return Integer.toString((int) base + counter);