Skip to content

Commit

Permalink
fix: build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
j5ik2o committed Sep 25, 2023
1 parent 94cbb1f commit 322255b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 22 deletions.
8 changes: 6 additions & 2 deletions build.sbt
Expand Up @@ -44,7 +44,7 @@ lazy val baseSettings = Seq(
scalatest.scalatest % Test
),
dependencyOverrides ++= Seq(
"com.fasterxml.jackson.core" % "jackson-databind" % "2.15.2"
fasterxml.jacksonModuleScala
),
Test / publishArtifact := false,
Test / fork := true,
Expand Down Expand Up @@ -236,7 +236,11 @@ val `docker-controller-scala-elasticsearch` = (project in file("docker-controlle
libraryDependencies ++= Seq(
scalatest.scalatest % Test,
logback.classic % Test,
elasticsearch.restHighLevelClient % Test
elasticsearch.restHighLevelClient % Test,
"co.elastic.clients" % "elasticsearch-java" % "7.17.13" % Test,
"com.fasterxml.jackson.core"%"jackson-databind" % "2.12.3" % Test,
"org.apache.logging.log4j" % "log4j-api" % "2.20.0" % Test,
"org.apache.logging.log4j" % "log4j-core" % "2.20.0" % Test
)
).dependsOn(`docker-controller-scala-core`, `docker-controller-scala-scalatest` % Test)

Expand Down
Expand Up @@ -11,7 +11,7 @@ import scala.concurrent.duration._

object ElasticsearchController {
final val DefaultImageName: String = "docker.elastic.co/elasticsearch/elasticsearch"
final val DefaultImageTag: Option[String] = Some("7.12.0")
final val DefaultImageTag: Option[String] = Some("8.10.2")
final val DefaultContainerPorts: Seq[Int] = Seq(9200, 9300)

def apply(
Expand Down Expand Up @@ -48,7 +48,9 @@ class ElasticsearchController(
) extends DockerControllerImpl(dockerClient, isDockerClientAutoClose, outputFrameInterval)(imageName, imageTag) {

private val environmentVariables = Map(
"discovery.type" -> "single-node"
"discovery.type" -> "single-node",
"xpack.security.enabled" -> "false"
// "network.host" -> "0.0.0.0"
) ++ envVars

override protected def newCreateContainerCmd(): CreateContainerCmd = {
Expand Down
@@ -1,11 +1,16 @@
package com.github.j5ik2o.dockerController.elasticsearch

import com.github.j5ik2o.dockerController.{ DockerController, DockerControllerSpecSupport, WaitPredicates }
import org.elasticsearch.client.{ RequestOptions, RestClient, RestHighLevelClient }
import co.elastic.clients.elasticsearch.ElasticsearchClient
import co.elastic.clients.json.jackson.JacksonJsonpMapper
import co.elastic.clients.transport.rest_client.RestClientTransport
import com.github.j5ik2o.dockerController.{DockerController, DockerControllerSpecSupport, WaitPredicates}
import org.elasticsearch.client.{RequestOptions, RestClient, RestClientBuilder, RestHighLevelClient, RestHighLevelClientBuilder}
import org.scalatest.freespec.AnyFreeSpec
import org.apache.http.HttpHost
import org.apache.http.client.methods.RequestBuilder.options
import org.elasticsearch.client.core.MainRequest

import scala.concurrent.duration.{ Duration, DurationInt }
import scala.concurrent.duration.{Duration, DurationInt}
import scala.util.control.NonFatal

class ElasticsearchControllerSpec extends AnyFreeSpec with DockerControllerSpecSupport {
Expand All @@ -25,29 +30,32 @@ class ElasticsearchControllerSpec extends AnyFreeSpec with DockerControllerSpecS
WaitPredicates.forListeningHostTcpPort(
dockerHost,
hostPort1,
(3 * testTimeFactor).seconds,
Some((10 * testTimeFactor).seconds)
(30 * testTimeFactor).seconds,
Some((20 * testTimeFactor).seconds)
)
)
)

"ElasticsearchController" - {
"run" in {
var client: RestHighLevelClient = null
var httpClient: RestClient = null
var transport: RestClientTransport = null
try {
client = new RestHighLevelClient(
RestClient.builder(
new HttpHost(dockerHost, hostPort1, "http"),
new HttpHost(dockerHost, hostPort2, "http")
)
httpClient = RestClient.builder(
new HttpHost("localhost", hostPort1)
).build()
transport = new RestClientTransport(
httpClient,
new JacksonJsonpMapper()
)
val result = client.ping(RequestOptions.DEFAULT)
assert(result)
} catch {
case NonFatal(ex) =>
ex.printStackTrace()
fail("occurred error", ex)
} finally if (client != null) client.close()
val esClient = new ElasticsearchClient(transport)
esClient.ping()
} finally {
if (transport != null)
transport.close()
if (httpClient != null)
httpClient.close()
}
}
}
}
3 changes: 3 additions & 0 deletions project/Dependencies.scala
Expand Up @@ -111,4 +111,7 @@ object Dependencies {
val finagleMemcached = "com.twitter" %% "finagle-memcached" % "22.12.0"
}

object fasterxml {
val jacksonModuleScala = "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.15.2"
}
}

0 comments on commit 322255b

Please sign in to comment.