1 /*
2  *  Make.org Core API
3  *  Copyright (C) 2018 Make.org
4  *
5  * This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU Affero General Public License as
7  *  published by the Free Software Foundation, either version 3 of the
8  *  License, or (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU Affero General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Affero General Public License
16  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  *
18  */
19 
20 package org.make.api.docker
21 
22 import com.whisk.docker.{DockerContainer, DockerReadyChecker}
23 import org.scalatest.Suite
24 
25 import scala.concurrent.duration.DurationInt
26 
27 trait DockerElasticsearchService extends DockerBaseTest {
28   self: Suite =>
29 
30   val defaultElasticsearchHttpPort = 9200
31   val defaultElasticsearchClientPort = 9300
32 
33   // Port range: [30000-30999]
34   def elasticsearchExposedPort: Int
35 
36   val defaultElasticsearchProposalIndex = "proposals"
37   val defaultElasticsearchProposalDocType = "proposal"
38 
39   private def elasticSearchContainer =
40     DockerContainer(
41       "docker.elastic.co/elasticsearch/elasticsearch:8.18.0",
42       name = Some(s"${getClass.getSimpleName}-elasticsearch")
43     ).withEntrypoint(
44         "/bin/sh",
45         "-c",
46         "./bin/elasticsearch-plugin list | grep -q analysis-icu || ./bin/elasticsearch-plugin install analysis-icu; ./bin/elasticsearch-plugin list | grep -q analysis-stempel || ./bin/elasticsearch-plugin install analysis-stempel; /usr/local/bin/docker-entrypoint.sh"
47       )
48       .withPorts(defaultElasticsearchHttpPort -> Some(elasticsearchExposedPort))
49       .withEnv(
50         "xpack.security.enabled=false",
51         "transport.host=localhost",
52         "ES_JVM_OPTIONS=-Xmx256M -Xms256M",
53         "ES_JAVA_OPTS=-Xmx256M -Xms256M"
54       )
55       .withReadyChecker(
56         DockerReadyChecker
57           .HttpResponseCode(defaultElasticsearchHttpPort, "/")
58           .within(100.millis)
59           .looped(300, 1.second)
60       )
61 
62   abstract override def dockerContainers: List[DockerContainer] =
63     elasticSearchContainer :: super.dockerContainers
64 }
Line Stmt Id Pos Tree Symbol Tests Code
30 22193 1023 - 1027 Literal <nosymbol> 9200
31 22096 1067 - 1071 Literal <nosymbol> 9300
36 22054 1183 - 1194 Literal <nosymbol> "proposals"
37 22216 1239 - 1249 Literal <nosymbol> "proposal"
40 22127 1294 - 1294 Select com.whisk.docker.DockerContainer.apply$default$13 com.whisk.docker.DockerContainer.apply$default$13
40 22130 1294 - 1294 Select com.whisk.docker.DockerContainer.apply$default$4 com.whisk.docker.DockerContainer.apply$default$4
40 22088 1294 - 1294 Select com.whisk.docker.DockerContainer.apply$default$7 com.whisk.docker.DockerContainer.apply$default$7
40 22174 1294 - 1294 Select com.whisk.docker.DockerContainer.apply$default$3 com.whisk.docker.DockerContainer.apply$default$3
40 22105 1294 - 1294 Select com.whisk.docker.DockerContainer.apply$default$10 com.whisk.docker.DockerContainer.apply$default$10
40 22090 1294 - 1294 Select com.whisk.docker.DockerContainer.apply$default$16 com.whisk.docker.DockerContainer.apply$default$16
40 22189 1294 - 1294 Select com.whisk.docker.DockerContainer.apply$default$15 com.whisk.docker.DockerContainer.apply$default$15
40 22045 1294 - 1294 Select com.whisk.docker.DockerContainer.apply$default$17 com.whisk.docker.DockerContainer.apply$default$17
40 22027 1294 - 1294 Select com.whisk.docker.DockerContainer.apply$default$5 com.whisk.docker.DockerContainer.apply$default$5
40 22021 1294 - 1294 Select com.whisk.docker.DockerContainer.apply$default$11 com.whisk.docker.DockerContainer.apply$default$11
40 22051 1294 - 1294 Select com.whisk.docker.DockerContainer.apply$default$8 com.whisk.docker.DockerContainer.apply$default$8
40 22170 1294 - 1294 Select com.whisk.docker.DockerContainer.apply$default$12 com.whisk.docker.DockerContainer.apply$default$12
40 22209 1294 - 1294 Select com.whisk.docker.DockerContainer.apply$default$9 com.whisk.docker.DockerContainer.apply$default$9
40 22194 1294 - 1294 Select com.whisk.docker.DockerContainer.apply$default$6 com.whisk.docker.DockerContainer.apply$default$6
40 22026 1294 - 1294 Select com.whisk.docker.DockerContainer.apply$default$14 com.whisk.docker.DockerContainer.apply$default$14
41 22104 1317 - 1371 Literal <nosymbol> "docker.elastic.co/elasticsearch/elasticsearch:8.18.0"
42 22020 1386 - 1434 Apply scala.Some.apply scala.Some.apply[String](("".+(DockerElasticsearchService.this.getClass().getSimpleName()).+("-elasticsearch"): String))
44 22215 1465 - 1474 Literal <nosymbol> "/bin/sh"
45 22107 1484 - 1488 Literal <nosymbol> "-c"
46 22004 1498 - 1757 Literal <nosymbol> "./bin/elasticsearch-plugin list | grep -q analysis-icu || ./bin/elasticsearch-plugin install analysis-icu; ./bin/elasticsearch-plugin list | grep -q analysis-stempel || ./bin/elasticsearch-plugin install analysis-stempel; /usr/local/bin/docker-entrypoint.sh"
48 22171 1783 - 1811 Select org.make.api.docker.DockerElasticsearchService.defaultElasticsearchHttpPort DockerElasticsearchService.this.defaultElasticsearchHttpPort
48 22191 1783 - 1845 Apply scala.Predef.ArrowAssoc.-> scala.Predef.ArrowAssoc[Int](DockerElasticsearchService.this.defaultElasticsearchHttpPort).->[Some[Int]](scala.Some.apply[Int](DockerElasticsearchService.this.elasticsearchExposedPort))
48 22041 1815 - 1845 Apply scala.Some.apply scala.Some.apply[Int](DockerElasticsearchService.this.elasticsearchExposedPort)
48 22124 1820 - 1844 Select org.make.api.docker.DockerElasticsearchService.elasticsearchExposedPort DockerElasticsearchService.this.elasticsearchExposedPort
50 22083 1871 - 1901 Literal <nosymbol> "xpack.security.enabled=false"
51 22247 1911 - 1937 Literal <nosymbol> "transport.host=localhost"
52 22208 1947 - 1981 Literal <nosymbol> "ES_JVM_OPTIONS=-Xmx256M -Xms256M"
53 22118 1991 - 2023 Literal <nosymbol> "ES_JAVA_OPTS=-Xmx256M -Xms256M"
55 22167 1294 - 2217 Apply com.whisk.docker.DockerContainer.withReadyChecker com.whisk.docker.DockerContainer.apply("docker.elastic.co/elasticsearch/elasticsearch:8.18.0", scala.Some.apply[String](("".+(DockerElasticsearchService.this.getClass().getSimpleName()).+("-elasticsearch"): String)), com.whisk.docker.DockerContainer.apply$default$3, com.whisk.docker.DockerContainer.apply$default$4, com.whisk.docker.DockerContainer.apply$default$5, com.whisk.docker.DockerContainer.apply$default$6, com.whisk.docker.DockerContainer.apply$default$7, com.whisk.docker.DockerContainer.apply$default$8, com.whisk.docker.DockerContainer.apply$default$9, com.whisk.docker.DockerContainer.apply$default$10, com.whisk.docker.DockerContainer.apply$default$11, com.whisk.docker.DockerContainer.apply$default$12, com.whisk.docker.DockerContainer.apply$default$13, com.whisk.docker.DockerContainer.apply$default$14, com.whisk.docker.DockerContainer.apply$default$15, com.whisk.docker.DockerContainer.apply$default$16, com.whisk.docker.DockerContainer.apply$default$17).withEntrypoint("/bin/sh", "-c", "./bin/elasticsearch-plugin list | grep -q analysis-icu || ./bin/elasticsearch-plugin install analysis-icu; ./bin/elasticsearch-plugin list | grep -q analysis-stempel || ./bin/elasticsearch-plugin install analysis-stempel; /usr/local/bin/docker-entrypoint.sh").withPorts(scala.Predef.ArrowAssoc[Int](DockerElasticsearchService.this.defaultElasticsearchHttpPort).->[Some[Int]](scala.Some.apply[Int](DockerElasticsearchService.this.elasticsearchExposedPort))).withEnv("xpack.security.enabled=false", "transport.host=localhost", "ES_JVM_OPTIONS=-Xmx256M -Xms256M", "ES_JAVA_OPTS=-Xmx256M -Xms256M").withReadyChecker(com.whisk.docker.DockerReadyChecker.HttpResponseCode.apply(DockerElasticsearchService.this.defaultElasticsearchHttpPort, "/", com.whisk.docker.DockerReadyChecker.HttpResponseCode.apply$default$3, com.whisk.docker.DockerReadyChecker.HttpResponseCode.apply$default$4).within(scala.concurrent.duration.`package`.DurationInt(100).millis).looped(300, scala.concurrent.duration.`package`.DurationInt(1).second))
57 22165 2142 - 2145 Literal <nosymbol> "/"
57 22042 2095 - 2095 Select com.whisk.docker.DockerReadyChecker.HttpResponseCode.apply$default$4 com.whisk.docker.DockerReadyChecker.HttpResponseCode.apply$default$4
57 22131 2095 - 2095 Select com.whisk.docker.DockerReadyChecker.HttpResponseCode.apply$default$3 com.whisk.docker.DockerReadyChecker.HttpResponseCode.apply$default$3
57 22005 2112 - 2140 Select org.make.api.docker.DockerElasticsearchService.defaultElasticsearchHttpPort DockerElasticsearchService.this.defaultElasticsearchHttpPort
58 22084 2165 - 2175 Select scala.concurrent.duration.DurationConversions.millis scala.concurrent.duration.`package`.DurationInt(100).millis
58 22188 2165 - 2168 Literal <nosymbol> 100
59 22016 2065 - 2209 Apply com.whisk.docker.DockerReadyChecker.looped com.whisk.docker.DockerReadyChecker.HttpResponseCode.apply(DockerElasticsearchService.this.defaultElasticsearchHttpPort, "/", com.whisk.docker.DockerReadyChecker.HttpResponseCode.apply$default$3, com.whisk.docker.DockerReadyChecker.HttpResponseCode.apply$default$4).within(scala.concurrent.duration.`package`.DurationInt(100).millis).looped(300, scala.concurrent.duration.`package`.DurationInt(1).second)
59 22210 2200 - 2201 Literal <nosymbol> 1
59 22119 2200 - 2208 Select scala.concurrent.duration.DurationConversions.second scala.concurrent.duration.`package`.DurationInt(1).second
59 22244 2195 - 2198 Literal <nosymbol> 300
63 22132 2312 - 2337 Apply scala.collection.immutable.List.:: DockerElasticsearchService.super.dockerContainers.::[com.whisk.docker.DockerContainer](rassoc$1)