Skip to content

Commit

Permalink
Fix flaky testTerminateAfterEarlyTermination (opensearch-project#11683)
Browse files Browse the repository at this point in the history
Signed-off-by: Ticheng Lin <[email protected]>
  • Loading branch information
ticheng-aws authored Jan 3, 2024
1 parent 7b1c2c7 commit bb3959d
Showing 1 changed file with 52 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -615,12 +615,22 @@ public void testTerminateAfterEarlyTermination() throws Exception {
assertThat(query.getTimeBreakdown().get("score"), greaterThan(0L));
assertThat(query.getTimeBreakdown().get("score_count"), greaterThan(0L));
if (executor != null) {
assertThat(query.getTimeBreakdown().get("max_score"), greaterThan(0L));
assertThat(query.getTimeBreakdown().get("min_score"), greaterThan(0L));
assertThat(query.getTimeBreakdown().get("avg_score"), greaterThan(0L));
assertThat(query.getTimeBreakdown().get("max_score_count"), greaterThan(0L));
assertThat(query.getTimeBreakdown().get("min_score_count"), greaterThan(0L));
assertThat(query.getTimeBreakdown().get("avg_score_count"), greaterThan(0L));
long maxScore = query.getTimeBreakdown().get("max_score");
long minScore = query.getTimeBreakdown().get("min_score");
long avgScore = query.getTimeBreakdown().get("avg_score");
long maxScoreCount = query.getTimeBreakdown().get("max_score_count");
long minScoreCount = query.getTimeBreakdown().get("min_score_count");
long avgScoreCount = query.getTimeBreakdown().get("avg_score_count");
assertThat(maxScore, greaterThan(0L));
assertThat(minScore, greaterThanOrEqualTo(0L));
assertThat(avgScore, greaterThanOrEqualTo(0L));
assertThat(maxScore, greaterThanOrEqualTo(avgScore));
assertThat(avgScore, greaterThanOrEqualTo(minScore));
assertThat(maxScoreCount, greaterThan(0L));
assertThat(minScoreCount, greaterThanOrEqualTo(0L));
assertThat(avgScoreCount, greaterThanOrEqualTo(0L));
assertThat(maxScoreCount, greaterThanOrEqualTo(avgScoreCount));
assertThat(avgScoreCount, greaterThanOrEqualTo(minScoreCount));
}
assertThat(query.getTimeBreakdown().get("create_weight"), greaterThan(0L));
assertThat(query.getTimeBreakdown().get("create_weight_count"), equalTo(1L));
Expand Down Expand Up @@ -744,30 +754,50 @@ public void testTerminateAfterEarlyTermination() throws Exception {
assertThat(query.getProfiledChildren().get(0).getTime(), greaterThan(0L));
assertThat(query.getProfiledChildren().get(0).getTimeBreakdown().get("create_weight"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(0).getTimeBreakdown().get("create_weight_count"), equalTo(1L));
assertThat(query.getProfiledChildren().get(0).getTimeBreakdown().get("score"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(0).getTimeBreakdown().get("score_count"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(0).getTimeBreakdown().get("score"), greaterThanOrEqualTo(0L));
assertThat(query.getProfiledChildren().get(0).getTimeBreakdown().get("score_count"), greaterThanOrEqualTo(0L));
if (executor != null) {
assertThat(query.getProfiledChildren().get(0).getTimeBreakdown().get("max_score"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(0).getTimeBreakdown().get("min_score"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(0).getTimeBreakdown().get("avg_score"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(0).getTimeBreakdown().get("max_score_count"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(0).getTimeBreakdown().get("min_score_count"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(0).getTimeBreakdown().get("avg_score_count"), greaterThan(0L));
long maxScore = query.getProfiledChildren().get(0).getTimeBreakdown().get("max_score");
long minScore = query.getProfiledChildren().get(0).getTimeBreakdown().get("min_score");
long avgScore = query.getProfiledChildren().get(0).getTimeBreakdown().get("avg_score");
long maxScoreCount = query.getProfiledChildren().get(0).getTimeBreakdown().get("max_score_count");
long minScoreCount = query.getProfiledChildren().get(0).getTimeBreakdown().get("min_score_count");
long avgScoreCount = query.getProfiledChildren().get(0).getTimeBreakdown().get("avg_score_count");
assertThat(maxScore, greaterThanOrEqualTo(0L));
assertThat(minScore, greaterThanOrEqualTo(0L));
assertThat(avgScore, greaterThanOrEqualTo(0L));
assertThat(maxScore, greaterThanOrEqualTo(avgScore));
assertThat(avgScore, greaterThanOrEqualTo(minScore));
assertThat(maxScoreCount, greaterThanOrEqualTo(0L));
assertThat(minScoreCount, greaterThanOrEqualTo(0L));
assertThat(avgScoreCount, greaterThanOrEqualTo(0L));
assertThat(maxScoreCount, greaterThanOrEqualTo(avgScoreCount));
assertThat(avgScoreCount, greaterThanOrEqualTo(minScoreCount));
}

assertThat(query.getProfiledChildren().get(1).getQueryName(), equalTo("TermQuery"));
assertThat(query.getProfiledChildren().get(1).getTime(), greaterThan(0L));
assertThat(query.getProfiledChildren().get(1).getTimeBreakdown().get("create_weight"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(1).getTimeBreakdown().get("create_weight_count"), equalTo(1L));
assertThat(query.getProfiledChildren().get(1).getTimeBreakdown().get("score"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(1).getTimeBreakdown().get("score_count"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(1).getTimeBreakdown().get("score"), greaterThanOrEqualTo(0L));
assertThat(query.getProfiledChildren().get(1).getTimeBreakdown().get("score_count"), greaterThanOrEqualTo(0L));
if (executor != null) {
assertThat(query.getProfiledChildren().get(1).getTimeBreakdown().get("max_score"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(1).getTimeBreakdown().get("min_score"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(1).getTimeBreakdown().get("avg_score"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(1).getTimeBreakdown().get("max_score_count"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(1).getTimeBreakdown().get("min_score_count"), greaterThan(0L));
assertThat(query.getProfiledChildren().get(1).getTimeBreakdown().get("avg_score_count"), greaterThan(0L));
long maxScore = query.getProfiledChildren().get(1).getTimeBreakdown().get("max_score");
long minScore = query.getProfiledChildren().get(1).getTimeBreakdown().get("min_score");
long avgScore = query.getProfiledChildren().get(1).getTimeBreakdown().get("avg_score");
long maxScoreCount = query.getProfiledChildren().get(1).getTimeBreakdown().get("max_score_count");
long minScoreCount = query.getProfiledChildren().get(1).getTimeBreakdown().get("min_score_count");
long avgScoreCount = query.getProfiledChildren().get(1).getTimeBreakdown().get("avg_score_count");
assertThat(maxScore, greaterThanOrEqualTo(0L));
assertThat(minScore, greaterThanOrEqualTo(0L));
assertThat(avgScore, greaterThanOrEqualTo(0L));
assertThat(maxScore, greaterThanOrEqualTo(avgScore));
assertThat(avgScore, greaterThanOrEqualTo(minScore));
assertThat(maxScoreCount, greaterThanOrEqualTo(0L));
assertThat(minScoreCount, greaterThanOrEqualTo(0L));
assertThat(avgScoreCount, greaterThanOrEqualTo(0L));
assertThat(maxScoreCount, greaterThanOrEqualTo(avgScoreCount));
assertThat(avgScoreCount, greaterThanOrEqualTo(minScoreCount));
}
}, collector -> {
assertThat(collector.getReason(), equalTo("search_terminate_after_count"));
Expand Down

0 comments on commit bb3959d

Please sign in to comment.