forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '8.x' into backport/8.x/pr-120223
- Loading branch information
Showing
17 changed files
with
260 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...src/main21/java/org/elasticsearch/entitlement/qa/common/VersionSpecificNetworkChecks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
package org.elasticsearch.entitlement.qa.common; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.net.http.HttpClient; | ||
import java.net.http.HttpRequest; | ||
import java.net.http.HttpResponse; | ||
import java.net.spi.InetAddressResolver; | ||
import java.net.spi.InetAddressResolverProvider; | ||
|
||
class VersionSpecificNetworkChecks { | ||
static void createInetAddressResolverProvider() { | ||
var x = new InetAddressResolverProvider() { | ||
@Override | ||
public InetAddressResolver get(Configuration configuration) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return "TEST"; | ||
} | ||
}; | ||
} | ||
|
||
static void httpClientBuilderBuild() { | ||
try (HttpClient httpClient = HttpClient.newBuilder().build()) { | ||
assert httpClient != null; | ||
} | ||
} | ||
|
||
static void httpClientSend() throws InterruptedException { | ||
try (HttpClient httpClient = HttpClient.newBuilder().build()) { | ||
// Shutdown the client, so the send action will shortcut before actually executing any network operation | ||
// (but after it run our check in the prologue) | ||
httpClient.shutdown(); | ||
try { | ||
httpClient.send(HttpRequest.newBuilder(URI.create("http://localhost")).build(), HttpResponse.BodyHandlers.discarding()); | ||
} catch (IOException e) { | ||
// Expected, since we shut down the client | ||
} | ||
} | ||
} | ||
|
||
static void httpClientSendAsync() { | ||
try (HttpClient httpClient = HttpClient.newBuilder().build()) { | ||
// Shutdown the client, so the send action will return before actually executing any network operation | ||
// (but after it run our check in the prologue) | ||
httpClient.shutdown(); | ||
var future = httpClient.sendAsync( | ||
HttpRequest.newBuilder(URI.create("http://localhost")).build(), | ||
HttpResponse.BodyHandlers.discarding() | ||
); | ||
assert future.isCompletedExceptionally(); | ||
future.exceptionally(ex -> { | ||
assert ex instanceof IOException; | ||
return null; | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.