summaryrefslogtreecommitdiff
path: root/core/src/test
diff options
context:
space:
mode:
authorSimon Willnauer <simonw@apache.org>2015-07-03 15:40:09 +0200
committerSimon Willnauer <simonw@apache.org>2015-07-14 16:31:49 +0200
commit7db293c6167179bd470bb8a189223fcb67c0fae1 (patch)
tree5275a0b0cb4e49d7b31659cb254c34510283d27c /core/src/test
parentc6b110c6ef3004807f9257b68385c3d2e52635d5 (diff)
Generify Index and Shard exceptions
Today we have a intermediate hierarchy for shard and index exceptions which makes it hard to introduce generic exceptions like ResourceNotFoundException intoduced in this commit. This commit breaks up the hierarchy by adding index and shard as a special internal header that gets rendered for every exception that fills that header. This commit removes dedicated exceptions like `IndexMissingException` or `IndexShardMissingException` in favour of `ResourceNotFoundException`
Diffstat (limited to 'core/src/test')
-rw-r--r--core/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java33
-rw-r--r--core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java65
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/get/GetIndexTests.java5
-rw-r--r--core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/termvectors/AbstractTermVectorsTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/aliases/IndexAliasesTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/benchmark/recovery/ReplicaRecoveryBenchmark.java4
-rw-r--r--core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolverTests.java80
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/RoutingTableTest.java10
-rw-r--r--core/src/test/java/org/elasticsearch/index/store/CorruptedFileTest.java2
-rw-r--r--core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationTests.java10
-rw-r--r--core/src/test/java/org/elasticsearch/indices/exists/types/TypesExistsTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/indices/flush/SyncedFlushSingleNodeTest.java7
-rw-r--r--core/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexTests.java11
-rw-r--r--core/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/script/ScriptIndexSettingsTest.java4
-rw-r--r--core/src/test/java/org/elasticsearch/test/TestCluster.java4
-rw-r--r--core/src/test/java/org/elasticsearch/test/store/MockFSDirectoryService.java4
-rw-r--r--core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryTests.java4
21 files changed, 137 insertions, 139 deletions
diff --git a/core/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java b/core/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java
index 581868ff39..30b1d8c1da 100644
--- a/core/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java
+++ b/core/src/test/java/org/elasticsearch/ElasticsearchExceptionTests.java
@@ -34,10 +34,9 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentLocation;
import org.elasticsearch.index.Index;
-import org.elasticsearch.index.IndexException;
+import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.query.QueryParsingException;
import org.elasticsearch.index.query.TestQueryParsingException;
-import org.elasticsearch.indices.IndexMissingException;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.search.SearchParseException;
import org.elasticsearch.search.SearchShardTarget;
@@ -65,10 +64,10 @@ public class ElasticsearchExceptionTests extends ElasticsearchTestCase {
exception = new ElasticsearchException("test", new RuntimeException());
assertThat(exception.status(), equalTo(RestStatus.INTERNAL_SERVER_ERROR));
- exception = new ElasticsearchException("test", new IndexMissingException(new Index("test")));
+ exception = new ElasticsearchException("test", new ResourceNotFoundException("test"));
assertThat(exception.status(), equalTo(RestStatus.INTERNAL_SERVER_ERROR));
- exception = new RemoteTransportException("test", new IndexMissingException(new Index("test")));
+ exception = new RemoteTransportException("test", new ResourceNotFoundException("test"));
assertThat(exception.status(), equalTo(RestStatus.NOT_FOUND));
exception = new RemoteTransportException("test", new IllegalArgumentException("foobar"));
@@ -80,11 +79,11 @@ public class ElasticsearchExceptionTests extends ElasticsearchTestCase {
public void testGuessRootCause() {
{
- ElasticsearchException exception = new ElasticsearchException("foo", new ElasticsearchException("bar", new IndexException(new Index("foo"), "index is closed", new RuntimeException("foobar"))));
+ ElasticsearchException exception = new ElasticsearchException("foo", new ElasticsearchException("bar", new IndexNotFoundException("foo", new RuntimeException("foobar"))));
ElasticsearchException[] rootCauses = exception.guessRootCauses();
assertEquals(rootCauses.length, 1);
- assertEquals(ElasticsearchException.getExceptionName(rootCauses[0]), "index_exception");
- assertEquals(rootCauses[0].getMessage(), "index is closed");
+ assertEquals(ElasticsearchException.getExceptionName(rootCauses[0]), "index_not_found_exception");
+ assertEquals(rootCauses[0].getMessage(), "no such index");
ShardSearchFailure failure = new ShardSearchFailure(new TestQueryParsingException(new Index("foo"), "foobar", null),
new SearchShardTarget("node_1", "foo", 1));
ShardSearchFailure failure1 = new ShardSearchFailure(new TestQueryParsingException(new Index("foo"), "foobar", null),
@@ -116,7 +115,7 @@ public class ElasticsearchExceptionTests extends ElasticsearchTestCase {
assertEquals(rootCauses.length, 2);
assertEquals(ElasticsearchException.getExceptionName(rootCauses[0]), "test_query_parsing_exception");
assertEquals(rootCauses[0].getMessage(), "foobar");
- assertEquals(((QueryParsingException)rootCauses[0]).index().name(), "foo");
+ assertEquals(((QueryParsingException)rootCauses[0]).getIndex(), "foo");
assertEquals(ElasticsearchException.getExceptionName(rootCauses[1]), "test_query_parsing_exception");
assertEquals(rootCauses[1].getMessage(), "foobar");
assertEquals(((QueryParsingException) rootCauses[1]).getLineNumber(), 1);
@@ -222,7 +221,7 @@ public class ElasticsearchExceptionTests extends ElasticsearchTestCase {
builder.startObject();
ElasticsearchException.toXContent(builder, ToXContent.EMPTY_PARAMS, ex);
builder.endObject();
- String expected = "{\"type\":\"test_query_parsing_exception\",\"reason\":\"foobar\",\"line\":1,\"col\":2,\"index\":\"foo\"}";
+ String expected = "{\"type\":\"test_query_parsing_exception\",\"reason\":\"foobar\",\"index\":\"foo\",\"line\":1,\"col\":2}";
assertEquals(expected, builder.string());
}
@@ -241,6 +240,18 @@ public class ElasticsearchExceptionTests extends ElasticsearchTestCase {
assertEquals(otherBuilder.string(), builder.string());
assertEquals("{\"type\":\"file_not_found_exception\",\"reason\":\"foo not found\"}", builder.string());
}
+
+ { // render header
+ QueryParsingException ex = new TestQueryParsingException(new Index("foo"), 1, 2, "foobar", null);
+ ex.addHeader("test", "some value");
+ ex.addHeader("test_multi", "some value", "another value");
+ XContentBuilder builder = XContentFactory.jsonBuilder();
+ builder.startObject();
+ ElasticsearchException.toXContent(builder, ToXContent.EMPTY_PARAMS, ex);
+ builder.endObject();
+ String expected = "{\"type\":\"test_query_parsing_exception\",\"reason\":\"foobar\",\"index\":\"foo\",\"line\":1,\"col\":2,\"header\":{\"test_multi\":[\"some value\",\"another value\"],\"test\":\"some value\"}}";
+ assertEquals(expected, builder.string());
+ }
}
public void testSerializeElasticsearchException() throws IOException {
@@ -250,7 +261,7 @@ public class ElasticsearchExceptionTests extends ElasticsearchTestCase {
StreamInput in = StreamInput.wrap(out.bytes());
QueryParsingException e = in.readThrowable();
- assertEquals(ex.index(), e.index());
+ assertEquals(ex.getIndex(), e.getIndex());
assertEquals(ex.getMessage(), e.getMessage());
assertEquals(ex.getLineNumber(), e.getLineNumber());
assertEquals(ex.getColumnNumber(), e.getColumnNumber());
@@ -267,7 +278,7 @@ public class ElasticsearchExceptionTests extends ElasticsearchTestCase {
assertEquals("wtf", throwable.getMessage());
assertTrue(throwable instanceof ElasticsearchException);
QueryParsingException e = (QueryParsingException)throwable.getCause();
- assertEquals(queryParsingException.index(), e.index());
+ assertEquals(queryParsingException.getIndex(), e.getIndex());
assertEquals(queryParsingException.getMessage(), e.getMessage());
assertEquals(queryParsingException.getLineNumber(), e.getLineNumber());
assertEquals(queryParsingException.getColumnNumber(), e.getColumnNumber());
diff --git a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java
index f1040699e0..6381532c99 100644
--- a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java
+++ b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java
@@ -41,7 +41,6 @@ import org.elasticsearch.common.xcontent.*;
import org.elasticsearch.discovery.DiscoverySettings;
import org.elasticsearch.index.AlreadyExpiredException;
import org.elasticsearch.index.Index;
-import org.elasticsearch.index.IndexException;
import org.elasticsearch.index.engine.CreateFailedEngineException;
import org.elasticsearch.index.engine.IndexFailedEngineException;
import org.elasticsearch.index.engine.RecoveryEngineException;
@@ -55,7 +54,7 @@ import org.elasticsearch.indices.recovery.RecoverFilesRecoveryException;
import org.elasticsearch.percolator.PercolateException;
import org.elasticsearch.repositories.RepositoryException;
import org.elasticsearch.rest.RestStatus;
-import org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesMissingException;
+import org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException;
import org.elasticsearch.search.SearchContextMissingException;
import org.elasticsearch.search.SearchException;
import org.elasticsearch.search.SearchParseException;
@@ -209,13 +208,13 @@ public class ExceptionSerializationTests extends ElasticsearchTestCase {
public void testQueryParsingException() throws IOException {
QueryParsingException ex = serialize(new QueryParsingException(new Index("foo"), 1, 2, "fobar", null));
- assertEquals(ex.index(), new Index("foo"));
+ assertEquals(ex.getIndex(), "foo");
assertEquals(ex.getMessage(), "fobar");
assertEquals(ex.getLineNumber(),1);
assertEquals(ex.getColumnNumber(), 2);
ex = serialize(new QueryParsingException(null, 1, 2, null, null));
- assertNull(ex.index());
+ assertNull(ex.getIndex());
assertNull(ex.getMessage());
assertEquals(ex.getLineNumber(),1);
assertEquals(ex.getColumnNumber(), 2);
@@ -235,7 +234,7 @@ public class ExceptionSerializationTests extends ElasticsearchTestCase {
public void testAlreadyExpiredException() throws IOException {
AlreadyExpiredException alreadyExpiredException = serialize(new AlreadyExpiredException("index", "type", "id", 1, 2, 3));
- assertEquals("index", alreadyExpiredException.index());
+ assertEquals("index", alreadyExpiredException.getIndex());
assertEquals("type", alreadyExpiredException.type());
assertEquals("id", alreadyExpiredException.id());
assertEquals(2, alreadyExpiredException.ttl());
@@ -243,7 +242,7 @@ public class ExceptionSerializationTests extends ElasticsearchTestCase {
assertEquals(3, alreadyExpiredException.now());
alreadyExpiredException = serialize(new AlreadyExpiredException(null, null, null, -1, -2, -3));
- assertNull(alreadyExpiredException.index());
+ assertNull(alreadyExpiredException.getIndex());
assertNull(alreadyExpiredException.type());
assertNull(alreadyExpiredException.id());
assertEquals(-2, alreadyExpiredException.ttl());
@@ -253,13 +252,13 @@ public class ExceptionSerializationTests extends ElasticsearchTestCase {
public void testCreateFailedEngineException() throws IOException {
CreateFailedEngineException ex = serialize(new CreateFailedEngineException(new ShardId("idx", 2), "type", "id", null));
- assertEquals(ex.shardId(), new ShardId("idx", 2));
+ assertEquals(ex.getShardId(), new ShardId("idx", 2));
assertEquals("type", ex.type());
assertEquals("id", ex.id());
assertNull(ex.getCause());
ex = serialize(new CreateFailedEngineException(null, "type", "id", new NullPointerException()));
- assertNull(ex.shardId());
+ assertNull(ex.getShardId());
assertEquals("type", ex.type());
assertEquals("id", ex.id());
assertTrue(ex.getCause() instanceof NullPointerException);
@@ -292,14 +291,14 @@ public class ExceptionSerializationTests extends ElasticsearchTestCase {
ShardId id = new ShardId("foo", 1);
ByteSizeValue bytes = new ByteSizeValue(randomIntBetween(0, 10000));
RecoverFilesRecoveryException ex = serialize(new RecoverFilesRecoveryException(id, 10, bytes, null));
- assertEquals(ex.shardId(), id);
+ assertEquals(ex.getShardId(), id);
assertEquals(ex.numberOfFiles(), 10);
assertEquals(ex.totalFilesSize(), bytes);
assertEquals(ex.getMessage(), "Failed to transfer [10] files with total size of [" + bytes + "]");
assertNull(ex.getCause());
ex = serialize(new RecoverFilesRecoveryException(null, 10, bytes, new NullPointerException()));
- assertNull(ex.shardId());
+ assertNull(ex.getShardId());
assertEquals(ex.numberOfFiles(), 10);
assertEquals(ex.totalFilesSize(), bytes);
assertEquals(ex.getMessage(), "Failed to transfer [10] files with total size of [" + bytes + "]");
@@ -319,13 +318,13 @@ public class ExceptionSerializationTests extends ElasticsearchTestCase {
public void testBatchOperationException() throws IOException {
ShardId id = new ShardId("foo", 1);
TranslogRecoveryPerformer.BatchOperationException ex = serialize(new TranslogRecoveryPerformer.BatchOperationException(id, "batched the fucker", 666, null));
- assertEquals(ex.shardId(), id);
+ assertEquals(ex.getShardId(), id);
assertEquals(666, ex.completedOperations());
assertEquals("batched the fucker", ex.getMessage());
assertNull(ex.getCause());
ex = serialize(new TranslogRecoveryPerformer.BatchOperationException(null, "batched the fucker", -1, new NullPointerException()));
- assertNull(ex.shardId());
+ assertNull(ex.getShardId());
assertEquals(-1, ex.completedOperations());
assertEquals("batched the fucker", ex.getMessage());
assertTrue(ex.getCause() instanceof NullPointerException);
@@ -390,22 +389,23 @@ public class ExceptionSerializationTests extends ElasticsearchTestCase {
public void testIndexFailedEngineException() throws IOException {
ShardId id = new ShardId("foo", 1);
IndexFailedEngineException ex = serialize(new IndexFailedEngineException(id, "type", "id", null));
- assertEquals(ex.shardId(), new ShardId("foo", 1));
+ assertEquals(ex.getShardId(), new ShardId("foo", 1));
assertEquals("type", ex.type());
assertEquals("id", ex.id());
assertNull(ex.getCause());
ex = serialize(new IndexFailedEngineException(null, "type", "id", new NullPointerException()));
- assertNull(ex.shardId());
+ assertNull(ex.getShardId());
assertEquals("type", ex.type());
assertEquals("id", ex.id());
assertTrue(ex.getCause() instanceof NullPointerException);
}
public void testAliasesMissingException() throws IOException {
- AliasesMissingException ex = serialize(new AliasesMissingException("one", "two", "three"));
+ AliasesNotFoundException ex = serialize(new AliasesNotFoundException("one", "two", "three"));
assertEquals("aliases [one, two, three] missing", ex.getMessage());
- assertArrayEquals(new String[]{"one", "two", "three"}, ex.names());
+ assertEquals("aliases", ex.getResourceType());
+ assertArrayEquals(new String[]{"one", "two", "three"}, ex.getResourceId().toArray(new String[0]));
}
public void testSearchParseException() throws IOException {
@@ -421,7 +421,7 @@ public class ExceptionSerializationTests extends ElasticsearchTestCase {
ShardId id = new ShardId("foo", 1);
IndexShardState state = randomFrom(IndexShardState.values());
IllegalIndexShardStateException ex = serialize(new IllegalIndexShardStateException(id, state, "come back later buddy"));
- assertEquals(id, ex.shardId());
+ assertEquals(id, ex.getShardId());
assertEquals("CurrentState[" + state.name() + "] come back later buddy", ex.getMessage());
assertEquals(state, ex.currentState());
}
@@ -462,9 +462,9 @@ public class ExceptionSerializationTests extends ElasticsearchTestCase {
public void testRoutingMissingException() throws IOException {
RoutingMissingException ex = serialize(new RoutingMissingException("idx", "type", "id"));
- assertEquals("idx", ex.index());
- assertEquals("type", ex.type());
- assertEquals("id", ex.id());
+ assertEquals("idx", ex.getIndex());
+ assertEquals("type", ex.getType());
+ assertEquals("id", ex.getId());
assertEquals("routing is required for [idx]/[type]/[id]", ex.getMessage());
}
@@ -494,24 +494,15 @@ public class ExceptionSerializationTests extends ElasticsearchTestCase {
assertNull(ex.name());
}
- public void testIndexException() throws IOException {
- IndexException ex = serialize(new IndexException(new Index("foo"), "blub"));
- assertEquals("blub", ex.getMessage());
- assertEquals(new Index("foo"), ex.index());
-
- ex = serialize(new IndexException(null, "blub"));
- assertEquals("blub", ex.getMessage());
- assertNull(ex.index());
- }
public void testRecoveryEngineException() throws IOException {
ShardId id = new ShardId("foo", 1);
RecoveryEngineException ex = serialize(new RecoveryEngineException(id, 10, "total failure", new NullPointerException()));
- assertEquals(id, ex.shardId());
+ assertEquals(id, ex.getShardId());
assertEquals("Phase[10] total failure", ex.getMessage());
assertEquals(10, ex.phase());
ex = serialize(new RecoveryEngineException(null, -1, "total failure", new NullPointerException()));
- assertNull(ex.shardId());
+ assertNull(ex.getShardId());
assertEquals(-1, ex.phase());
assertTrue(ex.getCause() instanceof NullPointerException);
}
@@ -529,18 +520,6 @@ public class ExceptionSerializationTests extends ElasticsearchTestCase {
assertEquals(1, ex.blocks().size());
}
- public void testIndexShardException() throws IOException {
- ShardId id = new ShardId("foo", 1);
- IndexShardException ex = serialize(new IndexShardException(id, "boom", new NullPointerException()));
- assertEquals(id, ex.shardId());
- assertEquals("boom", ex.getMessage());
- assertEquals(new Index("foo"), ex.index());
- assertTrue(ex.getCause() instanceof NullPointerException);
- ex = serialize(new IndexShardException(null, "boom", new NullPointerException()));
- assertEquals("boom", ex.getMessage());
- assertNull(ex.index());
- assertNull(ex.shardId());
- }
private String toXContent(ToXContent x) {
try {
XContentBuilder builder = XContentFactory.jsonBuilder();
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/get/GetIndexTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/get/GetIndexTests.java
index d2e996d623..e8d24c774e 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/get/GetIndexTests.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/get/GetIndexTests.java
@@ -20,13 +20,14 @@
package org.elasticsearch.action.admin.indices.get;
import com.google.common.collect.ImmutableList;
+import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.action.admin.indices.get.GetIndexRequest.Feature;
import org.elasticsearch.cluster.metadata.AliasMetaData;
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.indices.IndexMissingException;
+import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.search.warmer.IndexWarmersMetaData.Entry;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.junit.Test;
@@ -68,7 +69,7 @@ public class GetIndexTests extends ElasticsearchIntegrationTest {
assertWarmers(response, "idx");
}
- @Test(expected=IndexMissingException.class)
+ @Test(expected=IndexNotFoundException.class)
public void testSimpleUnknownIndex() {
client().admin().indices().prepareGetIndex().addIndices("missing_idx").get();
}
diff --git a/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsTests.java b/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsTests.java
index 800a49453c..d450d2399c 100644
--- a/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsTests.java
+++ b/core/src/test/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsTests.java
@@ -47,7 +47,7 @@ public class BulkProcessorClusterSettingsTests extends ElasticsearchIntegrationT
assertEquals(3, responses.length);
assertFalse("Operation on existing index should succeed", responses[0].isFailed());
assertTrue("Missing index should have been flagged", responses[1].isFailed());
- assertEquals("[wontwork] no such index", responses[1].getFailureMessage());
+ assertEquals("[wontwork] IndexNotFoundException[no such index]", responses[1].getFailureMessage());
assertFalse("Operation on existing index should succeed", responses[2].isFailed());
}
}
diff --git a/core/src/test/java/org/elasticsearch/action/termvectors/AbstractTermVectorsTests.java b/core/src/test/java/org/elasticsearch/action/termvectors/AbstractTermVectorsTests.java
index 31d5af8d8b..06b21bbaab 100644
--- a/core/src/test/java/org/elasticsearch/action/termvectors/AbstractTermVectorsTests.java
+++ b/core/src/test/java/org/elasticsearch/action/termvectors/AbstractTermVectorsTests.java
@@ -40,7 +40,7 @@ import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.common.inject.internal.Join;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.indices.IndexMissingException;
+import org.elasticsearch.index.*;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import java.io.IOException;
@@ -262,7 +262,7 @@ public abstract class AbstractTermVectorsTests extends ElasticsearchIntegrationT
}
// always adds a test that fails
configs.add(new TestConfig(new TestDoc("doesnt_exist", new TestFieldSetting[]{}, new String[]{}).index("doesn't_exist").alias("doesn't_exist"),
- new String[]{"doesnt_exist"}, true, true, true).expectedException(IndexMissingException.class));
+ new String[]{"doesnt_exist"}, true, true, true).expectedException(org.elasticsearch.index.IndexNotFoundException.class));
refresh();
diff --git a/core/src/test/java/org/elasticsearch/aliases/IndexAliasesTests.java b/core/src/test/java/org/elasticsearch/aliases/IndexAliasesTests.java
index dd8d66469b..e4c873dd6f 100644
--- a/core/src/test/java/org/elasticsearch/aliases/IndexAliasesTests.java
+++ b/core/src/test/java/org/elasticsearch/aliases/IndexAliasesTests.java
@@ -38,7 +38,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesMissingException;
+import org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.aggregations.AggregationBuilders;
@@ -529,7 +529,7 @@ public class IndexAliasesTests extends ElasticsearchIntegrationTest {
}
- @Test(expected = AliasesMissingException.class)
+ @Test(expected = AliasesNotFoundException.class)
public void testIndicesRemoveNonExistingAliasResponds404() throws Exception {
logger.info("--> creating index [test]");
createIndex("test");
diff --git a/core/src/test/java/org/elasticsearch/benchmark/recovery/ReplicaRecoveryBenchmark.java b/core/src/test/java/org/elasticsearch/benchmark/recovery/ReplicaRecoveryBenchmark.java
index 0d3375d1c6..9648947af6 100644
--- a/core/src/test/java/org/elasticsearch/benchmark/recovery/ReplicaRecoveryBenchmark.java
+++ b/core/src/test/java/org/elasticsearch/benchmark/recovery/ReplicaRecoveryBenchmark.java
@@ -29,7 +29,7 @@ import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.SizeValue;
import org.elasticsearch.common.unit.TimeValue;
-import org.elasticsearch.indices.IndexMissingException;
+import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.BackgroundIndexer;
import org.elasticsearch.transport.TransportModule;
@@ -81,7 +81,7 @@ public class ReplicaRecoveryBenchmark {
indexer.setMaxFieldSize(150);
try {
client1.admin().indices().prepareDelete(INDEX_NAME).get();
- } catch (IndexMissingException e) {
+ } catch (IndexNotFoundException e) {
}
client1.admin().indices().prepareCreate(INDEX_NAME).get();
indexer.start(DOC_COUNT / 2);
diff --git a/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java b/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java
index 7dd1839c61..76d44642e4 100644
--- a/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java
+++ b/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java
@@ -24,6 +24,7 @@ import com.google.common.util.concurrent.ListenableFuture;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
+import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.Version;
import org.elasticsearch.action.admin.indices.get.GetIndexResponse;
import org.elasticsearch.action.get.GetResponse;
@@ -38,7 +39,6 @@ import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.MultiDataPathUpgrader;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.env.NodeEnvironment;
-import org.elasticsearch.index.IndexException;
import org.elasticsearch.index.engine.EngineConfig;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.shard.MergePolicyConfig;
@@ -304,8 +304,8 @@ public class OldIndexBackwardsCompatibilityTests extends ElasticsearchIntegratio
try {
client().admin().indices().prepareOpen(indexName).get();
fail("Shouldn't be able to open an old index");
- } catch (IndexException ex) {
- assertThat(ex.getMessage(), containsString("cannot open the index due to upgrade failure"));
+ } catch (IllegalStateException ex) {
+ assertThat(ex.getMessage(), containsString("was created before v0.90.0 and wasn't upgraded"));
}
unloadIndex(indexName);
logger.info("--> Done testing " + index + ", took " + ((System.currentTimeMillis() - startTime) / 1000.0) + " seconds");
diff --git a/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateTests.java b/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateTests.java
index c102251862..d3b26ac630 100644
--- a/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/SimpleClusterStateTests.java
@@ -30,7 +30,7 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
-import org.elasticsearch.indices.IndexMissingException;
+import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.hamcrest.CollectionAssertions;
import org.junit.Before;
@@ -195,14 +195,14 @@ public class SimpleClusterStateTests extends ElasticsearchIntegrationTest {
assertThat(clusterStateResponse.getState().metaData().indices().isEmpty(), is(true));
}
- @Test(expected=IndexMissingException.class)
+ @Test(expected=IndexNotFoundException.class)
public void testIndicesOptionsOnAllowNoIndicesFalse() throws Exception {
// empty wildcard expansion throws exception when allowNoIndices is turned off
IndicesOptions allowNoIndices = IndicesOptions.fromOptions(false, false, true, false);
client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("a*").setIndicesOptions(allowNoIndices).get();
}
- @Test(expected=IndexMissingException.class)
+ @Test(expected=IndexNotFoundException.class)
public void testIndicesIgnoreUnavailableFalse() throws Exception {
// ignore_unavailable set to false throws exception when allowNoIndices is turned off
IndicesOptions allowNoIndices = IndicesOptions.fromOptions(false, true, true, false);
diff --git a/core/src/test/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolverTests.java b/core/src/test/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolverTests.java
index 6f6b6685d7..9ffaaa6c33 100644
--- a/core/src/test/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolverTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolverTests.java
@@ -26,8 +26,8 @@ import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData.State;
import org.elasticsearch.common.Strings;
+import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.indices.IndexClosedException;
-import org.elasticsearch.indices.IndexMissingException;
import org.elasticsearch.test.ElasticsearchTestCase;
import org.junit.Test;
@@ -63,8 +63,8 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
try {
indexNameExpressionResolver.concreteIndices(context, "bar");
fail();
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("bar"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getIndex(), equalTo("bar"));
}
results = indexNameExpressionResolver.concreteIndices(context, "foofoo", "foobar");
@@ -78,15 +78,15 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
try {
indexNameExpressionResolver.concreteIndices(context, "bar");
fail();
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("bar"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getIndex(), equalTo("bar"));
}
try {
indexNameExpressionResolver.concreteIndices(context, "foo", "bar");
fail();
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("bar"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getIndex(), equalTo("bar"));
}
results = indexNameExpressionResolver.concreteIndices(context, "barbaz", "foobar");
@@ -96,8 +96,8 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
try {
indexNameExpressionResolver.concreteIndices(context, "barbaz", "bar");
fail();
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("bar"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getIndex(), equalTo("bar"));
}
results = indexNameExpressionResolver.concreteIndices(context, "baz*");
@@ -225,22 +225,22 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
try {
indexNameExpressionResolver.concreteIndices(context, "bar");
fail();
- } catch(IndexMissingException e) {
- assertThat(e.index().name(), equalTo("bar"));
+ } catch(IndexNotFoundException e) {
+ assertThat(e.getIndex(), equalTo("bar"));
}
try {
indexNameExpressionResolver.concreteIndices(context, "baz*");
fail();
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("baz*"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getIndex(), equalTo("baz*"));
}
try {
indexNameExpressionResolver.concreteIndices(context, "foo", "baz*");
fail();
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("baz*"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getIndex(), equalTo("baz*"));
}
}
@@ -320,8 +320,8 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
try {
indexNameExpressionResolver.concreteIndices(context, "-*");
fail();
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("-*"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getResourceId().toString(), equalTo("[-*]"));
}
}
@@ -364,8 +364,8 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
try {
indexNameExpressionResolver.concreteIndices(context, "baz*");
fail();
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("baz*"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getIndex(), equalTo("baz*"));
}
String[] results = indexNameExpressionResolver.concreteIndices(context, "foo", "baz*");
@@ -387,8 +387,8 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
try {
indexNameExpressionResolver.concreteIndices(context, "foo", "baz*");
fail();
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("baz*"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getIndex(), equalTo("baz*"));
}
results = indexNameExpressionResolver.concreteIndices(context, "foofoobar");
@@ -403,15 +403,15 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
try {
indexNameExpressionResolver.concreteIndices(context, "baz*");
fail();
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("baz*"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getIndex(), equalTo("baz*"));
}
try {
indexNameExpressionResolver.concreteIndices(context, "foo", "baz*");
fail();
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("baz*"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getIndex(), equalTo("baz*"));
}
String[] results = indexNameExpressionResolver.concreteIndices(context, "foofoobar");
@@ -436,16 +436,16 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, IndicesOptions.strictSingleIndexNoExpandForbidClosed());
indexNameExpressionResolver.concreteIndices(context, "baz*");
fail();
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("baz*"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getIndex(), equalTo("baz*"));
}
try {
IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, IndicesOptions.strictSingleIndexNoExpandForbidClosed());
indexNameExpressionResolver.concreteIndices(context, "foo", "baz*");
fail();
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("baz*"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getIndex(), equalTo("baz*"));
}
try {
@@ -470,7 +470,7 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
fail();
} catch(IndexClosedException e) {
assertThat(e.getMessage(), equalTo("closed"));
- assertEquals(e.index().getName(), "foofoo-closed");
+ assertEquals(e.getIndex(), "foofoo-closed");
}
IndexNameExpressionResolver.Context context = new IndexNameExpressionResolver.Context(state, IndicesOptions.strictSingleIndexNoExpandForbidClosed());
@@ -491,16 +491,16 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
try {
indexNameExpressionResolver.concreteIndices(context, "foo");
fail();
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("foo"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getIndex(), equalTo("foo"));
}
results = indexNameExpressionResolver.concreteIndices(context, "foo*");
assertThat(results, emptyArray());
try {
indexNameExpressionResolver.concreteIndices(context, "foo*", "bar");
fail();
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("bar"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getIndex(), equalTo("bar"));
}
@@ -517,8 +517,8 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
context = new IndexNameExpressionResolver.Context(state, IndicesOptions.fromOptions(true, false, true, false));
try {
indexNameExpressionResolver.concreteIndices(context, Strings.EMPTY_ARRAY);
- } catch (IndexMissingException e) {
- assertThat(e.index().name(), equalTo("[_all]"));
+ } catch (IndexNotFoundException e) {
+ assertThat(e.getResourceId().toString(), equalTo("[_all]"));
}
}
@@ -526,7 +526,7 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
return IndexMetaData.builder(index).settings(settings(Version.CURRENT).put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0));
}
- @Test(expected = IndexMissingException.class)
+ @Test(expected = IndexNotFoundException.class)
public void testConcreteIndicesIgnoreIndicesOneMissingIndex() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("testXXX"))
@@ -550,7 +550,7 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
assertThat(newHashSet(indexNameExpressionResolver.concreteIndices(context, "testXXX", "testZZZ")), equalTo(newHashSet("testXXX")));
}
- @Test(expected = IndexMissingException.class)
+ @Test(expected = IndexNotFoundException.class)
public void testConcreteIndicesIgnoreIndicesAllMissing() {
MetaData.Builder mdBuilder = MetaData.builder()
.put(indexBuilder("testXXX"))
@@ -659,7 +659,7 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
try {
indexNameExpressionResolver.concreteIndices(context, allIndices);
fail("wildcard expansion on should trigger IndexMissingException");
- } catch (IndexMissingException e) {
+ } catch (IndexNotFoundException e) {
// expected
}
}
@@ -688,7 +688,7 @@ public class IndexNameExpressionResolverTests extends ElasticsearchTestCase {
try {
indexNameExpressionResolver.concreteIndices(context, "Foo*");
fail("expecting exeption when result empty and allowNoIndicec=false");
- } catch (IndexMissingException e) {
+ } catch (IndexNotFoundException e) {
// expected exception
}
}
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/RoutingTableTest.java b/core/src/test/java/org/elasticsearch/cluster/routing/RoutingTableTest.java
index 23fad2de2e..28e93ad693 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/RoutingTableTest.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/RoutingTableTest.java
@@ -28,7 +28,7 @@ import org.elasticsearch.cluster.node.DiscoveryNodes.Builder;
import org.elasticsearch.cluster.routing.allocation.AllocationService;
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.indices.IndexMissingException;
+import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.test.ElasticsearchAllocationTestCase;
import org.junit.Before;
import org.junit.Test;
@@ -116,7 +116,7 @@ public class RoutingTableTest extends ElasticsearchAllocationTestCase {
try {
assertThat(this.testRoutingTable.allShards("not_existing").size(), is(0));
fail("Exception expected when calling allShards() with non existing index name");
- } catch (IndexMissingException e) {
+ } catch (IndexNotFoundException e) {
// expected
}
}
@@ -191,7 +191,7 @@ public class RoutingTableTest extends ElasticsearchAllocationTestCase {
try {
this.testRoutingTable.activePrimaryShardsGrouped(new String[]{TEST_INDEX_1, "not_exists"}, true);
fail("Calling with non-existing index name should raise IndexMissingException");
- } catch (IndexMissingException e) {
+ } catch (IndexNotFoundException e) {
// expected
}
}
@@ -220,7 +220,7 @@ public class RoutingTableTest extends ElasticsearchAllocationTestCase {
try {
this.testRoutingTable.allActiveShardsGrouped(new String[]{TEST_INDEX_1, "not_exists"}, true);
- } catch (IndexMissingException e) {
+ } catch (IndexNotFoundException e) {
fail("Calling with non-existing index should be ignored at the moment");
}
}
@@ -239,7 +239,7 @@ public class RoutingTableTest extends ElasticsearchAllocationTestCase {
try {
this.testRoutingTable.allAssignedShardsGrouped(new String[]{TEST_INDEX_1, "not_exists"}, false);
- } catch (IndexMissingException e) {
+ } catch (IndexNotFoundException e) {
fail("Calling with non-existing index should be ignored at the moment");
}
}
diff --git a/core/src/test/java/org/elasticsearch/index/store/CorruptedFileTest.java b/core/src/test/java/org/elasticsearch/index/store/CorruptedFileTest.java
index baa1f087cb..0e6a9559d7 100644
--- a/core/src/test/java/org/elasticsearch/index/store/CorruptedFileTest.java
+++ b/core/src/test/java/org/elasticsearch/index/store/CorruptedFileTest.java
@@ -191,7 +191,7 @@ public class CorruptedFileTest extends ElasticsearchIntegrationTest {
CheckIndex.Status status = checkIndex.checkIndex();
if (!status.clean) {
logger.warn("check index [failure]\n{}", new String(os.bytes().toBytes(), Charsets.UTF_8));
- throw new IndexShardException(sid, "index check failure");
+ throw new IOException("index check failure");
}
}
} catch (Throwable t) {
diff --git a/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationTests.java b/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationTests.java
index baec5760b7..ff0110b39f 100644
--- a/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationTests.java
+++ b/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationTests.java
@@ -18,6 +18,7 @@
*/
package org.elasticsearch.indices;
+import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.ActionRequestBuilder;
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse;
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequestBuilder;
@@ -50,6 +51,7 @@ import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.suggest.SuggestBuilders;
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
@@ -525,7 +527,7 @@ public class IndicesOptionsIntegrationTests extends ElasticsearchIntegrationTest
.setQuery(matchAllQuery())
.execute().actionGet();
fail("Exception should have been thrown.");
- } catch (IndexMissingException e) {
+ } catch (IndexNotFoundException e) {
}
try {
@@ -533,7 +535,7 @@ public class IndicesOptionsIntegrationTests extends ElasticsearchIntegrationTest
.setQuery(matchAllQuery())
.execute().actionGet();
fail("Exception should have been thrown.");
- } catch (IndexMissingException e) {
+ } catch (IndexNotFoundException e) {
}
//you should still be able to run empty searches without things blowing up
@@ -892,8 +894,8 @@ public class IndicesOptionsIntegrationTests extends ElasticsearchIntegrationTest
} else {
try {
requestBuilder.get();
- fail("IndexMissingException or IndexClosedException was expected");
- } catch (IndexMissingException | IndexClosedException e) {}
+ fail("IndexNotFoundException or IndexClosedException was expected");
+ } catch (IndexNotFoundException | IndexClosedException e) {}
}
} else {
if (requestBuilder instanceof SearchRequestBuilder) {
diff --git a/core/src/test/java/org/elasticsearch/indices/exists/types/TypesExistsTests.java b/core/src/test/java/org/elasticsearch/indices/exists/types/TypesExistsTests.java
index f72609298e..0191c56831 100644
--- a/core/src/test/java/org/elasticsearch/indices/exists/types/TypesExistsTests.java
+++ b/core/src/test/java/org/elasticsearch/indices/exists/types/TypesExistsTests.java
@@ -18,11 +18,12 @@
*/
package org.elasticsearch.indices.exists.types;
+import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.metadata.IndexMetaData;
-import org.elasticsearch.indices.IndexMissingException;
+import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.junit.Test;
@@ -61,11 +62,11 @@ public class TypesExistsTests extends ElasticsearchIntegrationTest {
try {
client.admin().indices().prepareTypesExists("notExist").setTypes("type1").execute().actionGet();
fail("Exception should have been thrown");
- } catch (IndexMissingException e) {}
+ } catch (IndexNotFoundException e) {}
try {
client.admin().indices().prepareTypesExists("notExist").setTypes("type0").execute().actionGet();
fail("Exception should have been thrown");
- } catch (IndexMissingException e) {}
+ } catch (IndexNotFoundException e) {}
response = client.admin().indices().prepareTypesExists("alias1").setTypes("type1").execute().actionGet();
assertThat(response.isExists(), equalTo(true));
response = client.admin().indices().prepareTypesExists("*").setTypes("type1").execute().actionGet();
diff --git a/core/src/test/java/org/elasticsearch/indices/flush/SyncedFlushSingleNodeTest.java b/core/src/test/java/org/elasticsearch/indices/flush/SyncedFlushSingleNodeTest.java
index 5d65c1acb7..8cd791b5c0 100644
--- a/core/src/test/java/org/elasticsearch/indices/flush/SyncedFlushSingleNodeTest.java
+++ b/core/src/test/java/org/elasticsearch/indices/flush/SyncedFlushSingleNodeTest.java
@@ -23,10 +23,12 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.Strings;
+import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.shard.ShardId;
+import org.elasticsearch.index.shard.ShardNotFoundException;
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.test.ElasticsearchSingleNodeTest;
@@ -136,7 +138,8 @@ public class SyncedFlushSingleNodeTest extends ElasticsearchSingleNodeTest {
listener.latch.await();
assertNotNull(listener.error);
assertNull(listener.result);
- assertEquals("missing", listener.error.getMessage());
+ assertEquals(ShardNotFoundException.class, listener.error.getClass());
+ assertEquals("no such shard", listener.error.getMessage());
final ShardId shardId = shard.shardId();
@@ -149,7 +152,7 @@ public class SyncedFlushSingleNodeTest extends ElasticsearchSingleNodeTest {
assertEquals("closed", listener.error.getMessage());
listener = new SyncedFlushUtil.LatchedListener();
- flushService.attemptSyncedFlush(new ShardId("nosuchindex", 0), listener);
+ flushService.attemptSyncedFlush(new ShardId("index not found", 0), listener);
listener.latch.await();
assertNotNull(listener.error);
assertNull(listener.result);
diff --git a/core/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexTests.java b/core/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexTests.java
index 4ba9722775..d1b461ef20 100644
--- a/core/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexTests.java
+++ b/core/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexTests.java
@@ -19,6 +19,7 @@
package org.elasticsearch.indices.state;
+import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
@@ -31,8 +32,8 @@ import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.indices.IndexMissingException;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.junit.Test;
@@ -63,19 +64,19 @@ public class OpenCloseIndexTests extends ElasticsearchIntegrationTest {
assertIndexIsOpened("test1");
}
- @Test(expected = IndexMissingException.class)
+ @Test(expected = IndexNotFoundException.class)
public void testSimpleCloseMissingIndex() {
Client client = client();
client.admin().indices().prepareClose("test1").execute().actionGet();
}
- @Test(expected = IndexMissingException.class)
+ @Test(expected = IndexNotFoundException.class)
public void testSimpleOpenMissingIndex() {
Client client = client();
client.admin().indices().prepareOpen("test1").execute().actionGet();
}
- @Test(expected = IndexMissingException.class)
+ @Test(expected = IndexNotFoundException.class)
public void testCloseOneMissingIndex() {
Client client = client();
createIndex("test1");
@@ -96,7 +97,7 @@ public class OpenCloseIndexTests extends ElasticsearchIntegrationTest {
assertIndexIsClosed("test1");
}
- @Test(expected = IndexMissingException.class)
+ @Test(expected = IndexNotFoundException.class)
public void testOpenOneMissingIndex() {
Client client = client();
createIndex("test1");
diff --git a/core/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateTests.java b/core/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateTests.java
index 9c1a78f2f0..0d162b7c52 100644
--- a/core/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateTests.java
+++ b/core/src/test/java/org/elasticsearch/indices/state/SimpleIndexStateTests.java
@@ -31,8 +31,8 @@ import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsException;
+import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.indices.IndexClosedException;
-import org.elasticsearch.indices.IndexMissingException;
import org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.junit.Test;
@@ -141,7 +141,7 @@ public class SimpleIndexStateTests extends ElasticsearchIntegrationTest {
logger.info("--> deleting test index....");
try {
client().admin().indices().prepareDelete("test").get();
- } catch (IndexMissingException ex) {
+ } catch (IndexNotFoundException ex) {
// Ignore
}
diff --git a/core/src/test/java/org/elasticsearch/script/ScriptIndexSettingsTest.java b/core/src/test/java/org/elasticsearch/script/ScriptIndexSettingsTest.java
index db8770a220..1a57c5155e 100644
--- a/core/src/test/java/org/elasticsearch/script/ScriptIndexSettingsTest.java
+++ b/core/src/test/java/org/elasticsearch/script/ScriptIndexSettingsTest.java
@@ -26,7 +26,7 @@ import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
import org.elasticsearch.action.indexedscripts.get.GetIndexedScriptResponse;
import org.elasticsearch.action.indexedscripts.put.PutIndexedScriptResponse;
import org.elasticsearch.action.support.IndicesOptions;
-import org.elasticsearch.indices.IndexMissingException;
+import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.junit.Test;
@@ -79,7 +79,7 @@ public class ScriptIndexSettingsTest extends ElasticsearchIntegrationTest{
try {
GetIndexedScriptResponse response = client().prepareGetIndexedScript("groovy","foobar").get();
assertTrue(false); //This should not happen
- } catch (IndexMissingException ime) {
+ } catch (IndexNotFoundException ime) {
assertTrue(true);
}
}
diff --git a/core/src/test/java/org/elasticsearch/test/TestCluster.java b/core/src/test/java/org/elasticsearch/test/TestCluster.java
index a1f5f016a8..322ed74197 100644
--- a/core/src/test/java/org/elasticsearch/test/TestCluster.java
+++ b/core/src/test/java/org/elasticsearch/test/TestCluster.java
@@ -25,7 +25,7 @@ import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
-import org.elasticsearch.indices.IndexMissingException;
+import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.indices.IndexTemplateMissingException;
import org.elasticsearch.repositories.RepositoryMissingException;
@@ -135,7 +135,7 @@ public abstract class TestCluster implements Iterable<Client>, Closeable {
if (size() > 0) {
try {
assertAcked(client().admin().indices().prepareDelete(indices));
- } catch (IndexMissingException e) {
+ } catch (IndexNotFoundException e) {
// ignore
} catch (IllegalArgumentException e) {
// Happens if `action.destructive_requires_name` is set to true
diff --git a/core/src/test/java/org/elasticsearch/test/store/MockFSDirectoryService.java b/core/src/test/java/org/elasticsearch/test/store/MockFSDirectoryService.java
index 036d98cc18..5be741b9dc 100644
--- a/core/src/test/java/org/elasticsearch/test/store/MockFSDirectoryService.java
+++ b/core/src/test/java/org/elasticsearch/test/store/MockFSDirectoryService.java
@@ -136,7 +136,7 @@ public class MockFSDirectoryService extends FsDirectoryService {
throw new UnsupportedOperationException();
}
- public void checkIndex(Store store, ShardId shardId) throws IndexShardException {
+ public void checkIndex(Store store, ShardId shardId) {
if (store.tryIncRef()) {
logger.info("start check index");
try {
@@ -159,7 +159,7 @@ public class MockFSDirectoryService extends FsDirectoryService {
logger.warn("check index [failure] index files={}\n{}",
Arrays.toString(dir.listAll()),
new String(os.bytes().toBytes(), Charsets.UTF_8));
- throw new IndexShardException(shardId, "index check failure");
+ throw new IOException("index check failure");
} else {
if (logger.isDebugEnabled()) {
logger.debug("check index [success]\n{}", new String(os.bytes().toBytes(), Charsets.UTF_8));
diff --git a/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryTests.java b/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryTests.java
index 5f40da8171..0026957fe7 100644
--- a/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryTests.java
+++ b/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryTests.java
@@ -27,9 +27,9 @@ import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.indices.IndexMissingException;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
import org.elasticsearch.test.ElasticsearchIntegrationTest.Scope;
@@ -145,7 +145,7 @@ public class SimpleValidateQueryTests extends ElasticsearchIntegrationTest {
assertThat(response.isValid(), equalTo(true));
}
- @Test(expected = IndexMissingException.class)
+ @Test(expected = IndexNotFoundException.class)
public void validateEmptyCluster() {
client().admin().indices().prepareValidateQuery().get();
}