Skip to content

Commit

Permalink
Fixes test disabling and reenabling ism flakiness
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Downs <[email protected]>
  • Loading branch information
downsrob committed Dec 6, 2021
1 parent 8408320 commit bc08240
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ abstract class IndexStateManagementRestTestCase : IndexManagementRestTestCase()
}
}

protected fun updateManagedIndexConfigStartTime(update: ManagedIndexConfig, desiredStartTimeMillis: Long? = null) {
protected fun updateManagedIndexConfigStartTime(update: ManagedIndexConfig, desiredStartTimeMillis: Long? = null, retryOnConflict: Int = 0) {
// Before updating start time of a job always make sure there are no unassigned shards that could cause the config
// index to move to a new node and negate this forced start
if (isMultiNode) {
Expand All @@ -379,8 +379,9 @@ abstract class IndexStateManagementRestTestCase : IndexManagementRestTestCase()
val millis = Duration.of(intervalSchedule.interval.toLong(), intervalSchedule.unit).minusSeconds(2).toMillis()
val startTimeMillis = desiredStartTimeMillis ?: Instant.now().toEpochMilli() - millis
val waitForActiveShards = if (isMultiNode) "all" else "1"
val endpoint = "$INDEX_MANAGEMENT_INDEX/_update/${update.id}?wait_for_active_shards=$waitForActiveShards;retry_on_conflict=$retryOnConflict"
val response = client().makeRequest(
"POST", "$INDEX_MANAGEMENT_INDEX/_update/${update.id}?wait_for_active_shards=$waitForActiveShards",
"POST", endpoint,
StringEntity(
"{\"doc\":{\"managed_index\":{\"schedule\":{\"interval\":{\"start_time\":" +
"\"$startTimeMillis\"}}}}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ class ManagedIndexCoordinatorIT : IndexStateManagementRestTestCase() {
// Confirm job was disabled
val disabledManagedIndexConfig: ManagedIndexConfig = waitFor {
val config = getManagedIndexConfigByDocId(managedIndexConfig.id)
assertNotNull("Could not find ManagedIndexConfig", config)
assertEquals("ManagedIndexConfig was not disabled", false, config!!.enabled)
config
}
Expand Down Expand Up @@ -230,16 +229,12 @@ class ManagedIndexCoordinatorIT : IndexStateManagementRestTestCase() {

// Confirm job was re-enabled
val enabledManagedIndexConfig: ManagedIndexConfig = waitFor {
val config = getExistingManagedIndexConfig(indexName)
assertEquals("ManagedIndexConfig was not re-enabled", true, config.enabled)
val config = getManagedIndexConfigByDocId(disabledManagedIndexConfig.id)
assertEquals("ManagedIndexConfig was not re-enabled", true, config!!.enabled)
config
}

// TODO seen version conflict flaky failure here
logger.info("Config we use on update: $enabledManagedIndexConfig")
logger.info("Latest config: ${getExistingManagedIndexConfig(indexName)}")
// seems the config from above waitFor, after that, config got updated again?
updateManagedIndexConfigStartTime(enabledManagedIndexConfig)
updateManagedIndexConfigStartTime(enabledManagedIndexConfig, retryOnConflict = 4)

waitFor {
assertEquals(
Expand Down

0 comments on commit bc08240

Please sign in to comment.