diff --git a/agent-testweb/elasticsearch-8-plugin-testweb/pom.xml b/agent-testweb/elasticsearch-8-plugin-testweb/pom.xml
index c077592b725a..24daace4bad7 100644
--- a/agent-testweb/elasticsearch-8-plugin-testweb/pom.xml
+++ b/agent-testweb/elasticsearch-8-plugin-testweb/pom.xml
@@ -37,9 +37,19 @@
8.1.2
- pl.allegro.tech
- embedded-elasticsearch
- 2.10.0
+ org.testcontainers
+ elasticsearch
+ ${testcontainers.version}
+
+
+ com.navercorp.pinpoint
+ pinpoint-plugin-it-utils
+ ${project.version}
+
+
+ junit
+ junit
+ compile
diff --git a/agent-testweb/elasticsearch-8-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ElasticSearch8PluginController.java b/agent-testweb/elasticsearch-8-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ElasticSearch8PluginController.java
index c3dfe0ce64ed..13558125df43 100644
--- a/agent-testweb/elasticsearch-8-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ElasticSearch8PluginController.java
+++ b/agent-testweb/elasticsearch-8-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ElasticSearch8PluginController.java
@@ -32,9 +32,9 @@
@RestController
public class ElasticSearch8PluginController {
- private final EmbeddedElasticServer elasticServer;
+ private final ElasticSearchServer elasticServer;
- public ElasticSearch8PluginController(EmbeddedElasticServer elasticServer) {
+ public ElasticSearch8PluginController(ElasticSearchServer elasticServer) {
this.elasticServer = Objects.requireNonNull(elasticServer, "elasticServer");
}
diff --git a/agent-testweb/elasticsearch-8-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ElasticSearchServer.java b/agent-testweb/elasticsearch-8-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ElasticSearchServer.java
new file mode 100644
index 000000000000..d1e175947cfe
--- /dev/null
+++ b/agent-testweb/elasticsearch-8-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ElasticSearchServer.java
@@ -0,0 +1,56 @@
+package com.pinpoint.test.plugin;
+
+import com.navercorp.pinpoint.pluginit.utils.LogUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.stereotype.Component;
+import org.testcontainers.DockerClientFactory;
+import org.testcontainers.containers.output.OutputFrame;
+import org.testcontainers.elasticsearch.ElasticsearchContainer;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import java.io.IOException;
+import java.util.function.Consumer;
+
+@Component
+public class ElasticSearchServer {
+ private final Logger logger = LogManager.getLogger(this.getClass());
+ public ElasticsearchContainer elasticSearchContainer;
+
+ private final String address = "127.0.0.1";
+
+ public String getAddress() {
+ return address;
+ }
+
+ public int getPort() {
+ return elasticSearchContainer.getMappedPort(9200);
+ }
+
+ @PostConstruct
+ public void init() throws IOException, InterruptedException {
+ logger.info("ElasticSearchServer init");
+ if (!DockerClientFactory.instance().isDockerAvailable()) {
+ throw new IllegalStateException("Docker not enabled");
+ }
+
+ elasticSearchContainer = new ElasticsearchContainer();
+ elasticSearchContainer.withLogConsumer(new Consumer() {
+ @Override
+ public void accept(OutputFrame outputFrame) {
+ logger.info(LogUtils.removeLineBreak(outputFrame.getUtf8String()));
+ }
+ });
+ elasticSearchContainer.start();
+ logger.info("host:{} port:{}", elasticSearchContainer.getHttpHostAddress(), getPort());
+ }
+
+ @PreDestroy
+ private void shutdown() {
+ logger.info("ElasticSearchServer destroy");
+ if (elasticSearchContainer != null) {
+ elasticSearchContainer.stop();
+ }
+ }
+}
diff --git a/agent-testweb/elasticsearch-8-plugin-testweb/src/main/java/com/pinpoint/test/plugin/EmbeddedElasticServer.java b/agent-testweb/elasticsearch-8-plugin-testweb/src/main/java/com/pinpoint/test/plugin/EmbeddedElasticServer.java
deleted file mode 100644
index c90b287ca3f0..000000000000
--- a/agent-testweb/elasticsearch-8-plugin-testweb/src/main/java/com/pinpoint/test/plugin/EmbeddedElasticServer.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.pinpoint.test.plugin;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.springframework.stereotype.Component;
-import pl.allegro.tech.embeddedelasticsearch.EmbeddedElastic;
-import pl.allegro.tech.embeddedelasticsearch.PopularProperties;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-
-import java.io.IOException;
-
-import static java.util.concurrent.TimeUnit.MINUTES;
-
-@Component
-public class EmbeddedElasticServer {
- private final Logger logger = LogManager.getLogger(this.getClass());
- public EmbeddedElastic embeddedElastic;
-
- private final String address = "127.0.0.1";
- private final int port = 9200;
-
- public String getAddress() {
- return address;
- }
-
- public int getPort() {
- return port;
- }
-
- @PostConstruct
- public void init() throws IOException, InterruptedException {
- logger.info("EmbeddedElasticServer init");
- embeddedElastic = EmbeddedElastic.builder()
- .withElasticVersion("6.8.0")
- .withSetting(PopularProperties.HTTP_PORT, port)
- .withEsJavaOpts("-Xms128m -Xmx512m")
- .withStartTimeout(2, MINUTES)
- .build()
- .start();
- }
-
- @PreDestroy
- private void shutdown() {
- logger.info("EmbeddedElasticServer destroy");
- if (embeddedElastic != null) {
- embeddedElastic.stop();
- }
- }
-}
diff --git a/agent-testweb/elasticsearch-plugin-testweb/pom.xml b/agent-testweb/elasticsearch-plugin-testweb/pom.xml
index 5db51e6d7e15..dba6ad407e2b 100644
--- a/agent-testweb/elasticsearch-plugin-testweb/pom.xml
+++ b/agent-testweb/elasticsearch-plugin-testweb/pom.xml
@@ -37,9 +37,19 @@
7.16.0
- pl.allegro.tech
- embedded-elasticsearch
- 2.10.0
+ org.testcontainers
+ elasticsearch
+ ${testcontainers.version}
+
+
+ com.navercorp.pinpoint
+ pinpoint-plugin-it-utils
+ ${project.version}
+
+
+ junit
+ junit
+ compile
diff --git a/agent-testweb/elasticsearch-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ElasticSearchPluginController.java b/agent-testweb/elasticsearch-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ElasticSearchPluginController.java
index 5acc1a6949c7..6614a43c44ee 100644
--- a/agent-testweb/elasticsearch-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ElasticSearchPluginController.java
+++ b/agent-testweb/elasticsearch-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ElasticSearchPluginController.java
@@ -32,9 +32,9 @@
@RestController
public class ElasticSearchPluginController {
- private final EmbeddedElasticServer elasticServer;
+ private final ElasticSearchServer elasticServer;
- public ElasticSearchPluginController(EmbeddedElasticServer elasticServer) {
+ public ElasticSearchPluginController(ElasticSearchServer elasticServer) {
this.elasticServer = Objects.requireNonNull(elasticServer, "elasticServer");
}
diff --git a/agent-testweb/elasticsearch-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ElasticSearchServer.java b/agent-testweb/elasticsearch-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ElasticSearchServer.java
new file mode 100644
index 000000000000..2de9b51e7602
--- /dev/null
+++ b/agent-testweb/elasticsearch-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ElasticSearchServer.java
@@ -0,0 +1,56 @@
+package com.pinpoint.test.plugin;
+
+import com.navercorp.pinpoint.pluginit.utils.LogUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.stereotype.Component;
+import org.testcontainers.DockerClientFactory;
+import org.testcontainers.containers.output.OutputFrame;
+import org.testcontainers.elasticsearch.ElasticsearchContainer;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import java.util.function.Consumer;
+
+
+@Component
+public class ElasticSearchServer {
+ private final Logger logger = LogManager.getLogger(this.getClass());
+ public ElasticsearchContainer elasticSearchContainer;
+
+ private final String address = "127.0.0.1";
+
+ public String getAddress() {
+ return address;
+ }
+
+ public int getPort() {
+ return elasticSearchContainer.getMappedPort(9200);
+ }
+
+ @PostConstruct
+ public void init() {
+ logger.info("ElasticSearchServer init");
+ if (!DockerClientFactory.instance().isDockerAvailable()) {
+ throw new IllegalStateException("Docker not enabled");
+ }
+
+ elasticSearchContainer = new ElasticsearchContainer();
+ elasticSearchContainer.withLogConsumer(new Consumer() {
+ @Override
+ public void accept(OutputFrame outputFrame) {
+ logger.info(LogUtils.removeLineBreak(outputFrame.getUtf8String()));
+ }
+ });
+ elasticSearchContainer.start();
+ logger.info("host:{} port:{}", elasticSearchContainer.getHttpHostAddress(), getPort());
+ }
+
+ @PreDestroy
+ private void shutdown() {
+ logger.info("ElasticSearchServer destroy");
+ if (elasticSearchContainer != null) {
+ elasticSearchContainer.stop();
+ }
+ }
+}
diff --git a/agent-testweb/elasticsearch-plugin-testweb/src/main/java/com/pinpoint/test/plugin/EmbeddedElasticServer.java b/agent-testweb/elasticsearch-plugin-testweb/src/main/java/com/pinpoint/test/plugin/EmbeddedElasticServer.java
deleted file mode 100644
index 7b161871fc0f..000000000000
--- a/agent-testweb/elasticsearch-plugin-testweb/src/main/java/com/pinpoint/test/plugin/EmbeddedElasticServer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.pinpoint.test.plugin;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.springframework.stereotype.Component;
-import pl.allegro.tech.embeddedelasticsearch.EmbeddedElastic;
-import pl.allegro.tech.embeddedelasticsearch.PopularProperties;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import java.io.IOException;
-
-import static java.util.concurrent.TimeUnit.MINUTES;
-
-@Component
-public class EmbeddedElasticServer {
- private final Logger logger = LogManager.getLogger(this.getClass());
- public EmbeddedElastic embeddedElastic;
-
- private final String address = "127.0.0.1";
- private final int port = 9200;
-
- public String getAddress() {
- return address;
- }
-
- public int getPort() {
- return port;
- }
-
- @PostConstruct
- public void init() throws IOException, InterruptedException {
- logger.info("EmbeddedElasticServer init");
- embeddedElastic = EmbeddedElastic.builder()
- .withElasticVersion("6.8.0")
- .withSetting(PopularProperties.HTTP_PORT, port)
- .withEsJavaOpts("-Xms128m -Xmx512m")
- .withStartTimeout(2, MINUTES)
- .build()
- .start();
- }
-
- @PreDestroy
- private void shutdown() {
- logger.info("EmbeddedElasticServer destroy");
- if (embeddedElastic != null) {
- embeddedElastic.stop();
- }
- }
-}