Skip to content

Commit

Permalink
Fix a test in rollup target alias change (opensearch-project#594)
Browse files Browse the repository at this point in the history
Signed-off-by: bowenlan-amzn <[email protected]>

Signed-off-by: bowenlan-amzn <[email protected]>
  • Loading branch information
bowenlan-amzn authored Nov 4, 2022
1 parent 7beec13 commit 98aa072
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class RollupMapperService(
@Suppress("ReturnCount")
suspend fun validateTargetIndexAlias(rollup: Rollup, targetIndexResolvedName: String): RollupJobValidationResult {

var errorMessage: String
val errorMessage: String

if (!RollupFieldValueExpressionResolver.indexAliasUtils.hasAlias(targetIndexResolvedName)) {
logger.error("[${rollup.targetIndex}] is not an alias!")
Expand All @@ -106,7 +106,7 @@ class RollupMapperService(
if (rollupJobs != null &&
(rollupJobs.size > 1 || rollupJobs[0].id != rollup.id)
) {
errorMessage = "More than one rollup job present on the backing index, cannot add alias for target index: [$targetIndexResolvedName]"
errorMessage = "More than one rollup jobs present on the backing index of the target alias, cannot perform rollup to this target alias [${rollup.targetIndex}]."
logger.error(errorMessage)
return RollupJobValidationResult.Failure(errorMessage)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package org.opensearch.indexmanagement.rollup.runner

import com.carrotsearch.randomizedtesting.RandomizedTest.sleep
import org.apache.http.entity.ContentType
import org.apache.http.entity.StringEntity
import org.opensearch.common.settings.Settings
Expand Down Expand Up @@ -1146,7 +1145,7 @@ class RollupRunnerIT : RollupRestTestCase() {

waitFor { assertTrue("Target rollup index was not created", indexExists(backingIndex1)) }

var startedRollup1 = waitFor {
val startedRollup1 = waitFor {
val rollupJob = getRollup(rollupId = job1.id)
assertNotNull("Rollup job doesn't have metadata set", rollupJob.metadataID)
val rollupMetadata = getRollupMetadata(rollupJob.metadataID!!)
Expand All @@ -1165,7 +1164,7 @@ class RollupRunnerIT : RollupRestTestCase() {
// Job2 First run, it should fail because job1 already wrote to backing index
updateRollupStartTime(job2)

var startedRollup2 = waitFor {
val startedRollup2 = waitFor {
val rollupJob = getRollup(rollupId = job2.id)
assertNotNull("Rollup job doesn't have metadata set", rollupJob.metadataID)
val rollupMetadata = getRollupMetadata(rollupJob.metadataID!!)
Expand All @@ -1175,7 +1174,7 @@ class RollupRunnerIT : RollupRestTestCase() {
}
rollupMetadataID = startedRollup2.metadataID!!
rollupMetadata = getRollupMetadata(rollupMetadataID)
assertEquals("If target_index is alias, write backing index must be used only by this rollup job: [$backingIndex1]", rollupMetadata.failureReason)
assertEquals("More than one rollup jobs present on the backing index of the target alias, cannot perform rollup to this target alias [$indexAlias].", rollupMetadata.failureReason)
}

fun `test rollup action with alias as target_index multiple empty backing indices`() {
Expand Down

0 comments on commit 98aa072

Please sign in to comment.