Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST] Minor REST tests infra cleanup #7723

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ public static void initExecutionContext() throws IOException, RestException {

String[] specPaths = resolvePathsProperty(REST_TESTS_SPEC, DEFAULT_SPEC_PATH);
RestSpec restSpec = RestSpec.parseFrom(DEFAULT_SPEC_PATH, specPaths);
assert restTestExecutionContext == null;
restTestExecutionContext = new RestTestExecutionContext(restSpec);
}

Expand All @@ -191,7 +190,7 @@ public void reset() throws IOException, RestException {
String testPath = testCandidate.getSuitePath() + "/" + testSection;
assumeFalse("[" + testCandidate.getTestPath() + "] skipped, reason: blacklisted", blacklistedPathMatcher.matches(Paths.get(testPath)));
}

//The client needs non static info to get initialized, therefore it can't be initialized in the before class
restTestExecutionContext.resetClient(cluster().httpAddresses(), restClientSettings());
restTestExecutionContext.clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class RestTestExecutionContext implements Closeable {

private RestResponse response;

public RestTestExecutionContext(RestSpec restSpec) throws RestException, IOException {
public RestTestExecutionContext(RestSpec restSpec) {
this.restSpec = restSpec;
}

Expand Down Expand Up @@ -116,13 +116,11 @@ public Object response(String path) throws IOException {
}

/**
* Resets (or creates) the embedded REST client which will point to the given addresses
* Creates the embedded REST client when needed
*/
public void resetClient(InetSocketAddress[] addresses, Settings settings) throws IOException, RestException {
if (restClient == null) {
restClient = new RestClient(restSpec, settings, addresses);
} else {
restClient.updateAddresses(addresses);
this.restClient = new RestClient(restSpec, settings, addresses);
}
}

Expand Down
11 changes: 1 addition & 10 deletions src/test/java/org/elasticsearch/test/rest/client/RestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ public class RestClient implements Closeable {
private final RestSpec restSpec;
private final CloseableHttpClient httpClient;
private final Headers headers;

private InetSocketAddress[] addresses;

private final InetSocketAddress[] addresses;
private final String esVersion;

public RestClient(RestSpec restSpec, Settings settings, InetSocketAddress[] addresses) throws IOException, RestException {
Expand Down Expand Up @@ -99,13 +97,6 @@ public String getEsVersion() {
return esVersion;
}

/**
* Allows to update the addresses the client needs to connect to
*/
public void updateAddresses(InetSocketAddress[] addresses) {
this.addresses = addresses;
}

/**
* Calls an api with the provided parameters and body
* @throws RestException if the obtained status code is non ok, unless the specific error code needs to be ignored
Expand Down