Skip to content

Commit

Permalink
refactor: use opensearch for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rgprajeen committed Mar 1, 2024
1 parent 5b89c15 commit c53fad3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 = _

Expand All @@ -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 = {
Expand Down

0 comments on commit c53fad3

Please sign in to comment.