55
66package org .opensearch .sql .ppl ;
77
8- import static org .opensearch .sql .legacy .TestsConstants .TEST_INDEX_DOG ;
9- import static org .opensearch .sql .util .MatcherUtils .columnName ;
10- import static org .opensearch .sql .util .MatcherUtils .verifyColumn ;
8+ import static org .opensearch .sql .util .MatcherUtils .verifyNumOfRows ;
119
1210import java .io .IOException ;
1311import org .hamcrest .Matchers ;
@@ -21,17 +19,19 @@ public class ResourceMonitorIT extends PPLIntegTestCase {
2119 @ Override
2220 public void init () throws Exception {
2321 super .init ();
24- loadIndex (Index .DOG );
22+ loadIndex (Index .CLICK_BENCH );
2523 }
2624
2725 @ Test
2826 public void queryExceedResourceLimitShouldFail () throws IOException {
2927 // update plugins.ppl.query.memory_limit to 1%
3028 updateClusterSettings (
3129 new ClusterSetting ("persistent" , Settings .Key .QUERY_MEMORY_LIMIT .getKeyValue (), "1%" ));
32- String query = String .format ("search source=%s age=20" , TEST_INDEX_DOG );
30+ // ClickBench Q30 is high memory consumption query.
31+ String query = sanitize (loadFromFile ("clickbench/queries/q30.ppl" ));
3332
34- ResponseException exception = expectThrows (ResponseException .class , () -> executeQuery (query ));
33+ ResponseException exception =
34+ expectThrows (ResponseException .class , () -> executeQueryMultipleTimes (query ));
3535 assertEquals (500 , exception .getResponse ().getStatusLine ().getStatusCode ());
3636 assertThat (
3737 exception .getMessage (),
@@ -40,7 +40,14 @@ public void queryExceedResourceLimitShouldFail() throws IOException {
4040 // update plugins.ppl.query.memory_limit to default value 85%
4141 updateClusterSettings (
4242 new ClusterSetting ("persistent" , Settings .Key .QUERY_MEMORY_LIMIT .getKeyValue (), "85%" ));
43- JSONObject result = executeQuery (String .format ("search source=%s" , TEST_INDEX_DOG ));
44- verifyColumn (result , columnName ("dog_name" ), columnName ("holdersName" ), columnName ("age" ));
43+ executeQueryMultipleTimes (query );
44+ }
45+
46+ /** Run the same query multiple times in case GC can be triggered in integration test */
47+ private void executeQueryMultipleTimes (String query ) throws IOException {
48+ for (int i = 0 ; i < 10 ; i ++) {
49+ JSONObject result = executeQuery (query );
50+ verifyNumOfRows (result , 1 );
51+ }
4552 }
4653}
0 commit comments