From af8f4c348b0e9bca677620da1af332331c8f3c92 Mon Sep 17 00:00:00 2001 From: Petar Dzepina Date: Wed, 31 Aug 2022 17:05:41 +0200 Subject: [PATCH] reduced pageSize to 1 in few ITs to avoid flaky tests; fixed bug where pagesProcessed was calculated incorrectly Signed-off-by: Petar Dzepina --- .../indexmanagement/transform/TransformSearchService.kt | 2 +- .../opensearch/indexmanagement/transform/TransformRunnerIT.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/transform/TransformSearchService.kt b/src/main/kotlin/org/opensearch/indexmanagement/transform/TransformSearchService.kt index 610538019..f42c22c1c 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/transform/TransformSearchService.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/transform/TransformSearchService.kt @@ -287,7 +287,7 @@ class TransformSearchService( val aggs = searchResponse.aggregations.get(transform.id) as CompositeAggregation val buckets = if (modifiedBuckets != null) aggs.buckets.filter { modifiedBuckets.contains(it.key) } else aggs.buckets val documentsProcessed = buckets.fold(0L) { sum, it -> sum + it.docCount } - val pagesProcessed = 1L + val pagesProcessed = if (buckets.isNotEmpty()) 1L else 0L val searchTime = searchResponse.took.millis val stats = TransformStats(pagesProcessed, documentsProcessed, 0, 0, searchTime) val afterKey = aggs.afterKey() diff --git a/src/test/kotlin/org/opensearch/indexmanagement/transform/TransformRunnerIT.kt b/src/test/kotlin/org/opensearch/indexmanagement/transform/TransformRunnerIT.kt index 9d18ef24f..bbf13cb86 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/transform/TransformRunnerIT.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/transform/TransformRunnerIT.kt @@ -46,7 +46,7 @@ class TransformRunnerIT : TransformRestTestCase() { sourceIndex = "transform-source-index", targetIndex = "transform-target-index", roles = emptyList(), - pageSize = 100, + pageSize = 1, groups = listOf( Terms(sourceField = "store_and_fwd_flag", targetField = "flag") ) @@ -86,7 +86,7 @@ class TransformRunnerIT : TransformRestTestCase() { sourceIndex = "transform-source-index", targetIndex = "transform-target-index", roles = emptyList(), - pageSize = 100, + pageSize = 1, groups = listOf( Terms(sourceField = "store_and_fwd_flag", targetField = "flag") ),