diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt index d0ec29321..bb8cf7829 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexRunner.kt @@ -537,6 +537,8 @@ object ManagedIndexRunner : val indexResponse: UpdateResponse = client.suspendUntil { update(indexRequest, it) } if (indexResponse.status() != RestStatus.OK) { logger.error("Failed to disable ManagedIndexConfig(${managedIndexConfig.index}) Error : indexResponse.status()") + } else { + logger.info("Successfully disabled ISM job for [${managedIndexConfig.index}]") } } catch (e: Exception) { logger.error("Failed to disable ManagedIndexConfig(${managedIndexConfig.index})", e) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/action/TransformActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/action/TransformActionIT.kt index a054d94bc..df1efd98b 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/action/TransformActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/action/TransformActionIT.kt @@ -26,6 +26,7 @@ import org.opensearch.indexmanagement.transform.avgAggregation import org.opensearch.indexmanagement.transform.maxAggregation import org.opensearch.indexmanagement.transform.minAggregation import org.opensearch.indexmanagement.transform.model.ISMTransform +import org.opensearch.indexmanagement.transform.model.Transform import org.opensearch.indexmanagement.transform.model.TransformMetadata import org.opensearch.indexmanagement.transform.sumAggregation import org.opensearch.indexmanagement.transform.valueCountAggregation @@ -274,6 +275,8 @@ class TransformActionIT : IndexStateManagementRestTestCase() { updateTransformStartTime(transform) + assertTransformCompleted(transform) + // Change the start time so that the transform action will be attempted. updateManagedIndexConfigStartTime(managedIndexConfig) waitFor { @@ -282,13 +285,6 @@ class TransformActionIT : IndexStateManagementRestTestCase() { getExplainManagedIndexMetaData(indexName).info?.get("message") ) } - - val transformJob = getTransform(transformId = transformId) - waitFor { - assertNotNull("Transform job doesn't have metadata set", transformJob.metadataId) - val transformMetadata = getTransformMetadata(transformJob.metadataId!!) - assertEquals("Transform is not finished", TransformMetadata.Status.FINISHED, transformMetadata.status) - } } private fun assertIndexTransformSucceededTwice(indexName: String, policyId: String, ismTransform: ISMTransform) { @@ -308,7 +304,8 @@ class TransformActionIT : IndexStateManagementRestTestCase() { getExplainManagedIndexMetaData(indexName).info?.get("message") ) } - updateTransformStartTime(transform) + + assertTransformCompleted(transform) // Change the start time so that the transform action will be attempted. updateManagedIndexConfigStartTime(managedIndexConfig) @@ -319,13 +316,6 @@ class TransformActionIT : IndexStateManagementRestTestCase() { ) } - var transformJob = getTransform(transformId = transformId) - waitFor { - assertNotNull("Transform job doesn't have metadata set", transformJob.metadataId) - val transformMetadata = getTransformMetadata(transformJob.metadataId!!) - assertEquals("Transform is not finished", TransformMetadata.Status.FINISHED, transformMetadata.status) - } - // Change the start time so that the transition attempted. updateManagedIndexConfigStartTime(managedIndexConfig) waitFor { @@ -343,7 +333,8 @@ class TransformActionIT : IndexStateManagementRestTestCase() { getExplainManagedIndexMetaData(indexName).info?.get("message") ) } - updateTransformStartTime(transform) + + assertTransformCompleted(transform) // Change the start time so that the second transform action will be attempted. updateManagedIndexConfigStartTime(managedIndexConfig) @@ -353,9 +344,12 @@ class TransformActionIT : IndexStateManagementRestTestCase() { getExplainManagedIndexMetaData(indexName).info?.get("message") ) } + } - transformJob = getTransform(transformId = transformId) - waitFor { + private fun assertTransformCompleted(transform: Transform) { + updateTransformStartTime(transform) + waitFor(timeout = Instant.ofEpochSecond(60)) { + val transformJob = getTransform(transformId = transform.id) assertNotNull("Transform job doesn't have metadata set", transformJob.metadataId) val transformMetadata = getTransformMetadata(transformJob.metadataId!!) assertEquals("Transform is not finished", TransformMetadata.Status.FINISHED, transformMetadata.status)