From ad5c75c53ffe996cda6a5913551e25ef1a8aae88 Mon Sep 17 00:00:00 2001 From: Atharva Sharma Date: Tue, 30 Jan 2024 17:21:44 +0530 Subject: [PATCH 1/3] Added integration test to validate cluster health after adding both the Telemetry plugin and Security plugin Signed-off-by: Atharva Sharma --- build.gradle | 1 + src/index.js | 0 .../TelemetryPluginIntegrationTests.java | 39 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 src/index.js create mode 100644 src/integrationTest/java/org/opensearch/security/TelemetryPluginIntegrationTests.java diff --git a/build.gradle b/build.gradle index db7af24910..f9398b8a5c 100644 --- a/build.gradle +++ b/build.gradle @@ -574,6 +574,7 @@ check.dependsOn integrationTest dependencies { implementation "org.opensearch.plugin:transport-netty4-client:${opensearch_version}" + implementation "org.opensearch.plugin:telemetry-otel-client:${opensearch_version}" implementation "org.opensearch.client:opensearch-rest-high-level-client:${opensearch_version}" implementation "org.apache.httpcomponents.client5:httpclient5-cache:${versions.httpclient5}" implementation "org.apache.httpcomponents:httpclient:${versions.httpclient}" diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/integrationTest/java/org/opensearch/security/TelemetryPluginIntegrationTests.java b/src/integrationTest/java/org/opensearch/security/TelemetryPluginIntegrationTests.java new file mode 100644 index 0000000000..fbd26354c4 --- /dev/null +++ b/src/integrationTest/java/org/opensearch/security/TelemetryPluginIntegrationTests.java @@ -0,0 +1,39 @@ +package org.opensearch.security; + +import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; + +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.opensearch.test.framework.TestSecurityConfig; +import org.opensearch.test.framework.cluster.ClusterManager; +import org.opensearch.test.framework.cluster.LocalCluster; +import org.opensearch.test.framework.cluster.TestRestClient; + +import org.opensearch.telemetry.OTelTelemetryPlugin; +import static org.apache.http.HttpStatus.SC_OK; +import static org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.*; +import static org.opensearch.test.framework.TestSecurityConfig.Role.ALL_ACCESS; + +@RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class) +@ThreadLeakScope(ThreadLeakScope.Scope.NONE) +public class TelemetryPluginIntegrationTests { + static final TestSecurityConfig.User TEST_USER = new TestSecurityConfig.User("test_user").password("s3cret").roles(ALL_ACCESS); + + @ClassRule + public static LocalCluster cluster = new LocalCluster.Builder().clusterManager(ClusterManager.SINGLENODE) + .anonymousAuth(false) + .authc(AUTHC_HTTPBASIC_INTERNAL) + .users(TEST_USER) + .plugin(OTelTelemetryPlugin.class) + .build(); + + @Test + public void clusterShouldComeUpHealthy() { + try (TestRestClient client = cluster.getRestClient(TEST_USER)) { + final TestRestClient.HttpResponse response = client.get("_cat/indices"); + response.assertStatusCode(SC_OK); + } + } +} From c8591596c09b8bd2c6bf661f65ac4ffb2159a6fb Mon Sep 17 00:00:00 2001 From: Atharva Sharma <60044988+atharvasharma61@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:30:36 +0530 Subject: [PATCH 2/3] Deleted src/index.js Signed-off-by: Atharva Sharma <60044988+atharvasharma61@users.noreply.github.com> --- src/index.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/index.js diff --git a/src/index.js b/src/index.js deleted file mode 100644 index e69de29bb2..0000000000 From 890599a353a7d0b806c3dec7cbf54b6da04d2444 Mon Sep 17 00:00:00 2001 From: Atharva Sharma Date: Tue, 19 Mar 2024 13:01:23 +0530 Subject: [PATCH 3/3] Changed the otel plugin dependency import kind Signed-off-by: Atharva Sharma --- build.gradle | 2 +- .../security/TelemetryPluginIntegrationTests.java | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index dd2c1506d0..18cf5316a5 100644 --- a/build.gradle +++ b/build.gradle @@ -574,7 +574,6 @@ check.dependsOn integrationTest dependencies { implementation "org.opensearch.plugin:transport-netty4-client:${opensearch_version}" - implementation "org.opensearch.plugin:telemetry-otel-client:${opensearch_version}" implementation "org.opensearch.client:opensearch-rest-high-level-client:${opensearch_version}" implementation "org.apache.httpcomponents.client5:httpclient5-cache:${versions.httpclient5}" implementation "org.apache.httpcomponents:httpclient:${versions.httpclient}" @@ -726,6 +725,7 @@ dependencies { integrationTestImplementation 'junit:junit:4.13.2' integrationTestImplementation "org.opensearch.plugin:reindex-client:${opensearch_version}" integrationTestImplementation "org.opensearch.plugin:percolator-client:${opensearch_version}" + integrationTestImplementation "org.opensearch.plugin:telemetry-otel-client:${opensearch_version}" integrationTestImplementation 'commons-io:commons-io:2.15.1' integrationTestImplementation "org.apache.logging.log4j:log4j-core:${versions.log4j}" integrationTestImplementation "org.apache.logging.log4j:log4j-jul:${versions.log4j}" diff --git a/src/integrationTest/java/org/opensearch/security/TelemetryPluginIntegrationTests.java b/src/integrationTest/java/org/opensearch/security/TelemetryPluginIntegrationTests.java index fbd26354c4..91d8caa88e 100644 --- a/src/integrationTest/java/org/opensearch/security/TelemetryPluginIntegrationTests.java +++ b/src/integrationTest/java/org/opensearch/security/TelemetryPluginIntegrationTests.java @@ -1,17 +1,16 @@ package org.opensearch.security; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; - import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; +import org.opensearch.telemetry.OTelTelemetryPlugin; import org.opensearch.test.framework.TestSecurityConfig; import org.opensearch.test.framework.cluster.ClusterManager; import org.opensearch.test.framework.cluster.LocalCluster; import org.opensearch.test.framework.cluster.TestRestClient; -import org.opensearch.telemetry.OTelTelemetryPlugin; import static org.apache.http.HttpStatus.SC_OK; import static org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.*; import static org.opensearch.test.framework.TestSecurityConfig.Role.ALL_ACCESS; @@ -23,11 +22,11 @@ public class TelemetryPluginIntegrationTests { @ClassRule public static LocalCluster cluster = new LocalCluster.Builder().clusterManager(ClusterManager.SINGLENODE) - .anonymousAuth(false) - .authc(AUTHC_HTTPBASIC_INTERNAL) - .users(TEST_USER) - .plugin(OTelTelemetryPlugin.class) - .build(); + .anonymousAuth(false) + .authc(AUTHC_HTTPBASIC_INTERNAL) + .users(TEST_USER) + .plugin(OTelTelemetryPlugin.class) + .build(); @Test public void clusterShouldComeUpHealthy() {