Skip to content

Commit

Permalink
Making refresh_synonym_analyzer uri odfe compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
Himanshu Setia committed Sep 9, 2020
1 parent d4cc71e commit 52526e8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ internal class IndexManagementPlugin : JobSchedulerExtension, ActionPlugin, Plug
const val PLUGIN_NAME = "opendistro-im"
const val OPEN_DISTRO_BASE_URI = "/_opendistro"
const val ISM_BASE_URI = "$OPEN_DISTRO_BASE_URI/_ism"
const val ANALYZER_BASE_URI = "$OPEN_DISTRO_BASE_URI/_analyzer"
const val POLICY_BASE_URI = "$ISM_BASE_URI/policies"
const val INDEX_MANAGEMENT_INDEX = ".opendistro-ism-config"
const val INDEX_MANAGEMENT_JOB_TYPE = "opendistro-index-management"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package com.amazon.opendistroforelasticsearch.indexmanagement.refreshanalyzer

import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementPlugin.Companion.ANALYZER_BASE_URI
import org.elasticsearch.client.node.NodeClient
import org.elasticsearch.common.Strings
import org.elasticsearch.rest.BaseRestHandler
Expand Down Expand Up @@ -54,6 +55,6 @@ class RestRefreshSynonymAnalyzerAction : BaseRestHandler() {
}

companion object {
const val REFRESH_SYNONYM_ANALYZER_URI = "/{index}/_refresh_synonym_analyzer"
const val REFRESH_SYNONYM_ANALYZER_URI = "$ANALYZER_BASE_URI/refresh_synonym_analyzer/{index}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package com.amazon.opendistroforelasticsearch.indexmanagement.refreshanalyzer

import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementPlugin
import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementRestTestCase
import org.elasticsearch.client.Request
import org.elasticsearch.common.io.Streams
Expand Down Expand Up @@ -202,7 +203,8 @@ class RefreshSynonymAnalyzerActionIT : IndexManagementRestTestCase() {
}

fun refreshAnalyzer(indexName: String) {
val request = Request("POST", "/$indexName/_refresh_synonym_analyzer")
val request = Request("POST",
"${IndexManagementPlugin.ANALYZER_BASE_URI}/refresh_synonym_analyzer/$indexName")
client().performRequest(request)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package com.amazon.opendistroforelasticsearch.indexmanagement.refreshanalyzer

import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementPlugin.Companion.ANALYZER_BASE_URI
import com.amazon.opendistroforelasticsearch.indexmanagement.IndexManagementRestTestCase
import com.amazon.opendistroforelasticsearch.indexmanagement.indexstatemanagement.makeRequest
import org.elasticsearch.client.ResponseException
Expand All @@ -26,18 +27,18 @@ class RestRefreshSynonymAnalyzerActionIT : IndexManagementRestTestCase() {

fun `test missing indices`() {
try {
client().makeRequest(POST.toString(), "//_refresh_synonym_analyzer")
client().makeRequest(POST.toString(), "$ANALYZER_BASE_URI/refresh_synonym_analyzer")
fail("Expected a failure")
} catch (e: ResponseException) {
assertEquals("Unexpected RestStatus", RestStatus.BAD_REQUEST, e.response.restStatus())
val actualMessage = e.response.asMap()
val expectedErrorMessage = mapOf(
"error" to mapOf(
"root_cause" to listOf<Map<String, Any>>(
mapOf("type" to "illegal_argument_exception", "reason" to "Missing indices")
mapOf("type" to "parse_exception", "reason" to "request body is required")
),
"type" to "illegal_argument_exception",
"reason" to "Missing indices"
"type" to "parse_exception",
"reason" to "request body is required"
),
"status" to 400
)
Expand All @@ -52,7 +53,7 @@ class RestRefreshSynonymAnalyzerActionIT : IndexManagementRestTestCase() {
closeIndex(indexName)

try {
client().makeRequest(POST.toString(), "/$indexName/_refresh_synonym_analyzer")
client().makeRequest(POST.toString(), "$ANALYZER_BASE_URI/refresh_synonym_analyzer/$indexName")
fail("Expected a failure")
} catch (e: ResponseException) {
val response = e.response.asMap()
Expand Down

0 comments on commit 52526e8

Please sign in to comment.