Skip to content

Commit

Permalink
fixes flaky rollup/transform explain IT
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Downs <downsrob@amazon.com>
  • Loading branch information
downsrob committed Jan 14, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent ed11e18 commit 1933b89
Showing 2 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -89,38 +89,38 @@ 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"])
}

@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())
}

Original file line number Diff line number Diff line change
@@ -73,37 +73,37 @@ 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"])
}

@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())
}

0 comments on commit 1933b89

Please sign in to comment.