mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 06:25:07 +00:00
Cleanup Deadcode in Rest Tests (#37418)
* Either dead code outright or redundant overrides removed
This commit is contained in:
parent
1abe5df09c
commit
033e67fa59
@ -112,7 +112,7 @@ public abstract class ESRestTestCase extends ESTestCase {
|
|||||||
/**
|
/**
|
||||||
* Does any node in the cluster being tested have x-pack installed?
|
* 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) {
|
if (hasXPack == null) {
|
||||||
throw new IllegalStateException("must be called inside of a rest test case test");
|
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"));
|
Response response = adminClient().performRequest(new Request("GET", "/_rollup/job/_all"));
|
||||||
Map<String, Object> jobs = entityAsMap(response);
|
Map<String, Object> jobs = entityAsMap(response);
|
||||||
@SuppressWarnings("unchecked")
|
@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
|
* 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.
|
* other tests.
|
||||||
*/
|
*/
|
||||||
private void logIfThereAreRunningTasks() throws InterruptedException, IOException {
|
private void logIfThereAreRunningTasks() throws IOException {
|
||||||
Set<String> runningTasks = runningTasks(adminClient().performRequest(new Request("GET", "/_tasks")));
|
Set<String> runningTasks = runningTasks(adminClient().performRequest(new Request("GET", "/_tasks")));
|
||||||
// Ignore the task list API - it doesn't count against us
|
// Ignore the task list API - it doesn't count against us
|
||||||
runningTasks.remove(ListTasksAction.NAME);
|
runningTasks.remove(ListTasksAction.NAME);
|
||||||
|
@ -18,18 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.elasticsearch.test.rest;
|
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.AbstractRestChannel;
|
||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
import org.elasticsearch.rest.RestResponse;
|
import org.elasticsearch.rest.RestResponse;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public final class FakeRestChannel extends AbstractRestChannel {
|
public final class FakeRestChannel extends AbstractRestChannel {
|
||||||
@ -43,31 +37,6 @@ public final class FakeRestChannel extends AbstractRestChannel {
|
|||||||
this.latch = new CountDownLatch(responseCount);
|
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
|
@Override
|
||||||
public void sendResponse(RestResponse response) {
|
public void sendResponse(RestResponse response) {
|
||||||
this.capturedRestResponse = response;
|
this.capturedRestResponse = response;
|
||||||
@ -83,10 +52,6 @@ public final class FakeRestChannel extends AbstractRestChannel {
|
|||||||
return capturedRestResponse;
|
return capturedRestResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean await() throws InterruptedException {
|
|
||||||
return latch.await(10, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AtomicInteger responses() {
|
public AtomicInteger responses() {
|
||||||
return responses;
|
return responses;
|
||||||
}
|
}
|
||||||
|
@ -319,26 +319,6 @@ public abstract class ESClientYamlSuiteTestCase extends ESRestTestCase {
|
|||||||
return new Tuple<>(version, masterVersion);
|
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 {
|
public void test() throws IOException {
|
||||||
//skip test if it matches one of the blacklist globs
|
//skip test if it matches one of the blacklist globs
|
||||||
for (BlacklistedPathPatternMatcher blacklistedPathMatcher : blacklistPathMatchers) {
|
for (BlacklistedPathPatternMatcher blacklistedPathMatcher : blacklistPathMatchers) {
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package org.elasticsearch.test.rest.yaml;
|
package org.elasticsearch.test.rest.yaml;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -58,7 +57,6 @@ public final class Features {
|
|||||||
* Tells whether all the features provided as argument are supported
|
* Tells whether all the features provided as argument are supported
|
||||||
*/
|
*/
|
||||||
public static boolean areAllSupported(List<String> features) {
|
public static boolean areAllSupported(List<String> features) {
|
||||||
try {
|
|
||||||
for (String feature : features) {
|
for (String feature : features) {
|
||||||
if (feature.equals("xpack")) {
|
if (feature.equals("xpack")) {
|
||||||
if (false == ESRestTestCase.hasXPack()) {
|
if (false == ESRestTestCase.hasXPack()) {
|
||||||
@ -73,8 +71,5 @@ public final class Features {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException("error checking if xpack is available", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user