-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional grouping ITs and refactor (#89)
Signed-off-by: Siddhant Deshmukh <[email protected]>
- Loading branch information
Showing
5 changed files
with
176 additions
and
99 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
106 changes: 106 additions & 0 deletions
106
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,106 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
package org.opensearch.plugin.insights.core.service.grouper; | ||
|
||
import java.io.IOException; | ||
import org.opensearch.plugin.insights.QueryInsightsRestTestCase; | ||
|
||
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