Bring back ExecutionException after backport

This commit is contained in:
Simon Willnauer 2019-06-05 12:10:02 +02:00
parent d3524fdd06
commit ebec118ccf
1 changed files with 13 additions and 12 deletions

View File

@ -46,6 +46,7 @@ import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@ -63,7 +64,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
return pluginList(XPackPlugin.class); return pluginList(XPackPlugin.class);
} }
public void testCloseFreezeAndOpen() { public void testCloseFreezeAndOpen() throws ExecutionException, InterruptedException {
createIndex("index", Settings.builder().put("index.number_of_shards", 2).build()); createIndex("index", Settings.builder().put("index.number_of_shards", 2).build());
client().prepareIndex("index", "_doc", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); client().prepareIndex("index", "_doc", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("index", "_doc", "2").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); client().prepareIndex("index", "_doc", "2").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
@ -105,7 +106,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
} while (searchResponse.getHits().getHits().length > 0); } while (searchResponse.getHits().getHits().length > 0);
} }
public void testSearchAndGetAPIsAreThrottled() throws InterruptedException, IOException { public void testSearchAndGetAPIsAreThrottled() throws InterruptedException, IOException, ExecutionException {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("_doc") XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("_doc")
.startObject("properties").startObject("field").field("type", "text").field("term_vector", "with_positions_offsets_payloads") .startObject("properties").startObject("field").field("type", "text").field("term_vector", "with_positions_offsets_payloads")
.endObject().endObject() .endObject().endObject()
@ -149,7 +150,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
assertEquals(numRefreshes, index.getTotal().refresh.getTotal()); assertEquals(numRefreshes, index.getTotal().refresh.getTotal());
} }
public void testFreezeAndUnfreeze() { public void testFreezeAndUnfreeze() throws ExecutionException, InterruptedException {
createIndex("index", Settings.builder().put("index.number_of_shards", 2).build()); createIndex("index", Settings.builder().put("index.number_of_shards", 2).build());
client().prepareIndex("index", "_doc", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); client().prepareIndex("index", "_doc", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
client().prepareIndex("index", "_doc", "2").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); client().prepareIndex("index", "_doc", "2").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
@ -189,7 +190,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
assertTrue(FrozenEngine.INDEX_FROZEN.get(indexService.getIndexSettings().getSettings())); assertTrue(FrozenEngine.INDEX_FROZEN.get(indexService.getIndexSettings().getSettings()));
} }
public void testDoubleFreeze() { public void testDoubleFreeze() throws ExecutionException, InterruptedException {
createIndex("test-idx", Settings.builder().put("index.number_of_shards", 2).build()); createIndex("test-idx", Settings.builder().put("index.number_of_shards", 2).build());
XPackClient xPackClient = new XPackClient(client()); XPackClient xPackClient = new XPackClient(client());
assertAcked(xPackClient.freeze(new TransportFreezeIndexAction.FreezeRequest("test-idx"))); assertAcked(xPackClient.freeze(new TransportFreezeIndexAction.FreezeRequest("test-idx")));
@ -200,7 +201,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
assertEquals("no index found to freeze", executionException.getCause().getMessage()); assertEquals("no index found to freeze", executionException.getCause().getMessage());
} }
public void testUnfreezeClosedIndices() { public void testUnfreezeClosedIndices() throws ExecutionException, InterruptedException {
createIndex("idx", Settings.builder().put("index.number_of_shards", 1).build()); createIndex("idx", Settings.builder().put("index.number_of_shards", 1).build());
client().prepareIndex("idx", "_doc", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); client().prepareIndex("idx", "_doc", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
createIndex("idx-closed", Settings.builder().put("index.number_of_shards", 1).build()); createIndex("idx-closed", Settings.builder().put("index.number_of_shards", 1).build());
@ -216,7 +217,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
assertHitCount(client().prepareSearch().get(), 1L); assertHitCount(client().prepareSearch().get(), 1L);
} }
public void testFreezePattern() { public void testFreezePattern() throws ExecutionException, InterruptedException {
createIndex("test-idx", Settings.builder().put("index.number_of_shards", 1).build()); createIndex("test-idx", Settings.builder().put("index.number_of_shards", 1).build());
client().prepareIndex("test-idx", "_doc", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); client().prepareIndex("test-idx", "_doc", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
createIndex("test-idx-1", Settings.builder().put("index.number_of_shards", 1).build()); createIndex("test-idx-1", Settings.builder().put("index.number_of_shards", 1).build());
@ -240,7 +241,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
assertEquals(0, index.getTotal().refresh.getTotal()); assertEquals(0, index.getTotal().refresh.getTotal());
} }
public void testCanMatch() throws IOException { public void testCanMatch() throws IOException, ExecutionException, InterruptedException {
createIndex("index"); createIndex("index");
client().prepareIndex("index", "_doc", "1").setSource("field", "2010-01-05T02:00").setRefreshPolicy(IMMEDIATE).execute() client().prepareIndex("index", "_doc", "1").setSource("field", "2010-01-05T02:00").setRefreshPolicy(IMMEDIATE).execute()
.actionGet(); .actionGet();
@ -297,7 +298,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
} }
} }
public void testWriteToFrozenIndex() { public void testWriteToFrozenIndex() throws ExecutionException, InterruptedException {
createIndex("idx", Settings.builder().put("index.number_of_shards", 1).build()); createIndex("idx", Settings.builder().put("index.number_of_shards", 1).build());
client().prepareIndex("idx", "_doc", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); client().prepareIndex("idx", "_doc", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
XPackClient xPackClient = new XPackClient(client()); XPackClient xPackClient = new XPackClient(client());
@ -307,7 +308,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
client().prepareIndex("idx", "_doc", "2").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get()); client().prepareIndex("idx", "_doc", "2").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get());
} }
public void testIgnoreUnavailable() { public void testIgnoreUnavailable() throws ExecutionException, InterruptedException {
createIndex("idx", Settings.builder().put("index.number_of_shards", 1).build()); createIndex("idx", Settings.builder().put("index.number_of_shards", 1).build());
createIndex("idx-close", Settings.builder().put("index.number_of_shards", 1).build()); createIndex("idx-close", Settings.builder().put("index.number_of_shards", 1).build());
assertAcked(client().admin().indices().prepareClose("idx-close")); assertAcked(client().admin().indices().prepareClose("idx-close"));
@ -319,7 +320,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
client().admin().cluster().prepareState().get().getState().metaData().index("idx-close").getState()); client().admin().cluster().prepareState().get().getState().metaData().index("idx-close").getState());
} }
public void testUnfreezeClosedIndex() { public void testUnfreezeClosedIndex() throws ExecutionException, InterruptedException {
createIndex("idx", Settings.builder().put("index.number_of_shards", 1).build()); createIndex("idx", Settings.builder().put("index.number_of_shards", 1).build());
XPackClient xPackClient = new XPackClient(client()); XPackClient xPackClient = new XPackClient(client());
assertAcked(xPackClient.freeze(new TransportFreezeIndexAction.FreezeRequest("idx"))); assertAcked(xPackClient.freeze(new TransportFreezeIndexAction.FreezeRequest("idx")));
@ -336,7 +337,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
client().admin().cluster().prepareState().get().getState().metaData().index("idx").getState()); client().admin().cluster().prepareState().get().getState().metaData().index("idx").getState());
} }
public void testFreezeIndexIncreasesIndexSettingsVersion() { public void testFreezeIndexIncreasesIndexSettingsVersion() throws ExecutionException, InterruptedException {
final String index = "test"; final String index = "test";
createIndex(index, Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0).build()); createIndex(index, Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0).build());
client().prepareIndex(index, "_doc").setSource("field", "value").execute().actionGet(); client().prepareIndex(index, "_doc").setSource("field", "value").execute().actionGet();
@ -377,7 +378,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
assertIndexFrozen(indexName); assertIndexFrozen(indexName);
} }
public void testRecoveryState() { public void testRecoveryState() throws ExecutionException, InterruptedException {
final String indexName = "index_recovery_state"; final String indexName = "index_recovery_state";
createIndex(indexName, Settings.builder() createIndex(indexName, Settings.builder()
.put("index.number_of_replicas", 0) .put("index.number_of_replicas", 0)