diff --git a/plugins-it/elasticsearch-7.16-it/pom.xml b/plugins-it/elasticsearch-7.16-it/pom.xml index 12a793449cb2..670e5dfaaadf 100644 --- a/plugins-it/elasticsearch-7.16-it/pom.xml +++ b/plugins-it/elasticsearch-7.16-it/pom.xml @@ -41,9 +41,9 @@ test - pl.allegro.tech - embedded-elasticsearch - 2.10.0 + org.testcontainers + elasticsearch + ${testcontainers.version} test diff --git a/plugins-it/elasticsearch-7.16-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ESServerContainerFactory.java b/plugins-it/elasticsearch-7.16-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ESServerContainerFactory.java new file mode 100644 index 000000000000..fd1c3c7a67fe --- /dev/null +++ b/plugins-it/elasticsearch-7.16-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ESServerContainerFactory.java @@ -0,0 +1,25 @@ +package com.navercorp.pinpoint.plugin.elasticsearch; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.testcontainers.containers.output.OutputFrame; +import org.testcontainers.elasticsearch.ElasticsearchContainer; + +import java.util.function.Consumer; + +public class ESServerContainerFactory { + + public static final int DEFAULT_PORT = 9200; + + public static ElasticsearchContainer newESServerContainerFactory(String loggerName) { + ElasticsearchContainer elasticsearchContainer = new ElasticsearchContainer(); + elasticsearchContainer.withLogConsumer(new Consumer() { + private final Logger logger = LogManager.getLogger(loggerName); + @Override + public void accept(OutputFrame outputFrame) { + logger.info(outputFrame.getUtf8String()); + } + }); + return elasticsearchContainer; + } +} diff --git a/plugins-it/elasticsearch-7.16-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchITBase.java b/plugins-it/elasticsearch-7.16-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchITBase.java index 90b4ab6d26cd..68adc411ad13 100644 --- a/plugins-it/elasticsearch-7.16-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchITBase.java +++ b/plugins-it/elasticsearch-7.16-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchITBase.java @@ -17,18 +17,11 @@ import com.navercorp.pinpoint.test.plugin.shared.AfterSharedClass; import com.navercorp.pinpoint.test.plugin.shared.BeforeSharedClass; - -import org.apache.http.HttpHost; -import org.elasticsearch.client.RestClient; -import org.elasticsearch.client.RestHighLevelClient; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import pl.allegro.tech.embeddedelasticsearch.EmbeddedElastic; -import pl.allegro.tech.embeddedelasticsearch.PopularProperties; - -import java.io.IOException; - -import static java.util.concurrent.TimeUnit.MINUTES; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.Assume; +import org.testcontainers.DockerClientFactory; +import org.testcontainers.elasticsearch.ElasticsearchContainer; /** * @author Roy Kim @@ -36,41 +29,56 @@ public abstract class ElasticsearchITBase { - public static EmbeddedElastic embeddedElastic; - public static RestHighLevelClient restHighLevelClient; + protected static final Logger logger = LogManager.getLogger(ElasticsearchITBase.class); - public static String ELASTICSEARCH_ADDRESS = "127.0.0.1:" + 9200; + public static ElasticsearchContainer elasticsearchContainer; - @BeforeSharedClass - public static void sharedSetUp() throws Exception { - embeddedElastic = EmbeddedElastic.builder() - .withElasticVersion("6.8.0") - .withSetting(PopularProperties.HTTP_PORT, 9200) - .withEsJavaOpts("-Xms128m -Xmx512m") - .withStartTimeout(2, MINUTES) - .build() - .start(); + protected static int SERVER_PORT; + protected static String SERVER_HOST; + protected static String ELASTICSEARCH_ADDRESS; + public static int getServerPort() { + return SERVER_PORT; } - @BeforeClass - public static void setup() throws IOException { - restHighLevelClient = new RestHighLevelClient( - RestClient.builder( - new HttpHost("127.0.0.1", 9200, "http"))); + public static void setServerPort(int serverPort) { + SERVER_PORT = serverPort; } - @AfterClass - public static void tearDown() throws IOException { - if (restHighLevelClient == null) { - restHighLevelClient.close(); - } + public static String getServerHost() { + return SERVER_HOST; + } + + public static void setServerHost(String serverHost) { + SERVER_HOST = serverHost; + } + + public static String getElasticsearchAddress() { + return ELASTICSEARCH_ADDRESS; + } + + public static void setElasticsearchAddress(String elasticsearchAddress) { + ELASTICSEARCH_ADDRESS = elasticsearchAddress; + } + + @BeforeSharedClass + public static void sharedSetUp() { + Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); + + elasticsearchContainer = ESServerContainerFactory.newESServerContainerFactory(logger.getName()); + elasticsearchContainer.start(); + + setServerPort(elasticsearchContainer.getMappedPort(ESServerContainerFactory.DEFAULT_PORT)); + setServerHost(elasticsearchContainer.getHost()); + setElasticsearchAddress(elasticsearchContainer.getHttpHostAddress()); + } @AfterSharedClass - public static void sharedTearDown() throws IOException { - if (embeddedElastic != null) - embeddedElastic.stop(); + public static void sharedTearDown() { + if (elasticsearchContainer != null) { + elasticsearchContainer.stop(); + } } } diff --git a/plugins-it/elasticsearch-7.16-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_7_16_x_IT.java b/plugins-it/elasticsearch-7.16-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_7_16_x_IT.java index 0047e88ecc03..3e5d03366778 100644 --- a/plugins-it/elasticsearch-7.16-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_7_16_x_IT.java +++ b/plugins-it/elasticsearch-7.16-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_7_16_x_IT.java @@ -20,13 +20,19 @@ import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier; import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifierHolder; import com.navercorp.pinpoint.pluginit.utils.AgentPath; +import com.navercorp.pinpoint.pluginit.utils.TestcontainersOption; import com.navercorp.pinpoint.test.plugin.Dependency; import com.navercorp.pinpoint.test.plugin.JvmVersion; import com.navercorp.pinpoint.test.plugin.PinpointAgent; import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite; +import org.apache.http.HttpHost; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.client.RestClient; +import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.xcontent.XContentType; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -37,11 +43,27 @@ @RunWith(PinpointPluginTestSuite.class) @PinpointAgent(AgentPath.PATH) -@Dependency({"org.elasticsearch.client:elasticsearch-rest-high-level-client:[7.16.0,]", - "pl.allegro.tech:embedded-elasticsearch:2.10.0"}) +@Dependency({"org.elasticsearch.client:elasticsearch-rest-high-level-client:[7.16.0,7.max]", + TestcontainersOption.ELASTICSEARCH}) @JvmVersion(8) public class ElasticsearchIT_7_16_x_IT extends ElasticsearchITBase { + private static RestHighLevelClient restHighLevelClient; + + @Before + public void setup() { + restHighLevelClient = new RestHighLevelClient( + RestClient.builder( + new HttpHost(getServerHost(), getServerPort(), "http"))); + } + + @After + public void tearDown() throws IOException { + if (restHighLevelClient != null) { + restHighLevelClient.close(); + } + } + @Test public void testHighLevelClient() throws Exception { @@ -53,8 +75,7 @@ public void testHighLevelClient() throws Exception { private void testIndexV70UP(PluginTestVerifier verifier) throws IOException { - IndexRequest indexRequest = new IndexRequest( - "post2"); + IndexRequest indexRequest = new IndexRequest("post2"); indexRequest.id("1"); String jsonString = "{" + diff --git a/plugins-it/elasticsearch-it/pom.xml b/plugins-it/elasticsearch-it/pom.xml index d936d00b19d4..afa710af18be 100644 --- a/plugins-it/elasticsearch-it/pom.xml +++ b/plugins-it/elasticsearch-it/pom.xml @@ -40,9 +40,9 @@ test - pl.allegro.tech - embedded-elasticsearch - 2.10.0 + org.testcontainers + elasticsearch + ${testcontainers.version} test diff --git a/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ESServerContainerFactory.java b/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ESServerContainerFactory.java new file mode 100644 index 000000000000..fd1c3c7a67fe --- /dev/null +++ b/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ESServerContainerFactory.java @@ -0,0 +1,25 @@ +package com.navercorp.pinpoint.plugin.elasticsearch; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.testcontainers.containers.output.OutputFrame; +import org.testcontainers.elasticsearch.ElasticsearchContainer; + +import java.util.function.Consumer; + +public class ESServerContainerFactory { + + public static final int DEFAULT_PORT = 9200; + + public static ElasticsearchContainer newESServerContainerFactory(String loggerName) { + ElasticsearchContainer elasticsearchContainer = new ElasticsearchContainer(); + elasticsearchContainer.withLogConsumer(new Consumer() { + private final Logger logger = LogManager.getLogger(loggerName); + @Override + public void accept(OutputFrame outputFrame) { + logger.info(outputFrame.getUtf8String()); + } + }); + return elasticsearchContainer; + } +} diff --git a/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchITBase.java b/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchITBase.java index 90b4ab6d26cd..c63cb18bbb56 100644 --- a/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchITBase.java +++ b/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchITBase.java @@ -17,18 +17,11 @@ import com.navercorp.pinpoint.test.plugin.shared.AfterSharedClass; import com.navercorp.pinpoint.test.plugin.shared.BeforeSharedClass; - -import org.apache.http.HttpHost; -import org.elasticsearch.client.RestClient; -import org.elasticsearch.client.RestHighLevelClient; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import pl.allegro.tech.embeddedelasticsearch.EmbeddedElastic; -import pl.allegro.tech.embeddedelasticsearch.PopularProperties; - -import java.io.IOException; - -import static java.util.concurrent.TimeUnit.MINUTES; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.Assume; +import org.testcontainers.DockerClientFactory; +import org.testcontainers.elasticsearch.ElasticsearchContainer; /** * @author Roy Kim @@ -36,41 +29,58 @@ public abstract class ElasticsearchITBase { - public static EmbeddedElastic embeddedElastic; - public static RestHighLevelClient restHighLevelClient; + protected static final Logger logger = LogManager.getLogger(ElasticsearchITBase.class); - public static String ELASTICSEARCH_ADDRESS = "127.0.0.1:" + 9200; + public static ElasticsearchContainer elasticsearchContainer; - @BeforeSharedClass - public static void sharedSetUp() throws Exception { - embeddedElastic = EmbeddedElastic.builder() - .withElasticVersion("6.8.0") - .withSetting(PopularProperties.HTTP_PORT, 9200) - .withEsJavaOpts("-Xms128m -Xmx512m") - .withStartTimeout(2, MINUTES) - .build() - .start(); + protected static int SERVER_PORT; + protected static String SERVER_HOST; + protected static String ELASTICSEARCH_ADDRESS; + + public static int getServerPort() { + return SERVER_PORT; } - @BeforeClass - public static void setup() throws IOException { - restHighLevelClient = new RestHighLevelClient( - RestClient.builder( - new HttpHost("127.0.0.1", 9200, "http"))); + public static void setServerPort(int serverPort) { + SERVER_PORT = serverPort; } - @AfterClass - public static void tearDown() throws IOException { - if (restHighLevelClient == null) { - restHighLevelClient.close(); - } + public static String getServerHost() { + return SERVER_HOST; + } + + public static void setServerHost(String serverHost) { + SERVER_HOST = serverHost; + } + + public static String getElasticsearchAddress() { + return ELASTICSEARCH_ADDRESS; + } + + public static void setElasticsearchAddress(String elasticsearchAddress) { + ELASTICSEARCH_ADDRESS = elasticsearchAddress; + } + + @BeforeSharedClass + public static void sharedSetUp() { + Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); + + elasticsearchContainer = ESServerContainerFactory.newESServerContainerFactory(logger.getName()); + elasticsearchContainer.start(); + + setServerPort(elasticsearchContainer.getMappedPort(ESServerContainerFactory.DEFAULT_PORT)); + setServerHost(elasticsearchContainer.getHost()); + setElasticsearchAddress(elasticsearchContainer.getHttpHostAddress()); + } @AfterSharedClass - public static void sharedTearDown() throws IOException { - if (embeddedElastic != null) - embeddedElastic.stop(); + public static void sharedTearDown() { + if (elasticsearchContainer != null) { + elasticsearchContainer.stop(); + } } + } diff --git a/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_6_0_x_IT.java b/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_6_0_x_IT.java index ba0acc02e1d7..ae9234c70c85 100644 --- a/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_6_0_x_IT.java +++ b/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_6_0_x_IT.java @@ -19,13 +19,19 @@ import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier; import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifierHolder; import com.navercorp.pinpoint.pluginit.utils.AgentPath; +import com.navercorp.pinpoint.pluginit.utils.TestcontainersOption; import com.navercorp.pinpoint.test.plugin.Dependency; import com.navercorp.pinpoint.test.plugin.JvmVersion; import com.navercorp.pinpoint.test.plugin.PinpointAgent; import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite; import org.apache.http.Header; +import org.apache.http.HttpHost; import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.client.RestClient; +import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.common.xcontent.XContentType; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -38,10 +44,26 @@ @RunWith(PinpointPluginTestSuite.class) @PinpointAgent(AgentPath.PATH) @Dependency({"org.elasticsearch.client:elasticsearch-rest-high-level-client:[6.0.0,6.3.0)", - "pl.allegro.tech:embedded-elasticsearch:2.8.0"}) + TestcontainersOption.ELASTICSEARCH}) @JvmVersion(8) public class ElasticsearchIT_6_0_x_IT extends ElasticsearchITBase { + private static RestHighLevelClient restHighLevelClient; + + @Before + public void setup() { + restHighLevelClient = new RestHighLevelClient( + RestClient.builder( + new HttpHost(getServerHost(), getServerPort(), "http"))); + } + + @After + public void tearDown() throws IOException { + if (restHighLevelClient != null) { + restHighLevelClient.close(); + } + } + @Test public void testCRUD() throws Exception { @@ -52,8 +74,7 @@ public void testCRUD() throws Exception { private void testIndexV60UP(PluginTestVerifier verifier) throws IOException { - IndexRequest indexRequest = new IndexRequest( - "postv6", "doc", "3"); + IndexRequest indexRequest = new IndexRequest("postv6", "doc", "3"); String jsonString = "{" + "\"user\":\"kimchy\"," + @@ -89,7 +110,7 @@ private void testIndexV60UP(PluginTestVerifier verifier) throws IOException { throw new AssertionError(e); } - verifier.verifyTrace(event(ElasticsearchConstants.ELASTICSEARCH_EXECUTOR.getName(), index, null, ELASTICSEARCH_ADDRESS, "ElasticSearch" + verifier.verifyTrace(event(ElasticsearchConstants.ELASTICSEARCH_EXECUTOR.getName(), index, null, getElasticsearchAddress(), "ElasticSearch" , new ExpectedAnnotation(ElasticsearchConstants.ARGS_DSL_ANNOTATION_KEY.getName(), indexRequest.toString()) )); } diff --git a/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_6_4_x_IT.java b/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_6_4_x_IT.java index 1633c999f7c4..4dd1361b55f9 100644 --- a/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_6_4_x_IT.java +++ b/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_6_4_x_IT.java @@ -19,13 +19,19 @@ import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier; import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifierHolder; import com.navercorp.pinpoint.pluginit.utils.AgentPath; +import com.navercorp.pinpoint.pluginit.utils.TestcontainersOption; import com.navercorp.pinpoint.test.plugin.Dependency; import com.navercorp.pinpoint.test.plugin.JvmVersion; import com.navercorp.pinpoint.test.plugin.PinpointAgent; import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite; +import org.apache.http.HttpHost; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.client.RestClient; +import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.common.xcontent.XContentType; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -37,10 +43,26 @@ @RunWith(PinpointPluginTestSuite.class) @PinpointAgent(AgentPath.PATH) @Dependency({"org.elasticsearch.client:elasticsearch-rest-high-level-client:[6.4.0,6.9.9)", - "pl.allegro.tech:embedded-elasticsearch:2.8.0"}) + TestcontainersOption.ELASTICSEARCH}) @JvmVersion(8) public class ElasticsearchIT_6_4_x_IT extends ElasticsearchITBase { + private static RestHighLevelClient restHighLevelClient; + + @Before + public void setup() { + restHighLevelClient = new RestHighLevelClient( + RestClient.builder( + new HttpHost(getServerHost(), getServerPort(), "http"))); + } + + @After + public void tearDown() throws IOException { + if (restHighLevelClient != null) { + restHighLevelClient.close(); + } + } + @Test public void testCRUD() throws Exception { @@ -51,8 +73,7 @@ public void testCRUD() throws Exception { private void testIndexV64UP(PluginTestVerifier verifier) throws IOException { - IndexRequest indexRequest = new IndexRequest( - "postv6", "doc", "3"); + IndexRequest indexRequest = new IndexRequest("postv6", "doc", "3"); String jsonString = "{" + "\"user\":\"kimchy\"," + @@ -70,7 +91,7 @@ private void testIndexV64UP(PluginTestVerifier verifier) throws IOException { throw new AssertionError(e); } - verifier.verifyTrace(event(ElasticsearchConstants.ELASTICSEARCH_EXECUTOR.getName(), index, null, ELASTICSEARCH_ADDRESS, "ElasticSearch" + verifier.verifyTrace(event(ElasticsearchConstants.ELASTICSEARCH_EXECUTOR.getName(), index, null, getElasticsearchAddress(), "ElasticSearch" , new ExpectedAnnotation(ElasticsearchConstants.ARGS_DSL_ANNOTATION_KEY.getName(), indexRequest.toString()) )); } diff --git a/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_7_0_x_IT.java b/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_7_0_x_IT.java index 644e6b28314f..19d3fba3b6f5 100644 --- a/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_7_0_x_IT.java +++ b/plugins-it/elasticsearch-it/src/test/java/com/navercorp/pinpoint/plugin/elasticsearch/ElasticsearchIT_7_0_x_IT.java @@ -18,16 +18,20 @@ import com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation; import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier; import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifierHolder; - import com.navercorp.pinpoint.pluginit.utils.AgentPath; +import com.navercorp.pinpoint.pluginit.utils.TestcontainersOption; import com.navercorp.pinpoint.test.plugin.Dependency; import com.navercorp.pinpoint.test.plugin.JvmVersion; import com.navercorp.pinpoint.test.plugin.PinpointAgent; import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite; +import org.apache.http.HttpHost; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.client.RequestOptions; -import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.client.RestClient; +import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.common.xcontent.XContentType; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -39,10 +43,26 @@ @RunWith(PinpointPluginTestSuite.class) @PinpointAgent(AgentPath.PATH) @Dependency({"org.elasticsearch.client:elasticsearch-rest-high-level-client:[7.0.0,7.16.0)", - "pl.allegro.tech:embedded-elasticsearch:2.8.0"}) + TestcontainersOption.ELASTICSEARCH}) @JvmVersion(8) public class ElasticsearchIT_7_0_x_IT extends ElasticsearchITBase { + private static RestHighLevelClient restHighLevelClient; + + @Before + public void setup() { + restHighLevelClient = new RestHighLevelClient( + RestClient.builder( + new HttpHost(getServerHost(), getServerPort(), "http"))); + } + + @After + public void tearDown() throws IOException { + if (restHighLevelClient != null) { + restHighLevelClient.close(); + } + } + @Test public void testHighLevelClient() throws Exception { @@ -54,8 +74,7 @@ public void testHighLevelClient() throws Exception { private void testIndexV70UP(PluginTestVerifier verifier) throws IOException { - IndexRequest indexRequest = new IndexRequest( - "post2"); + IndexRequest indexRequest = new IndexRequest("post2"); indexRequest.id("1"); String jsonString = "{" + @@ -74,7 +93,7 @@ private void testIndexV70UP(PluginTestVerifier verifier) throws IOException { throw new AssertionError(e); } - verifier.verifyTrace(event(ElasticsearchConstants.ELASTICSEARCH_EXECUTOR.getName(), index, null, ELASTICSEARCH_ADDRESS, "ElasticSearch" + verifier.verifyTrace(event(ElasticsearchConstants.ELASTICSEARCH_EXECUTOR.getName(), index, null, getElasticsearchAddress(), "ElasticSearch" , new ExpectedAnnotation(ElasticsearchConstants.ARGS_DSL_ANNOTATION_KEY.getName(), indexRequest.toString()) )); } diff --git a/plugins-it/plugins-it-utils/src/main/java/com/navercorp/pinpoint/pluginit/utils/TestcontainersOption.java b/plugins-it/plugins-it-utils/src/main/java/com/navercorp/pinpoint/pluginit/utils/TestcontainersOption.java index 62b51ae321ac..285cc65407f6 100644 --- a/plugins-it/plugins-it-utils/src/main/java/com/navercorp/pinpoint/pluginit/utils/TestcontainersOption.java +++ b/plugins-it/plugins-it-utils/src/main/java/com/navercorp/pinpoint/pluginit/utils/TestcontainersOption.java @@ -30,4 +30,6 @@ private TestcontainersOption() { public static final String MYSQLDB = "org.testcontainers:mysql:" + VERSION; public static final String MARIADB = "org.testcontainers:mariadb:" + VERSION; public static final String POSTGRESQL = "org.testcontainers:postgresql:" + VERSION; + + public static final String ELASTICSEARCH = "org.testcontainers:elasticsearch:" + VERSION; }