Skip to content

Commit 216cb41

Browse files
committed
fix(test): fix Elasticsearch client compatibility and test configuration
- Replace ping() with info() method for Elasticsearch 8.x compatibility - Add environment variables to disable security for test environment - Add ES_JAVA_OPTS to set memory limits - Format code with scalafmt
1 parent bbd8169 commit 216cb41

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

docker-controller-scala-elasticsearch/src/test/scala/com/github/j5ik2o/dockerController/elasticsearch/ElasticsearchControllerSpec.scala

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,17 @@ class ElasticsearchControllerSpec extends AnyFreeSpec with DockerControllerSpecS
1515
val testTimeFactor: Int = sys.env.getOrElse("TEST_TIME_FACTOR", "1").toInt
1616
logger.debug(s"testTimeFactor = $testTimeFactor")
1717

18-
val hostPort1: Int = temporaryServerPort()
19-
val hostPort2: Int = temporaryServerPort()
20-
val controller: ElasticsearchController = ElasticsearchController(dockerClient)(hostPort1, hostPort2)
18+
val hostPort1: Int = temporaryServerPort()
19+
val hostPort2: Int = temporaryServerPort()
20+
val controller: ElasticsearchController = ElasticsearchController(
21+
dockerClient,
22+
envVars = Map(
23+
"discovery.type" -> "single-node",
24+
"xpack.security.enabled" -> "false",
25+
"xpack.security.http.ssl.enabled" -> "false",
26+
"ES_JAVA_OPTS" -> "-Xms512m -Xmx512m"
27+
)
28+
)(hostPort1, hostPort2)
2129

2230
override protected val dockerControllers: Vector[DockerController] = Vector(controller)
2331

@@ -48,7 +56,9 @@ class ElasticsearchControllerSpec extends AnyFreeSpec with DockerControllerSpecS
4856
new JacksonJsonpMapper()
4957
)
5058
val esClient = new ElasticsearchClient(transport)
51-
esClient.ping()
59+
// Use info() instead of ping() for compatibility
60+
val info = esClient.info()
61+
assert(info.clusterName() != null)
5262
} finally {
5363
if (transport != null)
5464
transport.close()

0 commit comments

Comments
 (0)