Skip to content

Commit f751392

Browse files
authored
[7.17] Flush response stream in Ec2DiscoveryTests (#114101) (#114113)
* Flush response stream in `Ec2DiscoveryTests` (#114101) This is apparently necessary when running with JDK23. Also cleans up some warnings in the same test suite. Closes #114088 Closes #114089 Closes #114090 * Revert for compat
1 parent 3ad62ca commit f751392

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class Ec2DiscoveryTests extends AbstractEC2MockAPITestCase {
5858
private static final String PREFIX_PUBLIC_IP = "8.8.8.";
5959
private static final String PREFIX_PRIVATE_IP = "10.0.0.";
6060

61-
private Map<String, TransportAddress> poorMansDNS = new ConcurrentHashMap<>();
61+
private final Map<String, TransportAddress> poorMansDNS = new ConcurrentHashMap<>();
6262

6363
protected MockTransportService createTransportService() {
6464
final Transport transport = new MockNioTransport(
@@ -142,6 +142,7 @@ protected List<TransportAddress> buildDynamicHosts(Settings nodeSettings, int no
142142
exchange.getResponseHeaders().set("Content-Type", "text/xml; charset=UTF-8");
143143
exchange.sendResponseHeaders(HttpStatus.SC_OK, responseBody.length);
144144
exchange.getResponseBody().write(responseBody);
145+
exchange.getResponseBody().flush();
145146
return;
146147
}
147148
}
@@ -158,14 +159,14 @@ protected List<TransportAddress> buildDynamicHosts(Settings nodeSettings, int no
158159
}
159160
}
160161

161-
public void testDefaultSettings() throws InterruptedException {
162+
public void testDefaultSettings() {
162163
int nodes = randomInt(10);
163164
Settings nodeSettings = Settings.builder().build();
164165
List<TransportAddress> discoveryNodes = buildDynamicHosts(nodeSettings, nodes);
165166
assertThat(discoveryNodes, hasSize(nodes));
166167
}
167168

168-
public void testPrivateIp() throws InterruptedException {
169+
public void testPrivateIp() {
169170
int nodes = randomInt(10);
170171
for (int i = 0; i < nodes; i++) {
171172
poorMansDNS.put(PREFIX_PRIVATE_IP + (i + 1), buildNewFakeTransportAddress());
@@ -181,7 +182,7 @@ public void testPrivateIp() throws InterruptedException {
181182
}
182183
}
183184

184-
public void testPublicIp() throws InterruptedException {
185+
public void testPublicIp() {
185186
int nodes = randomInt(10);
186187
for (int i = 0; i < nodes; i++) {
187188
poorMansDNS.put(PREFIX_PUBLIC_IP + (i + 1), buildNewFakeTransportAddress());
@@ -197,7 +198,7 @@ public void testPublicIp() throws InterruptedException {
197198
}
198199
}
199200

200-
public void testPrivateDns() throws InterruptedException {
201+
public void testPrivateDns() {
201202
int nodes = randomInt(10);
202203
for (int i = 0; i < nodes; i++) {
203204
String instanceId = "node" + (i + 1);
@@ -215,7 +216,7 @@ public void testPrivateDns() throws InterruptedException {
215216
}
216217
}
217218

218-
public void testPublicDns() throws InterruptedException {
219+
public void testPublicDns() {
219220
int nodes = randomInt(10);
220221
for (int i = 0; i < nodes; i++) {
221222
String instanceId = "node" + (i + 1);
@@ -233,14 +234,14 @@ public void testPublicDns() throws InterruptedException {
233234
}
234235
}
235236

236-
public void testInvalidHostType() throws InterruptedException {
237+
public void testInvalidHostType() {
237238
Settings nodeSettings = Settings.builder().put(AwsEc2Service.HOST_TYPE_SETTING.getKey(), "does_not_exist").build();
238239

239240
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> { buildDynamicHosts(nodeSettings, 1); });
240241
assertThat(exception.getMessage(), containsString("does_not_exist is unknown for discovery.ec2.host_type"));
241242
}
242243

243-
public void testFilterByTags() throws InterruptedException {
244+
public void testFilterByTags() {
244245
int nodes = randomIntBetween(5, 10);
245246
Settings nodeSettings = Settings.builder().put(AwsEc2Service.TAG_SETTING.getKey() + "stage", "prod").build();
246247

@@ -263,7 +264,7 @@ public void testFilterByTags() throws InterruptedException {
263264
assertThat(dynamicHosts, hasSize(prodInstances));
264265
}
265266

266-
public void testFilterByMultipleTags() throws InterruptedException {
267+
public void testFilterByMultipleTags() {
267268
int nodes = randomIntBetween(5, 10);
268269
Settings nodeSettings = Settings.builder().putList(AwsEc2Service.TAG_SETTING.getKey() + "stage", "prod", "preprod").build();
269270

0 commit comments

Comments
 (0)