Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
619ddcd
Improved error message for absence indices closes #38964
Eunovo Feb 21, 2019
ae8dee3
Remove ExceptionsHelper#detailedMessage in tests (#37921)
danielmitterdorfer Feb 22, 2019
d3bced2
Mute rolling upgrade watcher CRUD tests (#39293)
jkakavas Feb 22, 2019
31bfd91
Mute BasicWatcherTests.testConditionSearchWithIndexedTemplate (#39307)
romseygeek Feb 22, 2019
2b1c5a7
Mute IndexFollowingIT.testDeleteLeaderIndex (#39309)
romseygeek Feb 22, 2019
ca3b738
[ML] Improve DeleteExpiredDataIT failure message (#39298)
dimitris-athanasiou Feb 22, 2019
1e7f28e
Fix DissectParserTests expecting unique keys (#39262)
albertzaharovits Feb 22, 2019
73ba70d
[ML-DataFrame] Add _preview endpoint (#38924)
benwtrent Feb 22, 2019
ead14a8
[ML] Increase datafeed integration test timeout for slow machines (#3…
Feb 22, 2019
256b1cb
Fix the test failure in dense and sparse vectors (#39313)
mayya-sharipova Feb 22, 2019
9d54e74
Reduce garbage from allocations in deprecation logger (#38780)
ebadyano Feb 22, 2019
cbf9f3c
Simplify mocking in CCR retention lease tests
jasontedor Feb 22, 2019
ab26a57
Fix shard logged in background lease renewal
jasontedor Feb 22, 2019
91f69fc
Address failing CCR retention lease test
jasontedor Feb 22, 2019
14510a9
Change sort order of shard stats in CCR test
jasontedor Feb 22, 2019
fee33d5
Add test logging to CCR retention lease test
jasontedor Feb 22, 2019
094309e
Fix failing CCR retention lease test
jasontedor Feb 23, 2019
c897140
Add cause to assert_no_failure when replay translog (#39333)
dnhatn Feb 23, 2019
9d55105
Improved error message for No Indices (closes #38964)
Eunovo Feb 25, 2019
14c2e76
removed old solution to #38964
Eunovo Feb 25, 2019
c16d563
Added tests for No Indices Error Message
Eunovo Feb 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers;
import org.mockito.internal.util.collections.Sets;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -112,7 +112,7 @@ public void testBasicMatch() {
String delimiterFirstInput = "";
String delimiterFirstPattern = "";
//parallel arrays
List<String> expectedKeys = Arrays.asList(generateRandomStringArray(100, 10, false, false));
List<String> expectedKeys = new ArrayList<>(Sets.newSet(generateRandomStringArray(100, 10, false, false)));
List<String> expectedValues = new ArrayList<>(expectedKeys.size());
for (String key : expectedKeys) {
String value = randomAsciiAlphanumOfLengthBetween(1, 100);
Expand All @@ -127,7 +127,6 @@ public void testBasicMatch() {
assertMatch(delimiterFirstPattern, delimiterFirstInput, expectedKeys, expectedValues);
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/39244")
public void testBasicMatchUnicode() {
String valueFirstInput = "";
String keyFirstPattern = "";
Expand All @@ -138,6 +137,9 @@ public void testBasicMatchUnicode() {
List<String> expectedValues = new ArrayList<>();
for (int i = 0; i < randomIntBetween(1, 100); i++) {
String key = randomAsciiAlphanumOfLengthBetween(1, 100);
while (expectedKeys.contains(key)) { // keys should be unique in this test
key = randomAsciiAlphanumOfLengthBetween(1, 100);
}
String value = randomRealisticUnicodeOfCodepointLengthBetween(1, 100);
String delimiter = Integer.toString(randomInt()); //int to ensures values and delimiters don't overlap, else validation can fail
keyFirstPattern += "%{" + key + "}" + delimiter;
Expand Down Expand Up @@ -375,13 +377,11 @@ private void assertMatch(String pattern, String input, List<String> expectedKeys

private void assertMatch(String pattern, String input, List<String> expectedKeys, List<String> expectedValues, String appendSeperator) {
Map<String, String> results = new DissectParser(pattern, appendSeperator).parse(input);
List<String> foundKeys = new ArrayList<>(results.keySet());
List<String> foundValues = new ArrayList<>(results.values());
Collections.sort(foundKeys);
Collections.sort(foundValues);
Collections.sort(expectedKeys);
Collections.sort(expectedValues);
assertThat(foundKeys, Matchers.equalTo(expectedKeys));
assertThat(foundValues, Matchers.equalTo(expectedValues));
assertThat(results.size(), Matchers.equalTo(expectedKeys.size()));
assertThat(results.size(), Matchers.equalTo(expectedValues.size()));
for (int i = 0; i < results.size(); i++) {
final String key = expectedKeys.get(i);
assertThat(results.get(key), Matchers.equalTo(expectedValues.get(i)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ setup:
body:
settings:
number_of_replicas: 0
# we need to have 1 shard to get request failure in test "Dense vectors should error with sparse vector functions"
number_of_shards: 1
mappings:
properties:
my_dense_vector:
Expand Down Expand Up @@ -125,10 +127,6 @@ setup:
---
"Dense vectors should error with sparse vector functions":

- skip:
version: "all"
reason: "awaits fix in #39218"

- do:
index:
index: test-index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ setup:
body:
settings:
number_of_replicas: 0
# we need to have 1 shard to get request failure in test "Sparse vectors should error with dense vector functions"
number_of_shards: 1
mappings:
properties:
my_sparse_vector:
Expand Down Expand Up @@ -176,10 +178,6 @@ setup:
---
"Sparse vectors should error with dense vector functions":

- skip:
version: "all"
reason: "awaits fix in #39218"

- do:
index:
index: test-index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,16 @@ Index[] concreteIndices(Context context, String... indexExpressions) {
expressions = expressionResolver.resolve(context, expressions);
}

final String noIndicesErrorMessage = "no indices exist";

if (expressions.isEmpty()) {
if (!options.allowNoIndices()) {
IndexNotFoundException infe = new IndexNotFoundException((String)null);
if (indexExpressions.length == 1) {
if (indexExpressions[0].equals(MetaData.ALL)) {
infe = new IndexNotFoundException(noIndicesErrorMessage, (String)null);
}
}
infe.setResources("index_expression", indexExpressions);
throw infe;
} else {
Expand All @@ -173,7 +180,12 @@ Index[] concreteIndices(Context context, String... indexExpressions) {
AliasOrIndex aliasOrIndex = metaData.getAliasAndIndexLookup().get(expression);
if (aliasOrIndex == null ) {
if (failNoIndices) {
IndexNotFoundException infe = new IndexNotFoundException(expression);
IndexNotFoundException infe;
if(expression.equals(MetaData.ALL)) {
infe = new IndexNotFoundException(noIndicesErrorMessage, expression);
}else {
infe = new IndexNotFoundException(expression);
}
infe.setResources("index_expression", expression);
throw infe;
} else {
Expand Down Expand Up @@ -230,7 +242,7 @@ Index[] concreteIndices(Context context, String... indexExpressions) {
}

if (options.allowNoIndices() == false && concreteIndices.isEmpty()) {
IndexNotFoundException infe = new IndexNotFoundException((String)null);
IndexNotFoundException infe = new IndexNotFoundException("no indices exist", (String)null);
infe.setResources("index_expression", indexExpressions);
throw infe;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ public Void run() {
* @return a warning value formatted according to RFC 7234
*/
public static String formatWarning(final String s) {
return WARNING_PREFIX + " " + "\"" + escapeAndEncode(s) + "\"";
// Assume that the common scenario won't have a string to escape and encode.
int length = WARNING_PREFIX.length() + s.length() + 3;
final StringBuilder sb = new StringBuilder(length);
sb.append(WARNING_PREFIX).append(" \"").append(escapeAndEncode(s)).append("\"");
return sb.toString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static String format(final String prefix, final String messagePattern, fi
if (messagePattern == null) {
return null;
}
if (argArray == null) {
if (argArray == null || argArray.length == 0) {
if (prefix == null) {
return messagePattern;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexFormatTooNewException;
import org.apache.lucene.index.IndexFormatTooOldException;
import org.elasticsearch.Assertions;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.Version;
Expand Down Expand Up @@ -360,8 +361,12 @@ public void indexTranslogOperations(
if (result.getResultType() == Engine.Result.Type.MAPPING_UPDATE_REQUIRED) {
throw new MapperException("mapping updates are not allowed [" + operation + "]");
}
assert result.getFailure() == null : "unexpected failure while replicating translog entry: " + result.getFailure();
ExceptionsHelper.reThrowIfNotNull(result.getFailure());
if (result.getFailure() != null) {
if (Assertions.ENABLED) {
throw new AssertionError("unexpected failure while replicating translog entry", result.getFailure());
}
ExceptionsHelper.reThrowIfNotNull(result.getFailure());
}
}
// update stats only after all operations completed (to ensure that mapping updates don't mess with stats)
translog.incrementRecoveredOperations(operations.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,26 @@ public void testConcreteIndicesIgnoreIndicesEmptyRequest() {
equalTo(newHashSet("kuku", "testXXX")));
}

public void testConcreteIndicesNoIndicesErrorMessage() {
MetaData.Builder mdBuilder = MetaData.builder();
ClusterState state = ClusterState.builder(new ClusterName("_name")).metaData(mdBuilder).build();
IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state,
IndicesOptions.fromOptions(false, false, true, true));
IndexNotFoundException infe = expectThrows(IndexNotFoundException.class,
() -> indexNameExpressionResolver.concreteIndices(context, new String[]{}));
assertThat(infe.getMessage(), is("no such index [null] and no indices exist"));
}

public void testConcreteIndicesNoIndicesErrorMessageNoExpand() {
MetaData.Builder mdBuilder = MetaData.builder();
ClusterState state = ClusterState.builder(new ClusterName("_name")).metaData(mdBuilder).build();
IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state,
IndicesOptions.fromOptions(false, false, false, false));
IndexNotFoundException infe = expectThrows(IndexNotFoundException.class,
() -> indexNameExpressionResolver.concreteIndices(context, new String[]{}));
assertThat(infe.getMessage(), is("no such index [_all] and no indices exist"));
}

public void testConcreteIndicesWildcardExpansion() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("testXXX").state(State.OPEN))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.AckedClusterStateUpdateTask;
import org.elasticsearch.cluster.ClusterChangedEvent;
Expand Down Expand Up @@ -523,7 +522,7 @@ public void clusterStatePublished(ClusterChangedEvent clusterChangedEvent) {
final ClusterStateTaskListener listener = new ClusterStateTaskListener() {
@Override
public void onFailure(String source, Exception e) {
fail(ExceptionsHelper.detailedMessage(e));
throw new AssertionError(e);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.cluster.ClusterStateTaskConfig;
import org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException;
import org.elasticsearch.common.Priority;
Expand Down Expand Up @@ -273,7 +272,7 @@ public void processed(String source) {

@Override
public void onFailure(String source, Exception e) {
fail(ExceptionsHelper.detailedMessage(e));
throw new AssertionError(e);
}
});
usedKeys.add(key);
Expand Down Expand Up @@ -304,7 +303,7 @@ public void processed(String source) {

@Override
public void onFailure(String source, Exception e) {
fail(ExceptionsHelper.detailedMessage(e));
throw new AssertionError(e);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.elasticsearch.common.joda;

import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.common.time.DateMathParser;
import org.elasticsearch.test.ESTestCase;
Expand Down Expand Up @@ -278,7 +277,7 @@ void assertParseException(String msg, String date, String exc) {
parser.parse(date, () -> 0);
fail("Date: " + date + "\n" + msg);
} catch (ElasticsearchParseException e) {
assertThat(ExceptionsHelper.detailedMessage(e).contains(exc), equalTo(true));
assertThat(e.getMessage().contains(exc), equalTo(true));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.elasticsearch.common.time;

import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.test.ESTestCase;

import java.time.Instant;
Expand Down Expand Up @@ -251,7 +250,7 @@ public void testTimestamps() {

void assertParseException(String msg, String date, String exc) {
ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> parser.parse(date, () -> 0));
assertThat(msg, ExceptionsHelper.detailedMessage(e), containsString(exc));
assertThat(msg, e.getMessage(), containsString(exc));
}

public void testIllegalMathFormat() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.common.util.concurrent;

import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matcher;
Expand Down Expand Up @@ -276,7 +275,7 @@ public String toString() {
fail("Didn't get a rejection when we expected one.");
} catch (EsRejectedExecutionException e) {
assertFalse("Thread pool registering as terminated when it isn't", e.isExecutorShutdown());
String message = ExceptionsHelper.detailedMessage(e);
String message = e.getMessage();
assertThat(message, containsString("of dummy runnable"));
assertThat(message, containsString("on EsThreadPoolExecutor[name = " + getName()));
assertThat(message, containsString("queue capacity = " + queue));
Expand Down Expand Up @@ -316,7 +315,7 @@ public String toString() {
fail("Didn't get a rejection when we expected one.");
} catch (EsRejectedExecutionException e) {
assertTrue("Thread pool not registering as terminated when it is", e.isExecutorShutdown());
String message = ExceptionsHelper.detailedMessage(e);
String message = e.getMessage();
assertThat(message, containsString("of dummy runnable"));
assertThat(message, containsString("on EsThreadPoolExecutor[name = " + getName()));
assertThat(message, containsString("queue capacity = " + queue));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.index.mapper;

import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -51,6 +50,7 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;

// TODO: make this a real unit test
public class DocumentParserTests extends ESSingleNodeTestCase {
Expand Down Expand Up @@ -1443,7 +1443,8 @@ public void testBlankFieldNames() throws Exception {

MapperParsingException err = expectThrows(MapperParsingException.class, () ->
client().prepareIndex("idx", "type").setSource(bytes, XContentType.JSON).get());
assertThat(ExceptionsHelper.detailedMessage(err), containsString("field name cannot be an empty string"));
assertThat(err.getCause(), notNullValue());
assertThat(err.getCause().getMessage(), containsString("field name cannot be an empty string"));

final BytesReference bytes2 = BytesReference.bytes(XContentFactory.jsonBuilder()
.startObject()
Expand All @@ -1454,7 +1455,8 @@ public void testBlankFieldNames() throws Exception {

err = expectThrows(MapperParsingException.class, () ->
client().prepareIndex("idx", "type").setSource(bytes2, XContentType.JSON).get());
assertThat(ExceptionsHelper.detailedMessage(err), containsString("field name cannot be an empty string"));
assertThat(err.getCause(), notNullValue());
assertThat(err.getCause().getMessage(), containsString("field name cannot be an empty string"));
}

public void testWriteToFieldAlias() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.notNullValue;

public class IndexShardIT extends ESSingleNodeTestCase {

Expand Down Expand Up @@ -625,8 +626,9 @@ public void testCircuitBreakerIncrementedByIndexShard() throws Exception {
Exception e = expectThrows(Exception.class,
() -> client().prepareSearch("test")
.addAggregation(AggregationBuilders.terms("foo_terms").field("foo.keyword")).get());
logger.info("--> got: {}", ExceptionsHelper.detailedMessage(e));
assertThat(ExceptionsHelper.detailedMessage(e), containsString("[parent] Data too large, data for [<agg [foo_terms]>]"));
logger.info("--> got an expected exception", e);
assertThat(e.getCause(), notNullValue());
assertThat(e.getCause().getMessage(), containsString("[parent] Data too large, data for [<agg [foo_terms]>]"));

client().admin().cluster().prepareUpdateSettings()
.setTransientSettings(Settings.builder()
Expand Down
Loading