-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor code and add additional ITs
Signed-off-by: Siddhant Deshmukh <[email protected]>
- Loading branch information
Showing
5 changed files
with
155 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/test/java/org/opensearch/plugin/insights/core/service/grouper/MinMaxQueryGrouperIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package org.opensearch.plugin.insights.core.service.grouper; | ||
|
||
import org.junit.Assert; | ||
import org.opensearch.plugin.insights.QueryInsightsRestTestCase; | ||
import org.opensearch.plugin.insights.settings.QueryInsightsSettings; | ||
|
||
import java.io.IOException; | ||
|
||
public class MinMaxQueryGrouperIT extends QueryInsightsRestTestCase { | ||
/** | ||
* Grouping by none should not group queries | ||
* @throws IOException | ||
* @throws InterruptedException | ||
*/ | ||
public void testNoneToSimilarityGroupingTransition() throws IOException, InterruptedException { | ||
|
||
waitForEmptyTopQueriesResponse(); | ||
|
||
updateClusterSettings(this::defaultTopQueriesSettings); | ||
|
||
// Search | ||
doSearch("range", 2); | ||
doSearch("match", 6); | ||
doSearch("term", 4); | ||
|
||
assertTopQueriesCount(12, "latency"); | ||
|
||
updateClusterSettings(this::defaultTopQueryGroupingSettings); | ||
|
||
// Top queries should be drained due to grouping change from NONE -> SIMILARITY | ||
assertTopQueriesCount(0, "latency"); | ||
|
||
// Search | ||
doSearch("range", 2); | ||
doSearch("match", 6); | ||
doSearch("term", 4); | ||
|
||
// 3 groups | ||
assertTopQueriesCount(3, "latency"); | ||
} | ||
|
||
public void testSimilarityToNoneGroupingTransition() throws IOException, InterruptedException { | ||
|
||
waitForEmptyTopQueriesResponse(); | ||
|
||
updateClusterSettings(this::defaultTopQueryGroupingSettings); | ||
|
||
// Search | ||
doSearch("range", 2); | ||
doSearch("match", 6); | ||
doSearch("term", 4); | ||
|
||
assertTopQueriesCount(3, "latency"); | ||
|
||
updateClusterSettings(this::defaultTopQueriesSettings); | ||
|
||
// Top queries should be drained due to grouping change from SIMILARITY -> NONE | ||
assertTopQueriesCount(0, "latency"); | ||
|
||
// Search | ||
doSearch("range", 2); | ||
doSearch("match", 6); | ||
doSearch("term", 4); | ||
|
||
assertTopQueriesCount(12, "latency"); | ||
} | ||
|
||
public void testSimilarityMaxGroupsChanged() throws IOException, InterruptedException { | ||
|
||
waitForEmptyTopQueriesResponse(); | ||
|
||
updateClusterSettings(this::defaultTopQueryGroupingSettings); | ||
|
||
// Search | ||
doSearch("range", 2); | ||
doSearch("match", 6); | ||
doSearch("term", 4); | ||
|
||
assertTopQueriesCount(3, "latency"); | ||
|
||
// Change max groups exluding topn setting | ||
updateClusterSettings(this::updateMaxGroupsExcludingTopNSetting); | ||
|
||
// Top queries should be drained due to max group change | ||
assertTopQueriesCount(0, "latency"); | ||
|
||
// Search | ||
doSearch("range", 2); | ||
doSearch("match", 6); | ||
doSearch("term", 4); | ||
|
||
assertTopQueriesCount(3, "latency"); | ||
} | ||
|
||
protected String updateMaxGroupsExcludingTopNSetting() { | ||
return "{\n" | ||
+ " \"persistent\" : {\n" | ||
+ " \"search.insights.top_queries.max_groups_excluding_topn\" : 1\n" | ||
+ " }\n" | ||
+ "}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters