Browse Source

Reduce exception-mangling in more tests (#104034)

David Turner 1 year ago
parent
commit
b16620557d

+ 2 - 3
server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotStressTestsIT.java

@@ -24,7 +24,6 @@ import org.elasticsearch.action.bulk.BulkItemResponse;
 import org.elasticsearch.action.bulk.BulkRequestBuilder;
 import org.elasticsearch.action.bulk.BulkResponse;
 import org.elasticsearch.action.index.IndexRequest;
-import org.elasticsearch.action.support.ListenableActionFuture;
 import org.elasticsearch.action.support.SubscribableListener;
 import org.elasticsearch.action.support.master.AcknowledgedResponse;
 import org.elasticsearch.client.internal.Client;
@@ -1589,7 +1588,7 @@ public class SnapshotStressTestsIT extends AbstractSnapshotIntegTestCase {
         private final TrackedCluster.TrackedRepository trackedRepository;
         private final String snapshotName;
         private final Semaphore permits = new Semaphore(Integer.MAX_VALUE);
-        private final AtomicReference<ListenableActionFuture<SnapshotInfo>> snapshotInfoFutureRef = new AtomicReference<>();
+        private final AtomicReference<SubscribableListener<SnapshotInfo>> snapshotInfoFutureRef = new AtomicReference<>();
 
         TrackedSnapshot(TrackedCluster.TrackedRepository trackedRepository, String snapshotName) {
             this.trackedRepository = trackedRepository;
@@ -1628,7 +1627,7 @@ public class SnapshotStressTestsIT extends AbstractSnapshotIntegTestCase {
         }
 
         void getSnapshotInfo(Client client, ActionListener<SnapshotInfo> listener) {
-            final ListenableActionFuture<SnapshotInfo> newFuture = new ListenableActionFuture<>();
+            final SubscribableListener<SnapshotInfo> newFuture = new SubscribableListener<>();
 
             final boolean firstRunner = snapshotInfoFutureRef.compareAndSet(null, newFuture);
 

+ 3 - 3
server/src/test/java/org/elasticsearch/cluster/NodeConnectionsServiceTests.java

@@ -13,8 +13,8 @@ import org.elasticsearch.Build;
 import org.elasticsearch.TransportVersion;
 import org.elasticsearch.Version;
 import org.elasticsearch.action.ActionListener;
-import org.elasticsearch.action.support.ListenableActionFuture;
 import org.elasticsearch.action.support.PlainActionFuture;
+import org.elasticsearch.action.support.SubscribableListener;
 import org.elasticsearch.cluster.node.DiscoveryNode;
 import org.elasticsearch.cluster.node.DiscoveryNodeRole;
 import org.elasticsearch.cluster.node.DiscoveryNodeUtils;
@@ -620,8 +620,8 @@ public class NodeConnectionsServiceTests extends ESTestCase {
                 threadPool.generic().execute(() -> {
                     runConnectionBlock(connectionBlock);
                     listener.onResponse(new Connection() {
-                        private final ListenableActionFuture<Void> closeListener = new ListenableActionFuture<>();
-                        private final ListenableActionFuture<Void> removedListener = new ListenableActionFuture<>();
+                        private final SubscribableListener<Void> closeListener = new SubscribableListener<>();
+                        private final SubscribableListener<Void> removedListener = new SubscribableListener<>();
 
                         private final RefCounted refCounted = AbstractRefCounted.of(() -> closeListener.onResponse(null));
 

+ 2 - 2
server/src/test/java/org/elasticsearch/http/DefaultRestChannelTests.java

@@ -12,7 +12,7 @@ import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.lucene.util.BytesRef;
 import org.elasticsearch.action.ActionListener;
-import org.elasticsearch.action.support.ListenableActionFuture;
+import org.elasticsearch.action.support.SubscribableListener;
 import org.elasticsearch.common.ReferenceDocs;
 import org.elasticsearch.common.bytes.BytesArray;
 import org.elasticsearch.common.bytes.BytesReference;
@@ -570,7 +570,7 @@ public class DefaultRestChannelTests extends ESTestCase {
 
     @TestLogging(reason = "Get HttpTracer to output trace logs", value = "org.elasticsearch.http.HttpTracer:TRACE")
     public void testHttpTracerSendResponseSuccess() {
-        final ListenableActionFuture<Void> sendResponseFuture = new ListenableActionFuture<>();
+        final SubscribableListener<Void> sendResponseFuture = new SubscribableListener<>();
         final HttpChannel httpChannel = new FakeRestRequest.FakeHttpChannel(InetSocketAddress.createUnresolved("127.0.0.1", 9200)) {
             @Override
             public void sendResponse(HttpResponse response, ActionListener<Void> listener) {

+ 2 - 2
test/framework/src/main/java/org/elasticsearch/test/rest/FakeRestRequest.java

@@ -9,7 +9,7 @@
 package org.elasticsearch.test.rest;
 
 import org.elasticsearch.action.ActionListener;
-import org.elasticsearch.action.support.ListenableActionFuture;
+import org.elasticsearch.action.support.SubscribableListener;
 import org.elasticsearch.common.bytes.BytesArray;
 import org.elasticsearch.common.bytes.BytesReference;
 import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
@@ -150,7 +150,7 @@ public class FakeRestRequest extends RestRequest {
     public static class FakeHttpChannel implements HttpChannel {
 
         private final InetSocketAddress remoteAddress;
-        private final ListenableActionFuture<Void> closeFuture = new ListenableActionFuture<>();
+        private final SubscribableListener<Void> closeFuture = new SubscribableListener<>();
 
         public FakeHttpChannel(InetSocketAddress remoteAddress) {
             this.remoteAddress = remoteAddress;

+ 4 - 4
x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/shared/PartiallyCachedShardAllocationIntegTests.java

@@ -12,7 +12,7 @@ import org.elasticsearch.action.ActionFuture;
 import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplanation;
 import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
 import org.elasticsearch.action.support.ActionTestUtils;
-import org.elasticsearch.action.support.ListenableActionFuture;
+import org.elasticsearch.action.support.SubscribableListener;
 import org.elasticsearch.cluster.ClusterState;
 import org.elasticsearch.cluster.node.DiscoveryNodeRole;
 import org.elasticsearch.cluster.routing.RoutingNode;
@@ -198,10 +198,10 @@ public class PartiallyCachedShardAllocationIntegTests extends BaseFrozenSearchab
 
         final MountSearchableSnapshotRequest req = prepareMountRequest();
 
-        final Map<String, ListenableActionFuture<Void>> cacheInfoBlocks = ConcurrentCollections.newConcurrentMap();
-        final Function<String, ListenableActionFuture<Void>> cacheInfoBlockGetter = nodeName -> cacheInfoBlocks.computeIfAbsent(
+        final Map<String, SubscribableListener<Void>> cacheInfoBlocks = ConcurrentCollections.newConcurrentMap();
+        final Function<String, SubscribableListener<Void>> cacheInfoBlockGetter = nodeName -> cacheInfoBlocks.computeIfAbsent(
             nodeName,
-            ignored -> new ListenableActionFuture<>()
+            ignored -> new SubscribableListener<>()
         );
         // Unblock all the existing nodes
         for (final String nodeName : internalCluster().getNodeNames()) {