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

Cleanup Deadcode in Rest Tests #37418

Merged
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 @@ -112,7 +112,7 @@ public static Map<String, Object> entityAsMap(Response response) throws IOExcept
/**
* 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");
}
Expand Down Expand Up @@ -554,7 +554,7 @@ private void wipeClusterSettings() throws IOException {
}
}

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")
Expand Down Expand Up @@ -617,7 +617,7 @@ private static void deleteAllPolicies() throws IOException {
* 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -43,31 +37,6 @@ public FakeRestChannel(RestRequest request, boolean detailedErrorsEnabled, int r
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;
Expand All @@ -83,10 +52,6 @@ public RestResponse capturedResponse() {
return capturedRestResponse;
}

public boolean await() throws InterruptedException {
return latch.await(10, TimeUnit.SECONDS);
}

public AtomicInteger responses() {
return responses;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,26 +319,6 @@ private static Tuple<Version, Version> readVersionsFromCatNodes(RestClient restC
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.test.rest.yaml;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

Expand Down Expand Up @@ -58,23 +57,19 @@ private 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;
}
}