Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.elasticsearch.ElasticsearchContainer;

@SuppressWarnings("deprecation") // using deprecated semconv
class ElasticsearchClientTest {
private static final Logger logger = LoggerFactory.getLogger(ElasticsearchClientTest.class);

@RegisterExtension
static final InstrumentationExtension testing = AgentInstrumentationExtension.create();

Expand All @@ -57,9 +62,10 @@ class ElasticsearchClientTest {
@BeforeAll
static void setUp() {
elasticsearch =
new ElasticsearchContainer("docker.elastic.co/elasticsearch/elasticsearch:7.17.2");
new ElasticsearchContainer("docker.elastic.co/elasticsearch/elasticsearch:7.17.28");
// limit memory usage
elasticsearch.withEnv("ES_JAVA_OPTS", "-Xmx256m -Xms256m");
elasticsearch.withLogConsumer(new Slf4jLogConsumer(logger));
elasticsearch.start();

httpHost = HttpHost.create(elasticsearch.getHttpHostAddress());
Expand Down Expand Up @@ -87,7 +93,7 @@ static void cleanUp() {
@Test
void elasticsearchStatus() throws IOException {
InfoResponse response = client.info();
assertThat(response.version().number()).isEqualTo("7.17.2");
assertThat(response.version().number()).isEqualTo("7.17.28");

testing.waitAndAssertTraces(
trace ->
Expand Down Expand Up @@ -188,7 +194,7 @@ void elasticsearchStatusAsync() throws Exception {
//noinspection ResultOfMethodCallIgnored
countDownLatch.await(10, TimeUnit.SECONDS);

assertThat(request.getResponse().version().number()).isEqualTo("7.17.2");
assertThat(request.getResponse().version().number()).isEqualTo("7.17.28");

testing.waitAndAssertTraces(
trace ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ static void setup() {
new ElasticsearchContainer("docker.elastic.co/elasticsearch/elasticsearch-oss:6.8.16");
}
// limit memory usage
elasticsearch.withEnv("ES_JAVA_OPTS", "-Xmx256m -Xms256m");
elasticsearch.withEnv(
"ES_JAVA_OPTS",
"-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true -XX:-UseContainerSupport");
elasticsearch.start();

httpHost = HttpHost.create(elasticsearch.getHttpHostAddress());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ static void setUp() {
elasticsearch =
new ElasticsearchContainer("docker.elastic.co/elasticsearch/elasticsearch-oss:6.8.16");
// limit memory usage
elasticsearch.withEnv("ES_JAVA_OPTS", "-Xmx256m -Xms256m");
elasticsearch.withEnv(
"ES_JAVA_OPTS",
"-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true -XX:-UseContainerSupport");
elasticsearch.start();

httpHost = HttpHost.create(elasticsearch.getHttpHostAddress());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ static void setUp() {
elasticsearch =
new ElasticsearchContainer("docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2");
// limit memory usage
elasticsearch.withEnv("ES_JAVA_OPTS", "-Xmx256m -Xms256m");
elasticsearch.withEnv(
"ES_JAVA_OPTS",
"-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true -XX:-UseContainerSupport");
elasticsearch.start();

httpHost = HttpHost.create(elasticsearch.getHttpHostAddress());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ static void setUp() {
elasticsearch =
new ElasticsearchContainer("docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2");
// limit memory usage
elasticsearch.withEnv("ES_JAVA_OPTS", "-Xmx256m -Xms256m");
elasticsearch.withEnv(
"ES_JAVA_OPTS",
"-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true -XX:-UseContainerSupport");
elasticsearch.start();

httpHost = HttpHost.create(elasticsearch.getHttpHostAddress());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ void setUp() throws Exception {
opensearch =
new OpensearchContainer(DockerImageName.parse("opensearchproject/opensearch:1.3.6"))
.withSecurityEnabled();
opensearch.withEnv("OPENSEARCH_JAVA_OPTS", "-Xmx256m -Xms256m");
// limit memory usage and disable Log4j JMX to avoid cgroup detection issues in containers
opensearch.withEnv(
"OPENSEARCH_JAVA_OPTS",
"-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true -XX:-UseContainerSupport");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opensearch.start();
httpHost = URI.create(opensearch.getHttpHostAddress());
openSearchClient = buildOpenSearchClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ void setUp() throws Exception {
opensearch =
new OpensearchContainer(DockerImageName.parse("opensearchproject/opensearch:1.3.6"))
.withSecurityEnabled();
// limit memory usage
opensearch.withEnv("OPENSEARCH_JAVA_OPTS", "-Xmx256m -Xms256m");
// limit memory usage and disable Log4j JMX to avoid cgroup detection issues in containers
opensearch.withEnv(
"OPENSEARCH_JAVA_OPTS",
"-Xmx256m -Xms256m -Dlog4j2.disableJmx=true -Dlog4j2.disable.jmx=true -XX:-UseContainerSupport");
opensearch.start();
httpHost = URI.create(opensearch.getHttpHostAddress());

Expand Down
Loading