Cleanup Deadcode in Rest Tests (#37418)

* Either dead code outright or redundant overrides removed
This commit is contained in:
Armin Braun 2019-01-14 16:22:44 +01:00 committed by GitHub
parent 1abe5df09c
commit 033e67fa59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 73 deletions

View File

@ -112,7 +112,7 @@ public abstract class ESRestTestCase extends ESTestCase {
/**
* Does any node in the cluster being tested have x-pack installed?
*/
public static boolean hasXPack() throws IOException {
public static boolean hasXPack() {
if (hasXPack == null) {
throw new IllegalStateException("must be called inside of a rest test case test");
}
@ -554,7 +554,7 @@ public abstract class ESRestTestCase extends ESTestCase {
}
}
private void wipeRollupJobs() throws IOException, InterruptedException {
private void wipeRollupJobs() throws IOException {
Response response = adminClient().performRequest(new Request("GET", "/_rollup/job/_all"));
Map<String, Object> jobs = entityAsMap(response);
@SuppressWarnings("unchecked")
@ -617,7 +617,7 @@ public abstract class ESRestTestCase extends ESTestCase {
* Logs a message if there are still running tasks. The reasoning is that any tasks still running are state the is trying to bleed into
* other tests.
*/
private void logIfThereAreRunningTasks() throws InterruptedException, IOException {
private void logIfThereAreRunningTasks() throws IOException {
Set<String> runningTasks = runningTasks(adminClient().performRequest(new Request("GET", "/_tasks")));
// Ignore the task list API - it doesn't count against us
runningTasks.remove(ListTasksAction.NAME);

View File

@ -18,18 +18,12 @@
*/
package org.elasticsearch.test.rest;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.rest.AbstractRestChannel;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.RestStatus;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public final class FakeRestChannel extends AbstractRestChannel {
@ -43,31 +37,6 @@ public final class FakeRestChannel extends AbstractRestChannel {
this.latch = new CountDownLatch(responseCount);
}
@Override
public XContentBuilder newBuilder() throws IOException {
return super.newBuilder();
}
@Override
public XContentBuilder newErrorBuilder() throws IOException {
return super.newErrorBuilder();
}
@Override
public XContentBuilder newBuilder(@Nullable XContentType requestContentType, boolean useFiltering) throws IOException {
return super.newBuilder(requestContentType, useFiltering);
}
@Override
protected BytesStreamOutput newBytesOutput() {
return super.newBytesOutput();
}
@Override
public RestRequest request() {
return super.request();
}
@Override
public void sendResponse(RestResponse response) {
this.capturedRestResponse = response;
@ -83,10 +52,6 @@ public final class FakeRestChannel extends AbstractRestChannel {
return capturedRestResponse;
}
public boolean await() throws InterruptedException {
return latch.await(10, TimeUnit.SECONDS);
}
public AtomicInteger responses() {
return responses;
}

View File

@ -319,26 +319,6 @@ public abstract class ESClientYamlSuiteTestCase extends ESRestTestCase {
return new Tuple<>(version, masterVersion);
}
private static Version readVersionsFromInfo(RestClient restClient, int numHosts) throws IOException {
Version version = null;
for (int i = 0; i < numHosts; i++) {
//we don't really use the urls here, we rely on the client doing round-robin to touch all the nodes in the cluster
Response response = restClient.performRequest(new Request("GET", "/"));
ClientYamlTestResponse restTestResponse = new ClientYamlTestResponse(response);
Object latestVersion = restTestResponse.evaluate("version.number");
if (latestVersion == null) {
throw new RuntimeException("elasticsearch version not found in the response");
}
final Version currentVersion = Version.fromString(latestVersion.toString());
if (version == null) {
version = currentVersion;
} else if (version.onOrAfter(currentVersion)) {
version = currentVersion;
}
}
return version;
}
public void test() throws IOException {
//skip test if it matches one of the blacklist globs
for (BlacklistedPathPatternMatcher blacklistedPathMatcher : blacklistPathMatchers) {

View File

@ -19,7 +19,6 @@
package org.elasticsearch.test.rest.yaml;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
@ -58,23 +57,19 @@ public final class Features {
* Tells whether all the features provided as argument are supported
*/
public static boolean areAllSupported(List<String> features) {
try {
for (String feature : features) {
if (feature.equals("xpack")) {
if (false == ESRestTestCase.hasXPack()) {
return false;
}
} else if (feature.equals("no_xpack")) {
if (ESRestTestCase.hasXPack()) {
return false;
}
} else if (false == SUPPORTED.contains(feature)) {
for (String feature : features) {
if (feature.equals("xpack")) {
if (false == ESRestTestCase.hasXPack()) {
return false;
}
} else if (feature.equals("no_xpack")) {
if (ESRestTestCase.hasXPack()) {
return false;
}
} else if (false == SUPPORTED.contains(feature)) {
return false;
}
return true;
} catch (IOException e) {
throw new RuntimeException("error checking if xpack is available", e);
}
return true;
}
}