From c53fad34222dae857a1d21baab4a082e78ad7f0b Mon Sep 17 00:00:00 2001 From: Prajeen Govardhanam Date: Wed, 28 Feb 2024 08:42:46 +0530 Subject: [PATCH] refactor: use opensearch for testing --- build.sbt | 1 - .../OpenSearchInstrumentationTest.scala | 14 ++++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 7d97807cb..562dbfb96 100644 --- a/build.sbt +++ b/build.sbt @@ -400,7 +400,6 @@ lazy val `kamon-opensearch` = (project in file("instrumentation/kamon-opensearch scalatest % "test", logbackClassic % "test", "com.dimafeng" %% "testcontainers-scala" % "0.41.0" % "test", - "com.dimafeng" %% "testcontainers-scala-elasticsearch" % "0.41.0" % "test" ) ).dependsOn(`kamon-core`, `kamon-instrumentation-common`, `kamon-testkit` % "test") diff --git a/instrumentation/kamon-opensearch/src/test/scala/kamon/instrumentation/OpenSearchInstrumentationTest.scala b/instrumentation/kamon-opensearch/src/test/scala/kamon/instrumentation/OpenSearchInstrumentationTest.scala index 221e2aec9..67a0ecd09 100644 --- a/instrumentation/kamon-opensearch/src/test/scala/kamon/instrumentation/OpenSearchInstrumentationTest.scala +++ b/instrumentation/kamon-opensearch/src/test/scala/kamon/instrumentation/OpenSearchInstrumentationTest.scala @@ -1,6 +1,6 @@ package kamon.instrumentation -import com.dimafeng.testcontainers.{ElasticsearchContainer, ForAllTestContainer} +import com.dimafeng.testcontainers.{GenericContainer, ForAllTestContainer} import kamon.tag.Lookups.plain import kamon.testkit.{InitAndStopKamonAfterAll, Reconfigure, TestSpanReporter} import org.apache.http.HttpHost @@ -12,6 +12,7 @@ import org.scalatest.matchers.should.Matchers import org.scalatest.time.SpanSugar import org.scalatest.wordspec.AnyWordSpec import org.scalatest.OptionValues +import org.testcontainers.containers.wait.strategy.Wait class OpenSearchInstrumentationTest @@ -85,7 +86,12 @@ class OpenSearchInstrumentationTest } - override val container: ElasticsearchContainer = ElasticsearchContainer() + override val container: GenericContainer = GenericContainer( + "opensearchproject/opensearch:1.3.14", + exposedPorts = Seq(9200), + env = Map("discovery.type" -> "single-node", "plugins.security.disabled" -> "true"), + waitStrategy = Wait.forHttp("/_cluster/health") + ) var client: RestClient = _ var highLevelClient: RestHighLevelClient = _ @@ -94,11 +100,11 @@ class OpenSearchInstrumentationTest container.start() client = RestClient - .builder(HttpHost.create(container.httpHostAddress)) + .builder(HttpHost.create(s"${container.host}:${container.mappedPort(9200)}")) .build() highLevelClient = new RestHighLevelClient( - RestClient.builder(HttpHost.create(container.httpHostAddress))) + RestClient.builder(HttpHost.create(s"${container.host}:${container.mappedPort(9200)}"))) } override protected def afterAll(): Unit = {