Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the race condition in test reset action start time #1007

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedInde
import org.opensearch.indexmanagement.waitFor
import org.opensearch.rest.RestRequest
import org.opensearch.core.rest.RestStatus
import org.opensearch.indexmanagement.indexstatemanagement.step.forcemerge.AttemptSetReadOnlyStep
import java.time.Instant
import java.util.Locale

Expand Down Expand Up @@ -257,20 +258,19 @@ class RestRetryFailedManagedIndexActionIT : IndexStateManagementRestTestCase() {
val action = randomForceMergeActionConfig(maxNumSegments = 1)
action.configRetry = ActionRetry(0)
val policy = randomPolicy(states = listOf(randomState(actions = listOf(action))))

createPolicy(policy, policyId = policyID)
createIndex(indexName, policyID)

val managedIndexConfig = getExistingManagedIndexConfig(indexName)

// init policy on job
updateManagedIndexConfigStartTime(managedIndexConfig)

// verify we have policy
waitFor { assertEquals(policyID, getExplainManagedIndexMetaData(indexName).policyID) }

// speed up to execute set read only force merge step
updateManagedIndexConfigStartTime(managedIndexConfig)

waitFor {
assertPredicatesOnMetaData(
listOf(
Expand All @@ -294,7 +294,6 @@ class RestRetryFailedManagedIndexActionIT : IndexStateManagementRestTestCase() {

// speed up to execute attempt call force merge step
updateManagedIndexConfigStartTime(managedIndexConfig)

// verify failed and save the startTime
var firstStartTime: Long = Long.MAX_VALUE
waitFor {
Expand Down Expand Up @@ -331,7 +330,6 @@ class RestRetryFailedManagedIndexActionIT : IndexStateManagementRestTestCase() {
FAILED_INDICES to emptyList<Map<String, Any>>()
)
assertAffectedIndicesResponseIsEqual(expectedErrorMessage, response.asMap())

// verify actionStartTime was reset to null
assertPredicatesOnMetaData(
listOf(
Expand All @@ -348,7 +346,6 @@ class RestRetryFailedManagedIndexActionIT : IndexStateManagementRestTestCase() {

// should execute and set the startTime again
updateManagedIndexConfigStartTime(managedIndexConfig)

// the new startTime should be greater than the first start time
waitFor {
assertPredicatesOnMetaData(
Expand All @@ -363,6 +360,10 @@ class RestRetryFailedManagedIndexActionIT : IndexStateManagementRestTestCase() {
),
getExplainMap(indexName), false
)
assertEquals(
AttemptSetReadOnlyStep.getSuccessMessage(indexName),
getExplainManagedIndexMetaData(indexName).info?.get("message")
)
}
}
}
Loading