55
66package org .opensearch .sql .legacy ;
77
8- import static org .opensearch .sql .common .setting .Settings .Key ;
98import static org .opensearch .sql .legacy .TestUtils .getResponseBody ;
109import static org .opensearch .sql .legacy .TestsConstants .PERSISTENT ;
1110import static org .opensearch .sql .legacy .TestsConstants .TRANSIENT ;
4948import org .opensearch .common .xcontent .XContentFactory ;
5049import org .opensearch .core .rest .RestStatus ;
5150import org .opensearch .core .xcontent .XContentBuilder ;
51+ import org .opensearch .script .ScriptService ;
5252import org .opensearch .test .rest .OpenSearchRestTestCase ;
5353
5454/**
@@ -75,7 +75,8 @@ public abstract class OpenSearchSQLRestTestCase extends OpenSearchRestTestCase {
7575 + " }"
7676 + "}"
7777 + "}" ;
78-
78+ private static final String SCRIPT_CONTEXT_MAX_COMPILATIONS_RATE_PATTERN =
79+ "script.context.*.max_compilations_rate" ;
7980 private static RestClient remoteClient ;
8081
8182 /**
@@ -152,7 +153,7 @@ public RestClient initClient(String clusterName) throws IOException {
152153 builder .put (CLIENT_PATH_PREFIX , System .getProperty ("tests.rest.client_path_prefix" ));
153154 }
154155 // Disable max compilations rate to avoid hitting compilations threshold during tests
155- builder .put (Key . SCRIPT_DISABLE_MAX_COMPILATIONS_RATE . getKeyValue (), "true" );
156+ builder .put (ScriptService . SCRIPT_DISABLE_MAX_COMPILATIONS_RATE_SETTING . getKey (), "true" );
156157 return buildClient (builder .build (), hosts .toArray (new HttpHost [0 ]));
157158 }
158159
@@ -333,17 +334,12 @@ protected void increaseMaxCompilationsRate() throws IOException {
333334 // set
334335 if (!Objects .equals (
335336 getClusterSetting (
336- org .opensearch .sql .common .setting .Settings .Key .SCRIPT_DISABLE_MAX_COMPILATIONS_RATE
337- .getKeyValue (),
338- "persistent" ),
337+ ScriptService .SCRIPT_DISABLE_MAX_COMPILATIONS_RATE_SETTING .getKey (), "persistent" ),
339338 "true" )) {
340339 List <String > contexts = getScriptContexts ();
341340 for (String context : contexts ) {
342341 String contextCompilationsRate =
343- org .opensearch .sql .common .setting .Settings .Key
344- .SCRIPT_CONTEXT_MAX_COMPILATIONS_RATE_PATTERN
345- .getKeyValue ()
346- .replace ("*" , context );
342+ SCRIPT_CONTEXT_MAX_COMPILATIONS_RATE_PATTERN .replace ("*" , context );
347343 updateClusterSetting (contextCompilationsRate , "unlimited" , true );
348344 }
349345 }
0 commit comments