diff --git a/search-indexer/src/main/scala/org/sunbird/job/searchindexer/task/SearchIndexerConfig.scala b/search-indexer/src/main/scala/org/sunbird/job/searchindexer/task/SearchIndexerConfig.scala index 9adad0e00..77bb323eb 100644 --- a/search-indexer/src/main/scala/org/sunbird/job/searchindexer/task/SearchIndexerConfig.scala +++ b/search-indexer/src/main/scala/org/sunbird/job/searchindexer/task/SearchIndexerConfig.scala @@ -72,4 +72,11 @@ class SearchIndexerConfig(override val config: Config) extends BaseJobConfig(con val ignoredFields: List[String] = if (config.hasPath("ignored.fields")) config.getStringList("ignored.fields").asScala.toList else List("responseDeclaration", "body") val isrRelativePathEnabled: Boolean = if (config.hasPath("cloudstorage.metadata.replace_absolute_path")) config.getBoolean("cloudstorage.metadata.replace_absolute_path") else false -} + val esImage: String = if (config.hasPath("es.image")) config.getString("es.image") else "docker.elastic.co/elasticsearch/elasticsearch" + val esImageTag: String = if (config.hasPath("es.imageTag")) config.getString("es.imageTag") else "7.17.13" + val esPorts : util.List[String] = if (config.hasPath("es.ports")) config.getStringList("es.ports") else List("9200:9200").asJava + val esJavaOpts: String = if (config.hasPath("es.javaOpts")) config.getString("es.javaOpts") else "-Xms128m -Xmx512m" + val esJavaOptsKey: String = if (config.hasPath("es.javaOptsKey")) config.getString("es.javaOptsKey") else "ES_JAVA_OPTS" + val xpackSecurityEnabled: String = if (config.hasPath("es.xpackSecurityEnabled")) config.getString("es.xpackSecurityEnabled") else "false" + val xpackSecurityKey: String = if (config.hasPath("es.xpackSecurityKey")) config.getString("es.xpackSecurityKey") else "xpack.security.enabled" +} \ No newline at end of file diff --git a/search-indexer/src/test/resources/test.conf b/search-indexer/src/test/resources/test.conf index 1faacbda4..edae4e796 100644 --- a/search-indexer/src/test/resources/test.conf +++ b/search-indexer/src/test/resources/test.conf @@ -32,4 +32,16 @@ schema { itemset = "2.0" } } -schema.definition_cache.expiry = 14400 \ No newline at end of file +schema.definition_cache.expiry = 14400 + +es { + image = "docker.elastic.co/elasticsearch/elasticsearch" + imageTag = "7.17.13" + ports = ["9200:9200"] + javaOptsKey = "ES_JAVA_OPTS" + javaOpts = "-Xms128m -Xmx512m" + xpackSecurityKey = "xpack.security.enabled" + xpackSecurityEnabled = "false" + +} + diff --git a/search-indexer/src/test/scala/org/sunbird/job/spec/SearchIndexerTaskTestSpec.scala b/search-indexer/src/test/scala/org/sunbird/job/spec/SearchIndexerTaskTestSpec.scala index 122faa000..4e93135e7 100644 --- a/search-indexer/src/test/scala/org/sunbird/job/spec/SearchIndexerTaskTestSpec.scala +++ b/search-indexer/src/test/scala/org/sunbird/job/spec/SearchIndexerTaskTestSpec.scala @@ -44,15 +44,15 @@ class SearchIndexerTaskTestSpec extends BaseTestSpec { val config: Config = ConfigFactory.load("test.conf") val jobConfig = new SearchIndexerConfig(config) val mockElasticUtil = mock[ElasticSearchUtil](Mockito.withSettings().serializable()) - var elasticContainer = new ElasticsearchContainer(DockerImageName.parse("docker.elastic.co/elasticsearch/elasticsearch").withTag("7.17.13")) + var elasticContainer = new ElasticsearchContainer(DockerImageName.parse(jobConfig.esImage).withTag(jobConfig.esImageTag)) var restClient: RestClient = _ val defCache = new DefinitionCache() def setupElasticContainer(): Unit = { elasticContainer.setHostAccessible(true) - elasticContainer.setPortBindings(List("9200:9200").asJava) - elasticContainer.withEnv("ES_JAVA_OPTS", "-Xms128m -Xmx512m") - elasticContainer.withEnv("xpack.security.enabled", "false") + elasticContainer.setPortBindings(jobConfig.esPorts) + elasticContainer.withEnv(jobConfig.esJavaOptsKey, jobConfig.esJavaOpts) + elasticContainer.withEnv(jobConfig.xpackSecurityKey, jobConfig.xpackSecurityEnabled) elasticContainer.withStartupTimeout(Duration.ofSeconds(60)) elasticContainer.waitingFor(Wait.forListeningPort()) elasticContainer.start()