From 3ad24648063561ea0be9afb75a6c224c3cc528c3 Mon Sep 17 00:00:00 2001 From: Robert Downs Date: Thu, 3 Mar 2022 22:42:03 +0000 Subject: [PATCH] Fix additional rebase issues Signed-off-by: Robert Downs --- .../NewClusterEventHandler.kt | 0 .../indexmanagement/IndexManagementPlugin.kt | 1 + .../ManagedIndexRunner.kt | 6 ++-- .../NewClusterEventListener.kt | 35 ------------------- .../indexstatemanagement/model/Policy.kt | 13 ++++--- .../resthandler/RestIndexPolicyAction.kt | 5 +-- .../LegacyOpenDistroManagedIndexSettings.kt | 3 +- .../settings/ManagedIndexSettings.kt | 10 ------ .../step/transition/AttemptTransitionStep.kt | 2 +- .../util/ManagedIndexUtils.kt | 7 ++-- .../IndexManagementSettingsTests.kt | 1 - .../action/ActionRetryIT.kt | 1 + .../runner/ManagedIndexRunnerIT.kt | 12 ++++--- .../runner/ManagedIndexRunnerTests.kt | 1 - .../step/AttemptTransitionStepTests.kt | 8 ++--- .../action/explain/ExplainResponseTests.kt | 35 ++----------------- 16 files changed, 30 insertions(+), 110 deletions(-) delete mode 100644 spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/NewClusterEventHandler.kt delete mode 100644 src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/NewClusterEventListener.kt diff --git a/spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/NewClusterEventHandler.kt b/spi/src/main/kotlin/org.opensearch.indexmanagement.spi/indexstatemanagement/NewClusterEventHandler.kt deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt b/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt index b3b77407d..4b506f588 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/IndexManagementPlugin.kt @@ -379,6 +379,7 @@ class IndexManagementPlugin : JobSchedulerExtension, NetworkPlugin, ActionPlugin .registerSkipFlag(skipFlag) .registerThreadPool(threadPool) .registerExtensionChecker(extensionChecker) + .registerIndexMetadataProvider(indexMetadataProvider) val metadataService = MetadataService(client, clusterService, skipFlag, indexManagementIndices) val templateService = ISMTemplateService(client, clusterService, xContentRegistry, indexManagementIndices) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt index 90cef4db3..d8f3e66fb 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt @@ -65,7 +65,6 @@ import org.opensearch.indexmanagement.indexstatemanagement.util.hasTimedOut import org.opensearch.indexmanagement.indexstatemanagement.util.hasVersionConflict import org.opensearch.indexmanagement.indexstatemanagement.util.isAllowed import org.opensearch.indexmanagement.indexstatemanagement.util.isFailed -import org.opensearch.indexmanagement.indexstatemanagement.util.isMetadataMoved import org.opensearch.indexmanagement.indexstatemanagement.util.isSafeToChange import org.opensearch.indexmanagement.indexstatemanagement.util.isSuccessfulDelete import org.opensearch.indexmanagement.indexstatemanagement.util.managedIndexConfigIndexRequest @@ -252,7 +251,8 @@ object ManagedIndexRunner : indexMetadata = null // If the cluster state/default index type didn't have an index with a matching name and uuid combination, try all other index types val nonDefaultIndexTypes = indexMetadataProvider.services.keys.filter { it != DEFAULT_INDEX_TYPE } - val multiTypeIndexNameToMetaData = indexMetadataProvider.getMultiTypeIndexMetadata(nonDefaultIndexTypes, listOf(managedIndexConfig.index)) + val multiTypeIndexNameToMetaData = + indexMetadataProvider.getMultiTypeISMIndexMetadata(nonDefaultIndexTypes, listOf(managedIndexConfig.index)) val someTypeMatchedUuid = multiTypeIndexNameToMetaData.values.any { it[managedIndexConfig.index]?.indexUuid == managedIndexConfig.indexUuid } @@ -841,7 +841,7 @@ object ManagedIndexRunner : @Suppress("ReturnCount") private suspend fun getIndexCreationDate(managedIndexConfig: ManagedIndexConfig): Long? { try { - val multiTypeIndexNameToMetaData = indexMetadataProvider.getMultiTypeIndexMetadata(indexNames = listOf(managedIndexConfig.index)) + val multiTypeIndexNameToMetaData = indexMetadataProvider.getMultiTypeISMIndexMetadata(indexNames = listOf(managedIndexConfig.index)) // the managedIndexConfig.indexUuid should be unique across all index types val indexCreationDate = multiTypeIndexNameToMetaData.values.firstOrNull { it[managedIndexConfig.index]?.indexUuid == managedIndexConfig.indexUuid diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/NewClusterEventListener.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/NewClusterEventListener.kt deleted file mode 100644 index ac00386e6..000000000 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/NewClusterEventListener.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -package org.opensearch.indexmanagement.indexstatemanagement - -import org.opensearch.client.Client -import org.opensearch.cluster.ClusterChangedEvent -import org.opensearch.cluster.ClusterStateListener -import org.opensearch.cluster.service.ClusterService -import org.opensearch.indexmanagement.spi.indexstatemanagement.NewClusterEventHandler - -/** - * Notifies the NewClusterEventHandlers from all extensions whenever a ClusterChangedEvent of the `isNewCluster` type occurs, - * enabling extensions to react to `new cluster` typed events. - */ -class NewClusterEventListener( - val client: Client, - val clusterService: ClusterService, - private val newClusterEventHandlers: List -) : ClusterStateListener { - - init { - clusterService.addListener(this) - } - - override fun clusterChanged(event: ClusterChangedEvent) { - if (event.isNewCluster) { - newClusterEventHandlers.forEach { eventHandler -> - eventHandler.processEvent(client, clusterService, event) - } - } - } -} diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/Policy.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/Policy.kt index d4b25f4ce..432fa8e0d 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/Policy.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/Policy.kt @@ -118,16 +118,15 @@ data class Policy( } /** - * Disallowed actions are specified in the [ManagedIndexSettings.BLOCKED_ACTIONS_LIST], or are not specified in the - * deprecated [ManagedIndexSettings.ALLOW_LIST] setting. + * Disallowed actions are ones that are not specified in the [ManagedIndexSettings.ALLOW_LIST] setting. */ - fun getDisallowedActions(allowList: List, blockedActionsList: List): List { - val allowedActionsSet = allowList.toSet() - blockedActionsList.toSet() + fun getDisallowedActions(allowList: List): List { + val allowListSet = allowList.toSet() val disallowedActions = mutableListOf() this.states.forEach { state -> - state.actions.forEach { action -> - if (!allowedActionsSet.contains(action.type)) { - disallowedActions.add(action.type) + state.actions.forEach { actionConfig -> + if (!allowListSet.contains(actionConfig.type)) { + disallowedActions.add(actionConfig.type) } } } diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestIndexPolicyAction.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestIndexPolicyAction.kt index d4957eda9..dd98093a0 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestIndexPolicyAction.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/RestIndexPolicyAction.kt @@ -15,7 +15,6 @@ import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.LEGACY_POL import org.opensearch.indexmanagement.IndexManagementPlugin.Companion.POLICY_BASE_URI import org.opensearch.indexmanagement.indexstatemanagement.model.Policy import org.opensearch.indexmanagement.indexstatemanagement.settings.ManagedIndexSettings.Companion.ALLOW_LIST -import org.opensearch.indexmanagement.indexstatemanagement.settings.ManagedIndexSettings.Companion.BLOCKED_ACTIONS_LIST import org.opensearch.indexmanagement.indexstatemanagement.transport.action.indexpolicy.IndexPolicyAction import org.opensearch.indexmanagement.indexstatemanagement.transport.action.indexpolicy.IndexPolicyRequest import org.opensearch.indexmanagement.indexstatemanagement.transport.action.indexpolicy.IndexPolicyResponse @@ -42,11 +41,9 @@ class RestIndexPolicyAction( ) : BaseRestHandler() { @Volatile private var allowList = ALLOW_LIST.get(settings) - @Volatile private var blockedActionsList = BLOCKED_ACTIONS_LIST.get(settings) init { clusterService.clusterSettings.addSettingsUpdateConsumer(ALLOW_LIST) { allowList = it } - clusterService.clusterSettings.addSettingsUpdateConsumer(BLOCKED_ACTIONS_LIST) { blockedActionsList = it } } override fun routes(): List { @@ -88,7 +85,7 @@ class RestIndexPolicyAction( WriteRequest.RefreshPolicy.IMMEDIATE } - val disallowedActions = policy.getDisallowedActions(allowList, blockedActionsList) + val disallowedActions = policy.getDisallowedActions(allowList) if (disallowedActions.isNotEmpty()) { return RestChannelConsumer { channel -> channel.sendResponse( diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/LegacyOpenDistroManagedIndexSettings.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/LegacyOpenDistroManagedIndexSettings.kt index 5e6c521d2..ddd685b25 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/LegacyOpenDistroManagedIndexSettings.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/LegacyOpenDistroManagedIndexSettings.kt @@ -179,8 +179,7 @@ class LegacyOpenDistroManagedIndexSettings { ALLOW_LIST_ALL, Function.identity(), Setting.Property.NodeScope, - Setting.Property.Dynamic, - Setting.Property.Deprecated + Setting.Property.Dynamic ) val SNAPSHOT_DENY_LIST: Setting> = Setting.listSetting( diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/ManagedIndexSettings.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/ManagedIndexSettings.kt index 219c07ff1..359c52da8 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/ManagedIndexSettings.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/settings/ManagedIndexSettings.kt @@ -18,7 +18,6 @@ class ManagedIndexSettings { const val DEFAULT_JOB_INTERVAL = 5 const val DEFAULT_JITTER = 0.6 const val DEFAULT_RESTRICTED_PATTERN = "\\.opendistro_security|\\.kibana.*|\\$INDEX_MANAGEMENT_INDEX" - val DEFAULT_BLOCKED_ACTIONS = emptyList() val ALLOW_LIST_NONE = emptyList() val SNAPSHOT_DENY_LIST_NONE = emptyList() const val HOST_DENY_LIST = "opendistro.destination.host.deny_list" @@ -173,15 +172,6 @@ class ManagedIndexSettings { LegacyOpenDistroManagedIndexSettings.ALLOW_LIST, Function.identity(), Setting.Property.NodeScope, - Setting.Property.Dynamic, - Setting.Property.Deprecated - ) - - val BLOCKED_ACTIONS_LIST: Setting> = Setting.listSetting( - "plugins.index_state_management.blocked_actions_list", - DEFAULT_BLOCKED_ACTIONS, - Function.identity(), - Setting.Property.NodeScope, Setting.Property.Dynamic ) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transition/AttemptTransitionStep.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transition/AttemptTransitionStep.kt index 5e6218c37..18e49a4ca 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transition/AttemptTransitionStep.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/transition/AttemptTransitionStep.kt @@ -162,7 +162,7 @@ class AttemptTransitionStep(private val action: TransitionsAction) : Step(name) } else { // And then finally check all other index types which may not be in the cluster val nonDefaultIndexTypes = indexMetadataProvider.services.keys.filter { it != DEFAULT_INDEX_TYPE } - val multiTypeIndexNameToMetaData = indexMetadataProvider.getMultiTypeIndexMetadata(nonDefaultIndexTypes, listOf(indexName)) + val multiTypeIndexNameToMetaData = indexMetadataProvider.getMultiTypeISMIndexMetadata(nonDefaultIndexTypes, listOf(indexName)) // the managedIndexConfig.indexUuid should be unique across all index types val indexCreationDate = multiTypeIndexNameToMetaData.values.firstOrNull { it[indexName]?.indexUuid == metadata.indexUuid diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/util/ManagedIndexUtils.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/util/ManagedIndexUtils.kt index 6bfcd6fde..b23227083 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/util/ManagedIndexUtils.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/util/ManagedIndexUtils.kt @@ -468,12 +468,9 @@ fun Policy.isSafeToChange(stateName: String?, newPolicy: Policy, changePolicy: C } /** - * Allowed actions are specified in the [ManagedIndexSettings.ALLOW_LIST] setting, and are not specified in the - * [ManagedIndexSettings.BLOCKED_ACTIONS_LIST] setting. + * Allowed actions are ones that are specified in the [ManagedIndexSettings.ALLOW_LIST] setting. */ -fun Action.isAllowed(blockedActionsList: List, allowList: List): Boolean { - return allowList.contains(this.type) && !blockedActionsList.contains(this.type) -} +fun Action.isAllowed(allowList: List): Boolean = allowList.contains(this.type) /** * Check if cluster state metadata has been moved to config index diff --git a/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementSettingsTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementSettingsTests.kt index e9ed17b9a..0176c90a2 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementSettingsTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/IndexManagementSettingsTests.kt @@ -81,7 +81,6 @@ class IndexManagementSettingsTests : OpenSearchTestCase() { ManagedIndexSettings.COORDINATOR_BACKOFF_COUNT, ManagedIndexSettings.COORDINATOR_BACKOFF_MILLIS, ManagedIndexSettings.ALLOW_LIST, - ManagedIndexSettings.BLOCKED_ACTIONS_LIST, ManagedIndexSettings.SNAPSHOT_DENY_LIST, ManagedIndexSettings.JITTER, RollupSettings.ROLLUP_INGEST_BACKOFF_COUNT, diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/action/ActionRetryIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/action/ActionRetryIT.kt index 02e14fc11..cf05dd34d 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/action/ActionRetryIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/action/ActionRetryIT.kt @@ -145,6 +145,7 @@ class ActionRetryIT : IndexStateManagementRestTestCase() { ManagedIndexMetaData.POLICY_SEQ_NO to policySeq::equals, ManagedIndexMetaData.POLICY_PRIMARY_TERM to policyPrimaryTerm::equals, ManagedIndexMetaData.ROLLED_OVER to false::equals, + ManagedIndexMetaData.INDEX_CREATION_DATE to fun(indexCreationDate: Any?): Boolean = (indexCreationDate as Long) > 1L, StateMetaData.STATE to fun(stateMetaDataMap: Any?): Boolean = assertStateEquals(StateMetaData("Ingest", Instant.now().toEpochMilli()), stateMetaDataMap), ActionMetaData.ACTION to fun(actionMetaDataMap: Any?): Boolean = diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/runner/ManagedIndexRunnerIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/runner/ManagedIndexRunnerIT.kt index d227c4926..38d013232 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/runner/ManagedIndexRunnerIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/runner/ManagedIndexRunnerIT.kt @@ -5,6 +5,7 @@ package org.opensearch.indexmanagement.indexstatemanagement.runner +import org.opensearch.indexmanagement.indexstatemanagement.ISMActionsParser import org.opensearch.indexmanagement.indexstatemanagement.IndexStateManagementRestTestCase import org.opensearch.indexmanagement.indexstatemanagement.action.OpenAction import org.opensearch.indexmanagement.indexstatemanagement.action.ReadOnlyAction @@ -129,8 +130,8 @@ class ManagedIndexRunnerIT : IndexStateManagementRestTestCase() { } } - fun `test blocked action fails execution`() { - val indexName = "blocked_action_index" + fun `test allow list fails execution`() { + val indexName = "allow_list_index" val firstState = randomState( name = "first_state", actions = listOf(randomReadOnlyActionConfig()), @@ -167,8 +168,11 @@ class ManagedIndexRunnerIT : IndexStateManagementRestTestCase() { updateManagedIndexConfigStartTime(managedIndexConfig) waitFor { assertEquals(AttemptTransitionStep.getSuccessMessage(indexName, firstState.name), getExplainManagedIndexMetaData(indexName).info?.get("message")) } - // block the read_only action - updateClusterSetting(ManagedIndexSettings.BLOCKED_ACTIONS_LIST.key, "[\"${ReadOnlyAction.name}\"]", escapeValue = false) + // remove read_only from the allowlist + val allowedActions = ISMActionsParser.instance.parsers.map { it.getActionType() }.toList() + .filter { actionType -> actionType != ReadOnlyAction.name } + .joinToString(prefix = "[", postfix = "]") { string -> "\"$string\"" } + updateClusterSetting(ManagedIndexSettings.ALLOW_LIST.key, allowedActions, escapeValue = false) // speed up to fifth execution that should try to set index to read only and fail because the action is not allowed updateManagedIndexConfigStartTime(managedIndexConfig) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/runner/ManagedIndexRunnerTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/runner/ManagedIndexRunnerTests.kt index eaff8a507..17a1a4ef5 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/runner/ManagedIndexRunnerTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/runner/ManagedIndexRunnerTests.kt @@ -62,7 +62,6 @@ class ManagedIndexRunnerTests : OpenSearchTestCase() { settingSet.add(ManagedIndexSettings.JOB_INTERVAL) settingSet.add(ManagedIndexSettings.INDEX_STATE_MANAGEMENT_ENABLED) settingSet.add(ManagedIndexSettings.ALLOW_LIST) - settingSet.add(ManagedIndexSettings.BLOCKED_ACTIONS_LIST) val clusterSettings = ClusterSettings(settings, settingSet) val originClusterService: ClusterService = ClusterServiceUtils.createClusterService(threadPool, discoveryNode, clusterSettings) clusterService = Mockito.spy(originClusterService) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptTransitionStepTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptTransitionStepTests.kt index 398489f2f..3c0f58090 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptTransitionStepTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/AttemptTransitionStepTests.kt @@ -69,7 +69,7 @@ class AttemptTransitionStepTests : OpenSearchTestCase() { whenever(docsStats.count).doReturn(6L) whenever(docsStats.totalSizeInBytes).doReturn(2) val client = getClient(getAdminClient(getIndicesAdminClient(statsResponse, null))) - val indexMetadataProvider = IndexMetadataProvider(client, clusterService, mutableMapOf()) + val indexMetadataProvider = IndexMetadataProvider(settings, client, clusterService, mutableMapOf()) runBlocking { val managedIndexMetadata = ManagedIndexMetaData(indexName, indexUUID, "policy_id", null, null, null, null, null, null, null, null, null, null, null) @@ -87,7 +87,7 @@ class AttemptTransitionStepTests : OpenSearchTestCase() { whenever(indexMetadata.creationDate).doReturn(5L) val exception = IllegalArgumentException("example") val client = getClient(getAdminClient(getIndicesAdminClient(null, exception))) - val indexMetadataProvider = IndexMetadataProvider(client, clusterService, mutableMapOf()) + val indexMetadataProvider = IndexMetadataProvider(settings, client, clusterService, mutableMapOf()) runBlocking { val managedIndexMetadata = ManagedIndexMetaData(indexName, indexUUID, "policy_id", null, null, null, null, null, null, null, null, null, null, null) @@ -105,7 +105,7 @@ class AttemptTransitionStepTests : OpenSearchTestCase() { whenever(indexMetadata.creationDate).doReturn(5L) val exception = RemoteTransportException("rte", IllegalArgumentException("nested")) val client = getClient(getAdminClient(getIndicesAdminClient(null, exception))) - val indexMetadataProvider = IndexMetadataProvider(client, clusterService, mutableMapOf()) + val indexMetadataProvider = IndexMetadataProvider(settings, client, clusterService, mutableMapOf()) runBlocking { val managedIndexMetadata = ManagedIndexMetaData(indexName, indexUUID, "policy_id", null, null, null, null, null, null, null, null, null, null, null) @@ -120,7 +120,7 @@ class AttemptTransitionStepTests : OpenSearchTestCase() { } fun `test step start time resetting between two transitions`() { - val indexMetadataProvider = IndexMetadataProvider(mock(), clusterService, mutableMapOf()) + val indexMetadataProvider = IndexMetadataProvider(settings, mock(), clusterService, mutableMapOf()) runBlocking { val completedStartTime = Instant.now() val managedIndexMetadata = ManagedIndexMetaData(indexName, indexUUID, "policy_id", null, null, null, null, null, null, null, null, StepMetaData("attempt_transition", completedStartTime.toEpochMilli(), Step.StepStatus.COMPLETED), null, null) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/explain/ExplainResponseTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/explain/ExplainResponseTests.kt index 03618e9f0..4df22f608 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/explain/ExplainResponseTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/explain/ExplainResponseTests.kt @@ -13,37 +13,6 @@ import org.opensearch.test.OpenSearchTestCase class ExplainResponseTests : OpenSearchTestCase() { fun `test explain response`() { - val indexNames = listOf("index1") - val indexPolicyIDs = listOf("policyID1") - val metadata = ManagedIndexMetaData( - index = "index1", - indexUuid = randomAlphaOfLength(10), - policyID = "policyID1", - policySeqNo = randomNonNegativeLong(), - policyPrimaryTerm = randomNonNegativeLong(), - policyCompleted = null, - rolledOver = null, - indexCreationDate = null, - transitionTo = randomAlphaOfLength(10), - stateMetaData = null, - actionMetaData = null, - stepMetaData = null, - policyRetryInfo = null, - info = null - ) - val indexMetadatas = listOf(metadata) - val res = ExplainResponse(indexNames, indexPolicyIDs, indexMetadatas) - - val out = BytesStreamOutput() - res.writeTo(out) - val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) - val newRes = ExplainResponse(sin) - assertEquals(indexNames, newRes.indexNames) - assertEquals(indexPolicyIDs, newRes.indexPolicyIDs) - assertEquals(indexMetadatas, newRes.indexMetadatas) - } - - fun `test explain all response`() { val indexNames = listOf("index1") val indexPolicyIDs = listOf("policyID1") val metadata = ManagedIndexMetaData( @@ -65,12 +34,12 @@ class ExplainResponseTests : OpenSearchTestCase() { val indexMetadatas = listOf(metadata) val totalManagedIndices = 1 val enabledState = mapOf("index1" to true) - val res = ExplainAllResponse(indexNames, indexPolicyIDs, indexMetadatas, totalManagedIndices, enabledState) + val res = ExplainResponse(indexNames, indexPolicyIDs, indexMetadatas, totalManagedIndices, enabledState) val out = BytesStreamOutput() res.writeTo(out) val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) - val newRes = ExplainAllResponse(sin) + val newRes = ExplainResponse(sin) assertEquals(indexNames, newRes.indexNames) assertEquals(indexPolicyIDs, newRes.indexPolicyIDs) assertEquals(indexMetadatas, newRes.indexMetadatas)