Refactor test/logger-usage and test/external-modules as per OpenSearch naming conventions (#398)
Signed-off-by: Himanshu Setia <setiah@amazon.com>
This commit is contained in:
parent
bf4e3294c9
commit
d1e275c4e9
|
@ -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
|
||||
|
|
|
@ -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<Class<? extends Plugin>> nodePlugins() {
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
apply plugin: 'elasticsearch.java'
|
||||
apply plugin: 'opensearch.java'
|
||||
|
||||
dependencies {
|
||||
api 'org.ow2.asm:asm:7.1'
|
||||
|
|
|
@ -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. <code>TestMessage<code> is also declared here to
|
||||
// make sure this functionality works
|
||||
public static final Set<Type> 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
|
|
@ -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<WrongLoggerUsage> 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());
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ package org.opensearch.test.loggerusage;
|
|||
import org.apache.logging.log4j.message.ParameterizedMessage;
|
||||
|
||||
/**
|
||||
* This class is for testing that <code>ESLoggerUsageChecker</code> can find incorrect usages of LogMessages
|
||||
* This class is for testing that <code>OpenSearchLoggerUsageChecker</code> can find incorrect usages of LogMessages
|
||||
* which are subclasses of <code>ParametrizedMessage</code>
|
||||
* @see OpenSearchLoggerUsageTests
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue