[TEST] call yaml client close method from test suite (#31591)
We added a way to close the yaml test client with #31575. Such close method also needs to be called from the test suite though for the additional clients to be closed.
This commit is contained in:
parent
13e1cf6191
commit
a35b5341c4
|
@ -31,6 +31,7 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.io.PathUtils;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.core.internal.io.IOUtils;
|
||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||
import org.elasticsearch.test.rest.yaml.restspec.ClientYamlSuiteRestApi;
|
||||
import org.elasticsearch.test.rest.yaml.restspec.ClientYamlSuiteRestSpec;
|
||||
|
@ -105,6 +106,7 @@ public abstract class ESClientYamlSuiteTestCase extends ESRestTestCase {
|
|||
private static List<BlacklistedPathPatternMatcher> blacklistPathMatchers;
|
||||
private static ClientYamlTestExecutionContext restTestExecutionContext;
|
||||
private static ClientYamlTestExecutionContext adminExecutionContext;
|
||||
private static ClientYamlTestClient clientYamlTestClient;
|
||||
|
||||
private final ClientYamlTestCandidate testCandidate;
|
||||
|
||||
|
@ -136,7 +138,7 @@ public abstract class ESClientYamlSuiteTestCase extends ESRestTestCase {
|
|||
final Version esVersion = versionVersionTuple.v1();
|
||||
final Version masterVersion = versionVersionTuple.v2();
|
||||
logger.info("initializing client, minimum es version [{}], master version, [{}], hosts {}", esVersion, masterVersion, hosts);
|
||||
final ClientYamlTestClient clientYamlTestClient = initClientYamlTestClient(restSpec, client(), hosts, esVersion, masterVersion);
|
||||
clientYamlTestClient = initClientYamlTestClient(restSpec, client(), hosts, esVersion, masterVersion);
|
||||
restTestExecutionContext = new ClientYamlTestExecutionContext(clientYamlTestClient, randomizeContentType());
|
||||
adminExecutionContext = new ClientYamlTestExecutionContext(clientYamlTestClient, false);
|
||||
final String[] blacklist = resolvePathsProperty(REST_TESTS_BLACKLIST, null);
|
||||
|
@ -169,6 +171,18 @@ public abstract class ESClientYamlSuiteTestCase extends ESRestTestCase {
|
|||
restClientBuilder -> configureClient(restClientBuilder, restClientSettings()));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void closeClient() throws IOException {
|
||||
try {
|
||||
IOUtils.close(clientYamlTestClient);
|
||||
} finally {
|
||||
blacklistPathMatchers = null;
|
||||
restTestExecutionContext = null;
|
||||
adminExecutionContext = null;
|
||||
clientYamlTestClient = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create parameters for this parameterized test. Uses the
|
||||
* {@link ExecutableSection#XCONTENT_REGISTRY list} of executable sections
|
||||
|
@ -266,13 +280,6 @@ public abstract class ESClientYamlSuiteTestCase extends ESRestTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void clearStatic() {
|
||||
blacklistPathMatchers = null;
|
||||
restTestExecutionContext = null;
|
||||
adminExecutionContext = null;
|
||||
}
|
||||
|
||||
private static Tuple<Version, Version> readVersionsFromCatNodes(RestClient restClient) throws IOException {
|
||||
// we simply go to the _cat/nodes API and parse all versions in the cluster
|
||||
Response response = restClient.performRequest("GET", "/_cat/nodes", Collections.singletonMap("h", "version,master"));
|
||||
|
|
Loading…
Reference in New Issue