From 1933b897a5209af8fac304bf5e770d6e7a456226 Mon Sep 17 00:00:00 2001 From: Robert Downs Date: Thu, 13 Jan 2022 22:10:08 +0000 Subject: [PATCH] fixes flaky rollup/transform explain IT Signed-off-by: Robert Downs --- .../resthandler/RestExplainRollupActionIT.kt | 22 +++++++++---------- .../RestExplainTransformActionIT.kt | 22 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestExplainRollupActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestExplainRollupActionIT.kt index 0daf3c4bc..4baab606d 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestExplainRollupActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/rollup/resthandler/RestExplainRollupActionIT.kt @@ -89,7 +89,7 @@ class RestExplainRollupActionIT : RollupRestTestCase() { @Throws(Exception::class) fun `test explain rollup for nonexistent id`() { // Creating a rollup so the config index exists - createRollup(rollup = randomRollup(), rollupId = "doesnt_exist_some_other_id") + createRollup(rollup = randomRollup(), rollupId = "doesnt_exist_some_other_rollup_id") val response = client().makeRequest("GET", "$ROLLUP_JOBS_BASE_URI/doesnt_exist/_explain") assertNull("Nonexistent rollup didn't return null", response.asMap()["doesnt_exist"]) } @@ -97,30 +97,30 @@ class RestExplainRollupActionIT : RollupRestTestCase() { @Throws(Exception::class) fun `test explain rollup for wildcard id`() { // Creating a rollup so the config index exists - createRollup(rollup = randomRollup(), rollupId = "wildcard_some_id") - createRollup(rollup = randomRollup(), rollupId = "wildcard_some_other_id") + createRollup(rollup = randomRollup(), rollupId = "wildcard_some_rollup_id") + createRollup(rollup = randomRollup(), rollupId = "wildcard_some_other_rollup_id") val response = client().makeRequest("GET", "$ROLLUP_JOBS_BASE_URI/wildcard_some*/_explain") // We don't expect there to always be metadata as we are creating random rollups and the job isn't running // but we do expect the wildcard some* to expand to the two jobs created above and have non-null values (meaning they exist) val map = response.asMap() - assertNotNull("Non null wildcard_some_id value wasn't in the response", map["wildcard_some_id"]) - assertNotNull("Non null wildcard_some_other_id value wasn't in the response", map["wildcard_some_other_id"]) + assertNotNull("Non null wildcard_some_rollup_id value wasn't in the response", map["wildcard_some_rollup_id"]) + assertNotNull("Non null wildcard_some_other_rollup_id value wasn't in the response", map["wildcard_some_other_rollup_id"]) } @Throws(Exception::class) fun `test explain rollup for job that hasnt started`() { - createRollup(rollup = randomRollup().copy(metadataID = null), rollupId = "not_started_some_id") - val response = client().makeRequest("GET", "$ROLLUP_JOBS_BASE_URI/not_started_some_id/_explain") - val expectedMap = mapOf("not_started_some_id" to mapOf("metadata_id" to null, "rollup_metadata" to null)) + createRollup(rollup = randomRollup().copy(metadataID = null), rollupId = "not_started_some_rollup_id") + val response = client().makeRequest("GET", "$ROLLUP_JOBS_BASE_URI/not_started_some_rollup_id/_explain") + val expectedMap = mapOf("not_started_some_rollup_id" to mapOf("metadata_id" to null, "rollup_metadata" to null)) assertEquals("The explain response did not match expected", expectedMap, response.asMap()) } @Throws(Exception::class) fun `test explain rollup for metadata_id but no metadata`() { // This is to test the case of a rollup existing with a metadataID but there being no metadata document - createRollup(rollup = randomRollup().copy(metadataID = "some_metadata_id"), rollupId = "no_meta_some_id") - val response = client().makeRequest("GET", "$ROLLUP_JOBS_BASE_URI/no_meta_some_id/_explain") - val expectedMap = mapOf("no_meta_some_id" to mapOf("metadata_id" to "some_metadata_id", "rollup_metadata" to null)) + createRollup(rollup = randomRollup().copy(metadataID = "some_metadata_id"), rollupId = "no_meta_some_rollup_id") + val response = client().makeRequest("GET", "$ROLLUP_JOBS_BASE_URI/no_meta_some_rollup_id/_explain") + val expectedMap = mapOf("no_meta_some_rollup_id" to mapOf("metadata_id" to "some_metadata_id", "rollup_metadata" to null)) assertEquals("The explain response did not match expected", expectedMap, response.asMap()) } diff --git a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt index 7f00fddc0..be305aae6 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/resthandler/RestExplainTransformActionIT.kt @@ -73,7 +73,7 @@ class RestExplainTransformActionIT : TransformRestTestCase() { @Throws(Exception::class) fun `test explain transform for nonexistent id`() { // Creating a transform so the config index exists - createTransform(transform = randomTransform(), transformId = "doesnt_exist_some_other_id") + createTransform(transform = randomTransform(), transformId = "doesnt_exist_some_other_transform_id") val response = client().makeRequest("GET", "$TRANSFORM_BASE_URI/doesnt_exist/_explain") assertNull("Nonexistent transform didn't return null", response.asMap()["doesnt_exist"]) } @@ -81,29 +81,29 @@ class RestExplainTransformActionIT : TransformRestTestCase() { @Throws(Exception::class) fun `test explain transform for wildcard id`() { // Creating a transform so the config index exists - createTransform(transform = randomTransform(), transformId = "wildcard_some_id") - createTransform(transform = randomTransform(), transformId = "wildcard_some_other_id") + createTransform(transform = randomTransform(), transformId = "wildcard_some_transform_id") + createTransform(transform = randomTransform(), transformId = "wildcard_some_other_transform_id") val response = client().makeRequest("GET", "$TRANSFORM_BASE_URI/wildcard_some*/_explain") // We don't expect there to always be metadata we are creating random transforms and the job isn't running // but we do expect the wildcard some* to expand to the two jobs created above and have non-null values (meaning they exist) val map = response.asMap() - assertNotNull("Non null wildcard_some_id value wasn't in the response", map["wildcard_some_id"]) - assertNotNull("Non null wildcard_some_other_id value wasn't in the response", map["wildcard_some_other_id"]) + assertNotNull("Non null wildcard_some_transform_id value wasn't in the response", map["wildcard_some_transform_id"]) + assertNotNull("Non null wildcard_some_other_transform_id value wasn't in the response", map["wildcard_some_other_transform_id"]) } @Throws(Exception::class) fun `test explain transform for job that hasnt started`() { - createTransform(transform = randomTransform().copy(metadataId = null), transformId = "not_started_some_id") - val response = client().makeRequest("GET", "$TRANSFORM_BASE_URI/not_started_some_id/_explain") - val expectedMap = mapOf("not_started_some_id" to mapOf("metadata_id" to null, "transform_metadata" to null)) + createTransform(transform = randomTransform().copy(metadataId = null), transformId = "not_started_some_transform_id") + val response = client().makeRequest("GET", "$TRANSFORM_BASE_URI/not_started_some_transform_id/_explain") + val expectedMap = mapOf("not_started_some_transform_id" to mapOf("metadata_id" to null, "transform_metadata" to null)) assertEquals("The explain response did not match expected", expectedMap, response.asMap()) } @Throws(Exception::class) fun `test explain transform for new transform attempted to create with metadata id`() { - createTransform(transform = randomTransform().copy(metadataId = "some_metadata_id"), transformId = "no_meta_some_id") - val response = client().makeRequest("GET", "$TRANSFORM_BASE_URI/no_meta_some_id/_explain") - val expectedMap = mapOf("no_meta_some_id" to mapOf("metadata_id" to null, "transform_metadata" to null)) + createTransform(transform = randomTransform().copy(metadataId = "some_metadata_id"), transformId = "no_meta_some_transform_id") + val response = client().makeRequest("GET", "$TRANSFORM_BASE_URI/no_meta_some_transform_id/_explain") + val expectedMap = mapOf("no_meta_some_transform_id" to mapOf("metadata_id" to null, "transform_metadata" to null)) assertEquals("The explain response did not match expected", expectedMap, response.asMap()) }