From d1e275c4e9adc90204e95af4b6986d79535b7382 Mon Sep 17 00:00:00 2001 From: Himanshu Setia <58999915+setiah@users.noreply.github.com> Date: Thu, 18 Mar 2021 13:47:45 -0700 Subject: [PATCH] Refactor test/logger-usage and test/external-modules as per OpenSearch naming conventions (#398) Signed-off-by: Himanshu Setia --- test/external-modules/build.gradle | 4 ++-- .../search/aggregations/DelayedShardAggregationIT.java | 10 +++++----- .../aggregations/DelayedShardAggregationBuilder.java | 4 ++-- .../aggregations/DelayedShardAggregationPlugin.java | 4 ++-- .../DelayedShardAggregationBuilderTests.java | 2 +- test/logger-usage/build.gradle | 2 +- ...eChecker.java => OpenSearchLoggerUsageChecker.java} | 10 +++++----- .../test/loggerusage/OpenSearchLoggerUsageTests.java | 8 ++++---- .../org/opensearch/test/loggerusage/TestMessage.java | 2 +- 9 files changed, 23 insertions(+), 23 deletions(-) rename test/external-modules/delayed-aggs/src/internalClusterTest/java/org/{elasticsearch => opensearch}/search/aggregations/DelayedShardAggregationIT.java (90%) rename test/logger-usage/src/main/java/org/opensearch/test/loggerusage/{ESLoggerUsageChecker.java => OpenSearchLoggerUsageChecker.java} (98%) diff --git a/test/external-modules/build.gradle b/test/external-modules/build.gradle index 6edede70396..e1d2720fab6 100644 --- a/test/external-modules/build.gradle +++ b/test/external-modules/build.gradle @@ -2,8 +2,8 @@ import org.elasticsearch.gradle.info.BuildParams; subprojects { - apply plugin: 'elasticsearch.esplugin' - apply plugin: 'elasticsearch.yaml-rest-test' + apply plugin: 'opensearch.esplugin' + apply plugin: 'opensearch.yaml-rest-test' esplugin { name it.name diff --git a/test/external-modules/delayed-aggs/src/internalClusterTest/java/org/elasticsearch/search/aggregations/DelayedShardAggregationIT.java b/test/external-modules/delayed-aggs/src/internalClusterTest/java/org/opensearch/search/aggregations/DelayedShardAggregationIT.java similarity index 90% rename from test/external-modules/delayed-aggs/src/internalClusterTest/java/org/elasticsearch/search/aggregations/DelayedShardAggregationIT.java rename to test/external-modules/delayed-aggs/src/internalClusterTest/java/org/opensearch/search/aggregations/DelayedShardAggregationIT.java index 9b3c8688317..487743c7a48 100644 --- a/test/external-modules/delayed-aggs/src/internalClusterTest/java/org/elasticsearch/search/aggregations/DelayedShardAggregationIT.java +++ b/test/external-modules/delayed-aggs/src/internalClusterTest/java/org/opensearch/search/aggregations/DelayedShardAggregationIT.java @@ -18,14 +18,14 @@ */ package org.opensearch.search.aggregations; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; +import org.opensearch.action.index.IndexRequestBuilder; +import org.opensearch.action.search.SearchResponse; import org.opensearch.common.unit.TimeValue; -import org.elasticsearch.plugins.Plugin; +import org.opensearch.plugins.Plugin; import org.opensearch.search.aggregations.bucket.filter.InternalFilter; import org.opensearch.search.aggregations.metrics.InternalMax; import org.opensearch.search.aggregations.metrics.MaxAggregationBuilder; -import org.elasticsearch.test.ESIntegTestCase; +import org.opensearch.test.OpenSearchIntegTestCase; import java.util.ArrayList; import java.util.Arrays; @@ -36,7 +36,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcke import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; -public class DelayedShardAggregationIT extends ESIntegTestCase { +public class DelayedShardAggregationIT extends OpenSearchIntegTestCase { @Override protected Collection> nodePlugins() { diff --git a/test/external-modules/delayed-aggs/src/main/java/org/opensearch/search/aggregations/DelayedShardAggregationBuilder.java b/test/external-modules/delayed-aggs/src/main/java/org/opensearch/search/aggregations/DelayedShardAggregationBuilder.java index d92dd7be5a3..ea395b99f74 100644 --- a/test/external-modules/delayed-aggs/src/main/java/org/opensearch/search/aggregations/DelayedShardAggregationBuilder.java +++ b/test/external-modules/delayed-aggs/src/main/java/org/opensearch/search/aggregations/DelayedShardAggregationBuilder.java @@ -25,8 +25,8 @@ import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.xcontent.ConstructingObjectParser; import org.opensearch.common.xcontent.XContentBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.query.QueryShardContext; +import org.opensearch.index.query.QueryBuilders; +import org.opensearch.index.query.QueryShardContext; import org.opensearch.search.aggregations.bucket.filter.FilterAggregationBuilder; import org.opensearch.search.internal.SearchContext; diff --git a/test/external-modules/delayed-aggs/src/main/java/org/opensearch/search/aggregations/DelayedShardAggregationPlugin.java b/test/external-modules/delayed-aggs/src/main/java/org/opensearch/search/aggregations/DelayedShardAggregationPlugin.java index da72fbcc1c0..2bff342c536 100644 --- a/test/external-modules/delayed-aggs/src/main/java/org/opensearch/search/aggregations/DelayedShardAggregationPlugin.java +++ b/test/external-modules/delayed-aggs/src/main/java/org/opensearch/search/aggregations/DelayedShardAggregationPlugin.java @@ -21,8 +21,8 @@ package org.opensearch.search.aggregations; import java.util.List; -import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.plugins.SearchPlugin; +import org.opensearch.plugins.Plugin; +import org.opensearch.plugins.SearchPlugin; import org.opensearch.search.aggregations.bucket.filter.InternalFilter; import static java.util.Collections.singletonList; diff --git a/test/external-modules/delayed-aggs/src/test/java/org/opensearch/search/aggregations/DelayedShardAggregationBuilderTests.java b/test/external-modules/delayed-aggs/src/test/java/org/opensearch/search/aggregations/DelayedShardAggregationBuilderTests.java index 4537cbdbea9..f8a0a76d215 100644 --- a/test/external-modules/delayed-aggs/src/test/java/org/opensearch/search/aggregations/DelayedShardAggregationBuilderTests.java +++ b/test/external-modules/delayed-aggs/src/test/java/org/opensearch/search/aggregations/DelayedShardAggregationBuilderTests.java @@ -19,7 +19,7 @@ package org.opensearch.search.aggregations; import org.opensearch.common.unit.TimeValue; -import org.elasticsearch.plugins.Plugin; +import org.opensearch.plugins.Plugin; import org.opensearch.test.TestGeoShapeFieldMapperPlugin; import java.util.Arrays; diff --git a/test/logger-usage/build.gradle b/test/logger-usage/build.gradle index 9e3ee778c9b..ba0b7ffb483 100644 --- a/test/logger-usage/build.gradle +++ b/test/logger-usage/build.gradle @@ -17,7 +17,7 @@ * under the License. */ -apply plugin: 'elasticsearch.java' +apply plugin: 'opensearch.java' dependencies { api 'org.ow2.asm:asm:7.1' diff --git a/test/logger-usage/src/main/java/org/opensearch/test/loggerusage/ESLoggerUsageChecker.java b/test/logger-usage/src/main/java/org/opensearch/test/loggerusage/OpenSearchLoggerUsageChecker.java similarity index 98% rename from test/logger-usage/src/main/java/org/opensearch/test/loggerusage/ESLoggerUsageChecker.java rename to test/logger-usage/src/main/java/org/opensearch/test/loggerusage/OpenSearchLoggerUsageChecker.java index 1c8a21bf550..8f1337ea439 100644 --- a/test/logger-usage/src/main/java/org/opensearch/test/loggerusage/ESLoggerUsageChecker.java +++ b/test/logger-usage/src/main/java/org/opensearch/test/loggerusage/OpenSearchLoggerUsageChecker.java @@ -58,7 +58,7 @@ import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; -public class ESLoggerUsageChecker { +public class OpenSearchLoggerUsageChecker { public static final Type LOGGER_CLASS = Type.getType(Logger.class); public static final Type THROWABLE_CLASS = Type.getType(Throwable.class); public static final Type STRING_CLASS = Type.getType(String.class); @@ -73,7 +73,7 @@ public class ESLoggerUsageChecker { // types which are subject to checking when used in logger. TestMessage is also declared here to // make sure this functionality works public static final Set DEPRECATED_TYPES = Stream.of( - Type.getObjectType("org/elasticsearch/common/logging/DeprecatedMessage"), + Type.getObjectType("org/opensearch/common/logging/DeprecatedMessage"), Type.getObjectType("org/opensearch/test/loggerusage/TestMessage") ).collect(Collectors.toSet()); @@ -81,7 +81,7 @@ public class ESLoggerUsageChecker { @SuppressForbidden(reason = "command line tool") public static void main(String... args) throws Exception { - System.out.println("checking for wrong usages of ESLogger..."); + System.out.println("checking for wrong usages of OpenSearchLogger..."); boolean[] wrongUsageFound = new boolean[1]; checkLoggerUsage(wrongLoggerUsage -> { System.err.println(wrongLoggerUsage.getErrorLines()); @@ -106,7 +106,7 @@ public class ESLoggerUsageChecker { public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (Files.isRegularFile(file) && file.getFileName().toString().endsWith(".class")) { try (InputStream in = Files.newInputStream(file)) { - ESLoggerUsageChecker.check(wrongUsageCallback, in); + OpenSearchLoggerUsageChecker.check(wrongUsageCallback, in); } } return super.visitFile(file, attrs); @@ -328,7 +328,7 @@ public class ESLoggerUsageChecker { //using strings because this test do not depend on server MethodInsnNode methodInsn = (MethodInsnNode) insn; - if (methodInsn.owner.equals("org/elasticsearch/common/logging/DeprecationLogger")) { + if (methodInsn.owner.equals("org/opensearch/common/logging/DeprecationLogger")) { if (methodInsn.name.equals("deprecate")) { Type[] argumentTypes = Type.getArgumentTypes(methodInsn.desc); int markerOffset = 1; // skip key diff --git a/test/logger-usage/src/test/java/org/opensearch/test/loggerusage/OpenSearchLoggerUsageTests.java b/test/logger-usage/src/test/java/org/opensearch/test/loggerusage/OpenSearchLoggerUsageTests.java index 5efc2eb4ff4..edccce70459 100644 --- a/test/logger-usage/src/test/java/org/opensearch/test/loggerusage/OpenSearchLoggerUsageTests.java +++ b/test/logger-usage/src/test/java/org/opensearch/test/loggerusage/OpenSearchLoggerUsageTests.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.util.Supplier; import org.opensearch.common.SuppressLoggerChecks; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.test.OpenSearchTestCase; -import org.opensearch.test.loggerusage.ESLoggerUsageChecker.WrongLoggerUsage; +import org.opensearch.test.loggerusage.OpenSearchLoggerUsageChecker.WrongLoggerUsage; import java.io.IOException; import java.io.InputStream; @@ -52,7 +52,7 @@ public class OpenSearchLoggerUsageTests extends OpenSearchTestCase { logger.info("Checking logger usage for method {}", method.getName()); InputStream classInputStream = getClass().getResourceAsStream(getClass().getSimpleName() + ".class"); List errors = new ArrayList<>(); - ESLoggerUsageChecker.check(errors::add, classInputStream, + OpenSearchLoggerUsageChecker.check(errors::add, classInputStream, m -> m.equals(method.getName()) || m.startsWith("lambda$" + method.getName())); if (method.getName().startsWith("checkFail")) { assertFalse("Expected " + method.getName() + " to have wrong Logger usage", errors.isEmpty()); @@ -68,7 +68,7 @@ public class OpenSearchLoggerUsageTests extends OpenSearchTestCase { public void testLoggerUsageCheckerCompatibilityWithLog4j2Logger() throws NoSuchMethodException { for (Method method : Logger.class.getMethods()) { - if (ESLoggerUsageChecker.LOGGER_METHODS.contains(method.getName())) { + if (OpenSearchLoggerUsageChecker.LOGGER_METHODS.contains(method.getName())) { assertThat(method.getParameterTypes().length, greaterThanOrEqualTo(1)); int markerOffset = method.getParameterTypes()[0].equals(Marker.class) ? 1 : 0; int paramLength = method.getParameterTypes().length - markerOffset; @@ -97,7 +97,7 @@ public class OpenSearchLoggerUsageTests extends OpenSearchTestCase { } } - for (String methodName : ESLoggerUsageChecker.LOGGER_METHODS) { + for (String methodName : OpenSearchLoggerUsageChecker.LOGGER_METHODS) { assertEquals(48, Stream.of(Logger.class.getMethods()).filter(m -> methodName.equals(m.getName())).count()); } diff --git a/test/logger-usage/src/test/java/org/opensearch/test/loggerusage/TestMessage.java b/test/logger-usage/src/test/java/org/opensearch/test/loggerusage/TestMessage.java index 000bb746736..1ee45ee11b1 100644 --- a/test/logger-usage/src/test/java/org/opensearch/test/loggerusage/TestMessage.java +++ b/test/logger-usage/src/test/java/org/opensearch/test/loggerusage/TestMessage.java @@ -22,7 +22,7 @@ package org.opensearch.test.loggerusage; import org.apache.logging.log4j.message.ParameterizedMessage; /** - * This class is for testing that ESLoggerUsageChecker can find incorrect usages of LogMessages + * This class is for testing that OpenSearchLoggerUsageChecker can find incorrect usages of LogMessages * which are subclasses of ParametrizedMessage * @see OpenSearchLoggerUsageTests */