From cb783ca21e7cb0f46b689801cf77c5bba9fefff2 Mon Sep 17 00:00:00 2001 From: bowenlan-amzn Date: Wed, 11 Oct 2023 09:47:25 -0700 Subject: [PATCH] [Test] increase the wait time after transform job triggered (#999) Signed-off-by: bowenlan-amzn --- .../action/TransformActionIT.kt | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) 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 41e95d0df..386e47407 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)