Skip to content

Commit 7267d03

Browse files
author
Andre van de Ven
committed
fixed test to allow for multiple fetch breakdowns for the same aggregation due to concurrency
Signed-off-by: Andre van de Ven <[email protected]>
1 parent c8e2ae1 commit 7267d03

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,17 +1039,21 @@ public void testTopHitsAggregationFetchProfiling() throws Exception {
10391039
if ("fetch".equals(result.getQueryName())) {
10401040
mainFetchCount++;
10411041
} else if (result.getQueryName().contains("top_hits_agg1")) {
1042-
topHitsFetch1 = result;
1042+
if (topHitsFetch1 == null) {
1043+
topHitsFetch1 = result; // Keep first instance for validation
1044+
}
10431045
topHitsAgg1Count++;
10441046
} else if (result.getQueryName().contains("top_hits_agg2")) {
1045-
topHitsFetch2 = result;
1047+
if (topHitsFetch2 == null) {
1048+
topHitsFetch2 = result; // Keep first instance for validation
1049+
}
10461050
topHitsAgg2Count++;
10471051
}
10481052
}
10491053

1050-
// Verify we have the expected top_hits aggregations (the main requirement)
1051-
assertEquals("Should have exactly 1 top_hits_agg1 fetch operation", 1, topHitsAgg1Count);
1052-
assertEquals("Should have exactly 1 top_hits_agg2 fetch operation", 1, topHitsAgg2Count);
1054+
// Verify we have the expected aggregations (concurrent search may create multiple instances)
1055+
assertTrue("Should have at least 1 top_hits_agg1 fetch operation", topHitsAgg1Count >= 1);
1056+
assertTrue("Should have at least 1 top_hits_agg2 fetch operation", topHitsAgg2Count >= 1);
10531057
assertTrue("Should have at least one main fetch operation", mainFetchCount >= 1);
10541058
assertTrue("Should have at least 3 total fetch operations", fetchProfileResults.size() >= 3);
10551059

0 commit comments

Comments
 (0)