@@ -59,7 +59,7 @@ public class Ec2DiscoveryTests extends AbstractEC2MockAPITestCase {
5959 private static final String PREFIX_PUBLIC_IP = "8.8.8." ;
6060 private static final String PREFIX_PRIVATE_IP = "10.0.0." ;
6161
62- private Map <String , TransportAddress > poorMansDNS = new ConcurrentHashMap <>();
62+ private final Map <String , TransportAddress > poorMansDNS = new ConcurrentHashMap <>();
6363
6464 protected MockTransportService createTransportService () {
6565 final Transport transport = new Netty4Transport (
@@ -133,7 +133,7 @@ protected List<TransportAddress> buildDynamicHosts(Settings nodeSettings, int no
133133 .stream ()
134134 .filter (t -> t .getKey ().equals (entry .getKey ()))
135135 .map (Tag ::getValue )
136- .collect ( Collectors . toList () )
136+ .toList ()
137137 .containsAll (entry .getValue ())
138138 )
139139 )
@@ -144,6 +144,7 @@ protected List<TransportAddress> buildDynamicHosts(Settings nodeSettings, int no
144144 exchange .getResponseHeaders ().set ("Content-Type" , "text/xml; charset=UTF-8" );
145145 exchange .sendResponseHeaders (HttpStatus .SC_OK , responseBody .length );
146146 exchange .getResponseBody ().write (responseBody );
147+ exchange .getResponseBody ().flush ();
147148 return ;
148149 }
149150 }
@@ -160,14 +161,14 @@ protected List<TransportAddress> buildDynamicHosts(Settings nodeSettings, int no
160161 }
161162 }
162163
163- public void testDefaultSettings () throws InterruptedException {
164+ public void testDefaultSettings () {
164165 int nodes = randomInt (10 );
165166 Settings nodeSettings = Settings .builder ().build ();
166167 List <TransportAddress > discoveryNodes = buildDynamicHosts (nodeSettings , nodes );
167168 assertThat (discoveryNodes , hasSize (nodes ));
168169 }
169170
170- public void testPrivateIp () throws InterruptedException {
171+ public void testPrivateIp () {
171172 int nodes = randomInt (10 );
172173 for (int i = 0 ; i < nodes ; i ++) {
173174 poorMansDNS .put (PREFIX_PRIVATE_IP + (i + 1 ), buildNewFakeTransportAddress ());
@@ -183,7 +184,7 @@ public void testPrivateIp() throws InterruptedException {
183184 }
184185 }
185186
186- public void testPublicIp () throws InterruptedException {
187+ public void testPublicIp () {
187188 int nodes = randomInt (10 );
188189 for (int i = 0 ; i < nodes ; i ++) {
189190 poorMansDNS .put (PREFIX_PUBLIC_IP + (i + 1 ), buildNewFakeTransportAddress ());
@@ -199,7 +200,7 @@ public void testPublicIp() throws InterruptedException {
199200 }
200201 }
201202
202- public void testPrivateDns () throws InterruptedException {
203+ public void testPrivateDns () {
203204 int nodes = randomInt (10 );
204205 for (int i = 0 ; i < nodes ; i ++) {
205206 String instanceId = "node" + (i + 1 );
@@ -217,7 +218,7 @@ public void testPrivateDns() throws InterruptedException {
217218 }
218219 }
219220
220- public void testPublicDns () throws InterruptedException {
221+ public void testPublicDns () {
221222 int nodes = randomInt (10 );
222223 for (int i = 0 ; i < nodes ; i ++) {
223224 String instanceId = "node" + (i + 1 );
@@ -235,14 +236,14 @@ public void testPublicDns() throws InterruptedException {
235236 }
236237 }
237238
238- public void testInvalidHostType () throws InterruptedException {
239+ public void testInvalidHostType () {
239240 Settings nodeSettings = Settings .builder ().put (AwsEc2Service .HOST_TYPE_SETTING .getKey (), "does_not_exist" ).build ();
240241
241242 IllegalArgumentException exception = expectThrows (IllegalArgumentException .class , () -> { buildDynamicHosts (nodeSettings , 1 ); });
242243 assertThat (exception .getMessage (), containsString ("does_not_exist is unknown for discovery.ec2.host_type" ));
243244 }
244245
245- public void testFilterByTags () throws InterruptedException {
246+ public void testFilterByTags () {
246247 int nodes = randomIntBetween (5 , 10 );
247248 Settings nodeSettings = Settings .builder ().put (AwsEc2Service .TAG_SETTING .getKey () + "stage" , "prod" ).build ();
248249
@@ -265,7 +266,7 @@ public void testFilterByTags() throws InterruptedException {
265266 assertThat (dynamicHosts , hasSize (prodInstances ));
266267 }
267268
268- public void testFilterByMultipleTags () throws InterruptedException {
269+ public void testFilterByMultipleTags () {
269270 int nodes = randomIntBetween (5 , 10 );
270271 Settings nodeSettings = Settings .builder ().putList (AwsEc2Service .TAG_SETTING .getKey () + "stage" , "prod" , "preprod" ).build ();
271272
0 commit comments