Skip to content

Commit 033e67f

Browse files
Cleanup Deadcode in Rest Tests (#37418)
* Either dead code outright or redundant overrides removed
1 parent 1abe5df commit 033e67f

File tree

4 files changed

+13
-73
lines changed

4 files changed

+13
-73
lines changed

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public static Map<String, Object> entityAsMap(Response response) throws IOExcept
112112
/**
113113
* Does any node in the cluster being tested have x-pack installed?
114114
*/
115-
public static boolean hasXPack() throws IOException {
115+
public static boolean hasXPack() {
116116
if (hasXPack == null) {
117117
throw new IllegalStateException("must be called inside of a rest test case test");
118118
}
@@ -554,7 +554,7 @@ private void wipeClusterSettings() throws IOException {
554554
}
555555
}
556556

557-
private void wipeRollupJobs() throws IOException, InterruptedException {
557+
private void wipeRollupJobs() throws IOException {
558558
Response response = adminClient().performRequest(new Request("GET", "/_rollup/job/_all"));
559559
Map<String, Object> jobs = entityAsMap(response);
560560
@SuppressWarnings("unchecked")
@@ -617,7 +617,7 @@ private static void deleteAllPolicies() throws IOException {
617617
* 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
618618
* other tests.
619619
*/
620-
private void logIfThereAreRunningTasks() throws InterruptedException, IOException {
620+
private void logIfThereAreRunningTasks() throws IOException {
621621
Set<String> runningTasks = runningTasks(adminClient().performRequest(new Request("GET", "/_tasks")));
622622
// Ignore the task list API - it doesn't count against us
623623
runningTasks.remove(ListTasksAction.NAME);

test/framework/src/main/java/org/elasticsearch/test/rest/FakeRestChannel.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,12 @@
1818
*/
1919
package org.elasticsearch.test.rest;
2020

21-
import org.elasticsearch.common.Nullable;
22-
import org.elasticsearch.common.io.stream.BytesStreamOutput;
23-
import org.elasticsearch.common.xcontent.XContentBuilder;
24-
import org.elasticsearch.common.xcontent.XContentType;
2521
import org.elasticsearch.rest.AbstractRestChannel;
2622
import org.elasticsearch.rest.RestRequest;
2723
import org.elasticsearch.rest.RestResponse;
2824
import org.elasticsearch.rest.RestStatus;
2925

30-
import java.io.IOException;
3126
import java.util.concurrent.CountDownLatch;
32-
import java.util.concurrent.TimeUnit;
3327
import java.util.concurrent.atomic.AtomicInteger;
3428

3529
public final class FakeRestChannel extends AbstractRestChannel {
@@ -43,31 +37,6 @@ public FakeRestChannel(RestRequest request, boolean detailedErrorsEnabled, int r
4337
this.latch = new CountDownLatch(responseCount);
4438
}
4539

46-
@Override
47-
public XContentBuilder newBuilder() throws IOException {
48-
return super.newBuilder();
49-
}
50-
51-
@Override
52-
public XContentBuilder newErrorBuilder() throws IOException {
53-
return super.newErrorBuilder();
54-
}
55-
56-
@Override
57-
public XContentBuilder newBuilder(@Nullable XContentType requestContentType, boolean useFiltering) throws IOException {
58-
return super.newBuilder(requestContentType, useFiltering);
59-
}
60-
61-
@Override
62-
protected BytesStreamOutput newBytesOutput() {
63-
return super.newBytesOutput();
64-
}
65-
66-
@Override
67-
public RestRequest request() {
68-
return super.request();
69-
}
70-
7140
@Override
7241
public void sendResponse(RestResponse response) {
7342
this.capturedRestResponse = response;
@@ -83,10 +52,6 @@ public RestResponse capturedResponse() {
8352
return capturedRestResponse;
8453
}
8554

86-
public boolean await() throws InterruptedException {
87-
return latch.await(10, TimeUnit.SECONDS);
88-
}
89-
9055
public AtomicInteger responses() {
9156
return responses;
9257
}

test/framework/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -319,26 +319,6 @@ private static Tuple<Version, Version> readVersionsFromCatNodes(RestClient restC
319319
return new Tuple<>(version, masterVersion);
320320
}
321321

322-
private static Version readVersionsFromInfo(RestClient restClient, int numHosts) throws IOException {
323-
Version version = null;
324-
for (int i = 0; i < numHosts; i++) {
325-
//we don't really use the urls here, we rely on the client doing round-robin to touch all the nodes in the cluster
326-
Response response = restClient.performRequest(new Request("GET", "/"));
327-
ClientYamlTestResponse restTestResponse = new ClientYamlTestResponse(response);
328-
Object latestVersion = restTestResponse.evaluate("version.number");
329-
if (latestVersion == null) {
330-
throw new RuntimeException("elasticsearch version not found in the response");
331-
}
332-
final Version currentVersion = Version.fromString(latestVersion.toString());
333-
if (version == null) {
334-
version = currentVersion;
335-
} else if (version.onOrAfter(currentVersion)) {
336-
version = currentVersion;
337-
}
338-
}
339-
return version;
340-
}
341-
342322
public void test() throws IOException {
343323
//skip test if it matches one of the blacklist globs
344324
for (BlacklistedPathPatternMatcher blacklistedPathMatcher : blacklistPathMatchers) {

test/framework/src/main/java/org/elasticsearch/test/rest/yaml/Features.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.elasticsearch.test.rest.yaml;
2121

22-
import java.io.IOException;
2322
import java.util.Arrays;
2423
import java.util.List;
2524

@@ -58,23 +57,19 @@ private Features() {
5857
* Tells whether all the features provided as argument are supported
5958
*/
6059
public static boolean areAllSupported(List<String> features) {
61-
try {
62-
for (String feature : features) {
63-
if (feature.equals("xpack")) {
64-
if (false == ESRestTestCase.hasXPack()) {
65-
return false;
66-
}
67-
} else if (feature.equals("no_xpack")) {
68-
if (ESRestTestCase.hasXPack()) {
69-
return false;
70-
}
71-
} else if (false == SUPPORTED.contains(feature)) {
60+
for (String feature : features) {
61+
if (feature.equals("xpack")) {
62+
if (false == ESRestTestCase.hasXPack()) {
7263
return false;
7364
}
65+
} else if (feature.equals("no_xpack")) {
66+
if (ESRestTestCase.hasXPack()) {
67+
return false;
68+
}
69+
} else if (false == SUPPORTED.contains(feature)) {
70+
return false;
7471
}
75-
return true;
76-
} catch (IOException e) {
77-
throw new RuntimeException("error checking if xpack is available", e);
7872
}
73+
return true;
7974
}
8075
}

0 commit comments

Comments
 (0)