Skip to content

Commit 6377745

Browse files
Address code review comments
1 parent 2a56cee commit 6377745

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

server/src/test/java/org/elasticsearch/transport/RemoteClusterServiceTests.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
package org.elasticsearch.transport;
1010

1111
import org.apache.logging.log4j.Level;
12+
import org.apache.lucene.store.AlreadyClosedException;
1213
import org.elasticsearch.TransportVersion;
1314
import org.elasticsearch.action.ActionListener;
1415
import org.elasticsearch.action.LatchedActionListener;
@@ -1097,22 +1098,20 @@ public void testCollectNodesConcurrentWithSettingsChanges() throws IOException {
10971098
taskLatch.countDown();
10981099
boolean isLinked = true;
10991100
while (taskLatch.getCount() != 0) {
1100-
final var latch = new CountDownLatch(1);
1101-
service.updateRemoteCluster(
1102-
"cluster_1",
1103-
createSettings("cluster_1", isLinked ? Collections.emptyList() : seedList),
1104-
new LatchedActionListener<>(ActionListener.noop(), latch)
1105-
);
1106-
safeAwait(latch);
1101+
final var future = new PlainActionFuture<RemoteClusterService.RemoteClusterConnectionStatus>();
1102+
final var settings = createSettings("cluster_1", isLinked ? Collections.emptyList() : seedList);
1103+
service.updateRemoteCluster("cluster_1", settings, future);
1104+
safeGet(future);
11071105
isLinked = isLinked == false;
11081106
}
11091107
return;
11101108
}
11111109

11121110
// Verify collectNodes() always invokes the listener, even if the node is concurrently being unlinked.
11131111
try {
1114-
for (int i = 0; i < 1000; ++i) {
1112+
for (int i = 0; i < 10; ++i) {
11151113
final var latch = new CountDownLatch(1);
1114+
final var exRef = new AtomicReference<Exception>();
11161115
service.collectNodes(Set.of("cluster_1"), new LatchedActionListener<>(new ActionListener<>() {
11171116
@Override
11181117
public void onResponse(BiFunction<String, String, DiscoveryNode> func) {
@@ -1121,10 +1120,18 @@ public void onResponse(BiFunction<String, String, DiscoveryNode> func) {
11211120

11221121
@Override
11231122
public void onFailure(Exception e) {
1124-
assertNotNull(e);
1123+
exRef.set(e);
11251124
}
11261125
}, latch));
11271126
safeAwait(latch);
1127+
if (exRef.get() != null) {
1128+
assertThat(
1129+
exRef.get(),
1130+
either(instanceOf(TransportException.class)).or(instanceOf(NoSuchRemoteClusterException.class))
1131+
.or(instanceOf(AlreadyClosedException.class))
1132+
.or(instanceOf(NoSeedNodeLeftException.class))
1133+
);
1134+
}
11281135
}
11291136
} finally {
11301137
taskLatch.countDown();

0 commit comments

Comments
 (0)