From 2520b5a5e2aac83aecb156e1377278dee7772d1c Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Wed, 5 May 2021 11:22:06 +0300 Subject: [PATCH 01/17] build gradle file update for integ test Signed-off-by: AmiStrn --- build.gradle | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/build.gradle b/build.gradle index 0e34228..bbae354 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import org.opensearch.gradle.test.RestIntegTestTask + apply plugin: 'java' apply plugin: 'idea' apply plugin: 'opensearch.opensearchplugin' @@ -37,3 +39,62 @@ dependencies { // required for the yaml test to run yamlRestTestImplementation 'org.apache.logging.log4j:log4j-core:2.11.1' } + + +task integTest(type: RestIntegTestTask) { + description = "Run tests against a cluster" + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath +} +tasks.named("check").configure { dependsOn(integTest) } + +integTest { + // The 'doFirst' delays till execution time. + doFirst { + // Tell the test JVM if the cluster JVM is running under a debugger so that tests can + // use longer timeouts for requests. + def isDebuggingCluster = getDebug() || System.getProperty("test.debug") != null + systemProperty 'cluster.debug', isDebuggingCluster + // Set number of nodes system property to be used in tests + systemProperty 'cluster.number_of_nodes', "${_numNodes}" + // There seems to be an issue when running multi node run or integ tasks with unicast_hosts + // not being written, the waitForAllConditions ensures it's written + getClusters().forEach { cluster -> + cluster.waitForAllConditions() + } + } + + // The --debug-jvm command-line option makes the cluster debuggable; this makes the tests debuggable + if (System.getProperty("test.debug") != null) { + jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005' + } +} + +testClusters.integTest { + testDistribution = "ARCHIVE" + // Cluster shrink exception thrown if we try to set numberOfNodes to 1, so only apply if > 1 + + // When running integration tests it doesn't forward the --debug-jvm to the cluster anymore + // i.e. we have to use a custom property to flag when we want to debug elasticsearch JVM + // since we also support multi node integration tests we increase debugPort per node + if (System.getProperty("opensearch.debug") != null) { + def debugPort = 5005 + nodes.forEach { node -> + node.jvmArgs("-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=*:${debugPort}") + debugPort += 1 + } + } + plugin(project.tasks.bundlePlugin.archiveFile) +} + +run { + doFirst { + // There seems to be an issue when running multi node run or integ tasks with unicast_hosts + // not being written, the waitForAllConditions ensures it's written + getClusters().forEach { cluster -> + cluster.waitForAllConditions() + } + } + + useCluster testClusters.integTest +} \ No newline at end of file From cfaa20327238606ce14942310313744b583dfaa0 Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Wed, 5 May 2021 11:23:26 +0300 Subject: [PATCH 02/17] added integtest Signed-off-by: AmiStrn --- .../rest/action/HelloWorldPluginIT.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java diff --git a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java new file mode 100644 index 0000000..7ca924f --- /dev/null +++ b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java @@ -0,0 +1,30 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + + +package org.opensearch.rest.action; + +import org.opensearch.client.Request; +import org.opensearch.plugins.Plugin; +import org.opensearch.test.OpenSearchIntegTestCase; + +import java.io.IOException; +import java.util.Collection; +import java.util.Collections; + +public class HelloWorldPluginIT extends OpenSearchIntegTestCase { + + @Override + protected Collection> nodePlugins() { + return Collections.singletonList(HelloWorldPlugin.class); + } + + public void testPluginExists() throws IOException { + createRestClient().performRequest(new Request("GET", "/_cat/plugins")); + } +} \ No newline at end of file From 62089b05fef19d98f43a000a07aab3795d67a278 Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Wed, 5 May 2021 14:48:17 +0300 Subject: [PATCH 03/17] added integtest Signed-off-by: AmiStrn --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index bbae354..0f45670 100644 --- a/build.gradle +++ b/build.gradle @@ -56,7 +56,7 @@ integTest { def isDebuggingCluster = getDebug() || System.getProperty("test.debug") != null systemProperty 'cluster.debug', isDebuggingCluster // Set number of nodes system property to be used in tests - systemProperty 'cluster.number_of_nodes', "${_numNodes}" + systemProperty 'cluster.number_of_nodes', "1" // There seems to be an issue when running multi node run or integ tasks with unicast_hosts // not being written, the waitForAllConditions ensures it's written getClusters().forEach { cluster -> From bd47bb2cf1fcb960b765e07d4cf590de0351a37f Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Sat, 8 May 2021 22:48:07 +0300 Subject: [PATCH 04/17] adding integtest Signed-off-by: AmiStrn --- .../java/org/opensearch/rest/action/HelloWorldPluginIT.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java index 7ca924f..6363032 100644 --- a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java +++ b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java @@ -9,7 +9,9 @@ package org.opensearch.rest.action; +import org.apache.http.util.EntityUtils; import org.opensearch.client.Request; +import org.opensearch.client.Response; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchIntegTestCase; @@ -25,6 +27,7 @@ protected Collection> nodePlugins() { } public void testPluginExists() throws IOException { - createRestClient().performRequest(new Request("GET", "/_cat/plugins")); + Response response = createRestClient().performRequest(new Request("GET", "/_cat/plugins")); + logger.info("response body: {}", EntityUtils.toString(response.getEntity())); } } \ No newline at end of file From 13615fd01958d349b1da778d64a8f015083c4c55 Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Sat, 8 May 2021 22:56:47 +0300 Subject: [PATCH 05/17] added cluster scope Signed-off-by: AmiStrn --- src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java index 6363032..c8a951f 100644 --- a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java +++ b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java @@ -19,6 +19,7 @@ import java.util.Collection; import java.util.Collections; +@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0) public class HelloWorldPluginIT extends OpenSearchIntegTestCase { @Override From 37e8e667d50603c42e62524374afc75ac9257dd8 Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Sat, 8 May 2021 22:59:49 +0300 Subject: [PATCH 06/17] added cluster scope Signed-off-by: AmiStrn --- .../java/org/opensearch/rest/action/HelloWorldPluginIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java index c8a951f..206dc8f 100644 --- a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java +++ b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java @@ -19,7 +19,7 @@ import java.util.Collection; import java.util.Collections; -@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0) +@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.SUITE) public class HelloWorldPluginIT extends OpenSearchIntegTestCase { @Override From 71555cb94a80c2a741fdc72485bab1db69828201 Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Sat, 8 May 2021 23:03:08 +0300 Subject: [PATCH 07/17] added cluster scope Signed-off-by: AmiStrn --- .../java/org/opensearch/rest/action/HelloWorldPluginIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java index 206dc8f..56b7ec2 100644 --- a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java +++ b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java @@ -28,7 +28,7 @@ protected Collection> nodePlugins() { } public void testPluginExists() throws IOException { - Response response = createRestClient().performRequest(new Request("GET", "/_cat/plugins")); - logger.info("response body: {}", EntityUtils.toString(response.getEntity())); + Response response = createRestClient().performRequest(new Request("GET", "/hello-world")); + logger.info("=====================> response body: {}", EntityUtils.toString(response.getEntity())); } } \ No newline at end of file From 8c12f4152e934350b97fa8e8e3bae4b61c74ef92 Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Sat, 8 May 2021 23:05:42 +0300 Subject: [PATCH 08/17] added cluster scope Signed-off-by: AmiStrn --- .../java/org/opensearch/rest/action/HelloWorldPluginIT.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java index 56b7ec2..8d1f82d 100644 --- a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java +++ b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java @@ -9,6 +9,7 @@ package org.opensearch.rest.action; +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; import org.apache.http.util.EntityUtils; import org.opensearch.client.Request; import org.opensearch.client.Response; @@ -19,6 +20,7 @@ import java.util.Collection; import java.util.Collections; +@ThreadLeakScope(ThreadLeakScope.Scope.NONE) @OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.SUITE) public class HelloWorldPluginIT extends OpenSearchIntegTestCase { From fe391e62c817c5b31d1a3fed7b9da49d03411ed8 Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Sat, 8 May 2021 23:17:19 +0300 Subject: [PATCH 09/17] added more tests Signed-off-by: AmiStrn --- .../rest/action/HelloWorldPluginIT.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java index 8d1f82d..d3ec36f 100644 --- a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java +++ b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java @@ -19,6 +19,11 @@ import java.io.IOException; import java.util.Collection; import java.util.Collections; +import java.util.Map; + +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; @ThreadLeakScope(ThreadLeakScope.Scope.NONE) @OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.SUITE) @@ -29,8 +34,23 @@ protected Collection> nodePlugins() { return Collections.singletonList(HelloWorldPlugin.class); } - public void testPluginExists() throws IOException { + public void testPluginInstalled() throws IOException { + Response response = createRestClient().performRequest(new Request("GET", "/_cat/plugins")); + logger.info("response body: {}", EntityUtils.toString(response.getEntity())); + assertThat(EntityUtils.toString(response.getEntity()), containsString("my-rest-plugin")); + } + + public void testPluginIsWorkingNoValue() throws IOException { Response response = createRestClient().performRequest(new Request("GET", "/hello-world")); - logger.info("=====================> response body: {}", EntityUtils.toString(response.getEntity())); + logger.info("response body: {}", EntityUtils.toString(response.getEntity())); + assertThat(EntityUtils.toString(response.getEntity()), equalTo("Hi! Your plugin is installed and working:)")); + } + + public void testPluginIsWorkingWithValue() throws IOException { + Request request = new Request("POST", "/hello-world"); + request.addParameters(Map.of("name", "amitai")); + Response response = createRestClient().performRequest(request); + logger.info("response body: {}", EntityUtils.toString(response.getEntity())); + assertThat(EntityUtils.toString(response.getEntity()), equalTo("Hi amitai! Your plugin is installed and working:)")); } } \ No newline at end of file From b8d2de1809903a73fd1353662c215bbc4605a496 Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Sat, 8 May 2021 23:17:36 +0300 Subject: [PATCH 10/17] added more tests Signed-off-by: AmiStrn --- .idea/misc.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 66be9e9..cf84f10 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file From 8a76bb10f6395b7ac73f69a74b3b301464913e22 Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Sat, 8 May 2021 23:24:54 +0300 Subject: [PATCH 11/17] added more tests Signed-off-by: AmiStrn --- .../opensearch/rest/action/HelloWorldPluginIT.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java index d3ec36f..7d51c16 100644 --- a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java +++ b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java @@ -10,6 +10,8 @@ package org.opensearch.rest.action; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; +import org.apache.http.entity.ContentType; +import org.apache.http.nio.entity.NStringEntity; import org.apache.http.util.EntityUtils; import org.opensearch.client.Request; import org.opensearch.client.Response; @@ -19,9 +21,7 @@ import java.io.IOException; import java.util.Collection; import java.util.Collections; -import java.util.Map; -import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; @@ -48,9 +48,14 @@ public void testPluginIsWorkingNoValue() throws IOException { public void testPluginIsWorkingWithValue() throws IOException { Request request = new Request("POST", "/hello-world"); - request.addParameters(Map.of("name", "amitai")); + request.setEntity( + new NStringEntity( + "{\"name\":\"Amitai\"}", + ContentType.APPLICATION_JSON + ) + ); Response response = createRestClient().performRequest(request); logger.info("response body: {}", EntityUtils.toString(response.getEntity())); - assertThat(EntityUtils.toString(response.getEntity()), equalTo("Hi amitai! Your plugin is installed and working:)")); + assertThat(EntityUtils.toString(response.getEntity()), equalTo("Hi Amitai! Your plugin is installed and working:)")); } } \ No newline at end of file From 5ba2bf3327f8678ee04009341a849bc59f6a89ae Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Sat, 8 May 2021 23:31:18 +0300 Subject: [PATCH 12/17] only test installed Signed-off-by: AmiStrn --- .../rest/action/HelloWorldPluginIT.java | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java index 7d51c16..1138a8c 100644 --- a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java +++ b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java @@ -39,23 +39,4 @@ public void testPluginInstalled() throws IOException { logger.info("response body: {}", EntityUtils.toString(response.getEntity())); assertThat(EntityUtils.toString(response.getEntity()), containsString("my-rest-plugin")); } - - public void testPluginIsWorkingNoValue() throws IOException { - Response response = createRestClient().performRequest(new Request("GET", "/hello-world")); - logger.info("response body: {}", EntityUtils.toString(response.getEntity())); - assertThat(EntityUtils.toString(response.getEntity()), equalTo("Hi! Your plugin is installed and working:)")); - } - - public void testPluginIsWorkingWithValue() throws IOException { - Request request = new Request("POST", "/hello-world"); - request.setEntity( - new NStringEntity( - "{\"name\":\"Amitai\"}", - ContentType.APPLICATION_JSON - ) - ); - Response response = createRestClient().performRequest(request); - logger.info("response body: {}", EntityUtils.toString(response.getEntity())); - assertThat(EntityUtils.toString(response.getEntity()), equalTo("Hi Amitai! Your plugin is installed and working:)")); - } } \ No newline at end of file From 72bbbfde510dd4bc419f621b75758ddb012378d0 Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Sat, 8 May 2021 23:31:30 +0300 Subject: [PATCH 13/17] only test installed Signed-off-by: AmiStrn --- src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java index 1138a8c..e4ce98c 100644 --- a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java +++ b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java @@ -23,7 +23,6 @@ import java.util.Collections; import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.equalTo; @ThreadLeakScope(ThreadLeakScope.Scope.NONE) @OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.SUITE) From c1683b23656cc4a52b2c68a96f63e387a01db998 Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Sat, 8 May 2021 23:32:57 +0300 Subject: [PATCH 14/17] only test installed Signed-off-by: AmiStrn --- .idea/misc.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index cf84f10..66be9e9 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file From 4f4e9b5560415322c375d393f65de42aebce06e9 Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Sat, 8 May 2021 23:35:06 +0300 Subject: [PATCH 15/17] only test installed Signed-off-by: AmiStrn --- .../java/org/opensearch/rest/action/HelloWorldPluginIT.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java index e4ce98c..69eb394 100644 --- a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java +++ b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java @@ -35,7 +35,8 @@ protected Collection> nodePlugins() { public void testPluginInstalled() throws IOException { Response response = createRestClient().performRequest(new Request("GET", "/_cat/plugins")); - logger.info("response body: {}", EntityUtils.toString(response.getEntity())); - assertThat(EntityUtils.toString(response.getEntity()), containsString("my-rest-plugin")); + String body = EntityUtils.toString(response.getEntity()); + logger.info("response body: {}", body); + assertThat(body, containsString("my-rest-plugin")); } } \ No newline at end of file From 597f61296352f152e4f592d9500048f37f5a2800 Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Sat, 8 May 2021 23:37:36 +0300 Subject: [PATCH 16/17] test the endpoint too Signed-off-by: AmiStrn --- .../rest/action/HelloWorldPluginIT.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java index 69eb394..59a8127 100644 --- a/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java +++ b/src/test/java/org/opensearch/rest/action/HelloWorldPluginIT.java @@ -23,6 +23,7 @@ import java.util.Collections; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; @ThreadLeakScope(ThreadLeakScope.Scope.NONE) @OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.SUITE) @@ -36,7 +37,31 @@ protected Collection> nodePlugins() { public void testPluginInstalled() throws IOException { Response response = createRestClient().performRequest(new Request("GET", "/_cat/plugins")); String body = EntityUtils.toString(response.getEntity()); + logger.info("response body: {}", body); assertThat(body, containsString("my-rest-plugin")); } + + public void testPluginIsWorkingNoValue() throws IOException { + Response response = createRestClient().performRequest(new Request("GET", "/hello-world")); + String body = EntityUtils.toString(response.getEntity()); + + logger.info("response body: {}", body); + assertThat(body, equalTo("Hi! Your plugin is installed and working:)")); + } + + public void testPluginIsWorkingWithValue() throws IOException { + Request request = new Request("POST", "/hello-world"); + request.setEntity( + new NStringEntity( + "{\"name\":\"Amitai\"}", + ContentType.APPLICATION_JSON + ) + ); + Response response = createRestClient().performRequest(request); + String body = EntityUtils.toString(response.getEntity()); + + logger.info("response body: {}", body); + assertThat(body, equalTo("Hi Amitai! Your plugin is installed and working:)")); + } } \ No newline at end of file From 654227d902f635dfbfbd97efd49bcceab55bbbd2 Mon Sep 17 00:00:00 2001 From: AmiStrn Date: Wed, 19 May 2021 17:16:47 +0300 Subject: [PATCH 17/17] cleanup build.gradle Signed-off-by: AmiStrn --- build.gradle | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 0f45670..bff9ba7 100644 --- a/build.gradle +++ b/build.gradle @@ -14,12 +14,21 @@ opensearchplugin { } -// disabling some unnecessary validations for this plugin +// Allow test cases to be named Tests without having to be inherited from LuceneTestCase. +// see https://github.com/elastic/elasticsearch/blob/323f312bbc829a63056a79ebe45adced5099f6e6/buildSrc/src/main/java/org/elasticsearch/gradle/precommit/TestingConventionsTasks.java testingConventions.enabled = false + +licenseHeaders.enabled = true +dependencyLicenses.enabled = false +thirdPartyAudit.enabled = false loggerUsageCheck.enabled = false -validateNebulaPom.enabled = false buildscript { + ext { + opensearch_group = "org.opensearch" + opensearch_version = System.getProperty("opensearch.version", "1.0.0-beta1") + } + repositories { mavenCentral() jcenter() @@ -27,7 +36,7 @@ buildscript { } dependencies { - classpath "org.opensearch.gradle:build-tools:1.0.0-beta1" + classpath "${opensearch_group}.gradle:build-tools:${opensearch_version}" } } @@ -40,6 +49,13 @@ dependencies { yamlRestTestImplementation 'org.apache.logging.log4j:log4j-core:2.11.1' } +test { + include '**/*Tests.class' + systemProperty 'tests.security.manager', 'false' +} + +// See package README.md for details on using these tasks. +def _numNodes = findProperty('numNodes') as Integer ?: 1 task integTest(type: RestIntegTestTask) { description = "Run tests against a cluster" @@ -56,7 +72,7 @@ integTest { def isDebuggingCluster = getDebug() || System.getProperty("test.debug") != null systemProperty 'cluster.debug', isDebuggingCluster // Set number of nodes system property to be used in tests - systemProperty 'cluster.number_of_nodes', "1" + systemProperty 'cluster.number_of_nodes', "${_numNodes}" // There seems to be an issue when running multi node run or integ tasks with unicast_hosts // not being written, the waitForAllConditions ensures it's written getClusters().forEach { cluster -> @@ -71,9 +87,7 @@ integTest { } testClusters.integTest { - testDistribution = "ARCHIVE" - // Cluster shrink exception thrown if we try to set numberOfNodes to 1, so only apply if > 1 - + testDistribution = "INTEG_TEST" // When running integration tests it doesn't forward the --debug-jvm to the cluster anymore // i.e. we have to use a custom property to flag when we want to debug elasticsearch JVM // since we also support multi node integration tests we increase debugPort per node