-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop compile limit on runtime fields scripts (#61297)
This opts all of the script contexts used by `runtime_script` our of the compilation rate limiting because it'd be lame to prevent a mapping update because we can't compile the script.
- Loading branch information
Showing
13 changed files
with
209 additions
and
63 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
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
32 changes: 32 additions & 0 deletions
32
...ds/src/test/java/org/elasticsearch/xpack/runtimefields/BooleanScriptFieldScriptTests.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,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.runtimefields; | ||
|
||
import org.elasticsearch.script.ScriptContext; | ||
|
||
public class BooleanScriptFieldScriptTests extends ScriptFieldScriptTestCase<BooleanScriptFieldScript.Factory> { | ||
public static final BooleanScriptFieldScript.Factory DUMMY = (params, lookup) -> ctx -> new BooleanScriptFieldScript( | ||
params, | ||
lookup, | ||
ctx | ||
) { | ||
@Override | ||
public void execute() { | ||
new BooleanScriptFieldScript.Value(this).value(false); | ||
} | ||
}; | ||
|
||
@Override | ||
protected ScriptContext<BooleanScriptFieldScript.Factory> context() { | ||
return BooleanScriptFieldScript.CONTEXT; | ||
} | ||
|
||
@Override | ||
protected BooleanScriptFieldScript.Factory dummyScript() { | ||
return DUMMY; | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
...lds/src/test/java/org/elasticsearch/xpack/runtimefields/DoubleScriptFieldScriptTests.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,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.runtimefields; | ||
|
||
import org.elasticsearch.script.ScriptContext; | ||
|
||
public class DoubleScriptFieldScriptTests extends ScriptFieldScriptTestCase<DoubleScriptFieldScript.Factory> { | ||
public static final DoubleScriptFieldScript.Factory DUMMY = (params, lookup) -> ctx -> new DoubleScriptFieldScript( | ||
params, | ||
lookup, | ||
ctx | ||
) { | ||
@Override | ||
public void execute() { | ||
new DoubleScriptFieldScript.Value(this).value(1.0); | ||
} | ||
}; | ||
|
||
@Override | ||
protected ScriptContext<DoubleScriptFieldScript.Factory> context() { | ||
return DoubleScriptFieldScript.CONTEXT; | ||
} | ||
|
||
@Override | ||
protected DoubleScriptFieldScript.Factory dummyScript() { | ||
return DUMMY; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...-fields/src/test/java/org/elasticsearch/xpack/runtimefields/IpScriptFieldScriptTests.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,28 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.runtimefields; | ||
|
||
import org.elasticsearch.script.ScriptContext; | ||
|
||
public class IpScriptFieldScriptTests extends ScriptFieldScriptTestCase<IpScriptFieldScript.Factory> { | ||
public static final IpScriptFieldScript.Factory DUMMY = (params, lookup) -> ctx -> new IpScriptFieldScript(params, lookup, ctx) { | ||
@Override | ||
public void execute() { | ||
new IpScriptFieldScript.StringValue(this).stringValue("192.168.0.1"); | ||
} | ||
}; | ||
|
||
@Override | ||
protected ScriptContext<IpScriptFieldScript.Factory> context() { | ||
return IpScriptFieldScript.CONTEXT; | ||
} | ||
|
||
@Override | ||
protected IpScriptFieldScript.Factory dummyScript() { | ||
return DUMMY; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...ields/src/test/java/org/elasticsearch/xpack/runtimefields/LongScriptFieldScriptTests.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,28 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.runtimefields; | ||
|
||
import org.elasticsearch.script.ScriptContext; | ||
|
||
public class LongScriptFieldScriptTests extends ScriptFieldScriptTestCase<LongScriptFieldScript.Factory> { | ||
public static final LongScriptFieldScript.Factory DUMMY = (params, lookup) -> ctx -> new LongScriptFieldScript(params, lookup, ctx) { | ||
@Override | ||
public void execute() { | ||
new LongScriptFieldScript.Value(this).value(1); | ||
} | ||
}; | ||
|
||
@Override | ||
protected ScriptContext<LongScriptFieldScript.Factory> context() { | ||
return LongScriptFieldScript.CONTEXT; | ||
} | ||
|
||
@Override | ||
protected LongScriptFieldScript.Factory dummyScript() { | ||
return DUMMY; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...fields/src/test/java/org/elasticsearch/xpack/runtimefields/ScriptFieldScriptTestCase.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,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.runtimefields; | ||
|
||
import org.elasticsearch.script.Script; | ||
import org.elasticsearch.script.ScriptContext; | ||
import org.elasticsearch.script.ScriptService; | ||
import org.elasticsearch.script.ScriptType; | ||
import org.elasticsearch.test.ESTestCase; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
public abstract class ScriptFieldScriptTestCase<T> extends ESTestCase { | ||
protected abstract ScriptContext<T> context(); | ||
|
||
protected abstract T dummyScript(); | ||
|
||
public final void testRateLimitingDisabled() throws IOException { | ||
try (ScriptService scriptService = TestScriptEngine.scriptService(context(), dummyScript())) { | ||
for (int i = 0; i < 1000; i++) { | ||
scriptService.compile(new Script(ScriptType.INLINE, "test", "test_" + i, Map.of()), context()); | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...lds/src/test/java/org/elasticsearch/xpack/runtimefields/StringScriptFieldScriptTests.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,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.runtimefields; | ||
|
||
import org.elasticsearch.script.ScriptContext; | ||
|
||
public class StringScriptFieldScriptTests extends ScriptFieldScriptTestCase<StringScriptFieldScript.Factory> { | ||
public static final StringScriptFieldScript.Factory DUMMY = (params, lookup) -> ctx -> new StringScriptFieldScript( | ||
params, | ||
lookup, | ||
ctx | ||
) { | ||
@Override | ||
public void execute() { | ||
new StringScriptFieldScript.Value(this).value("foo"); | ||
} | ||
}; | ||
|
||
@Override | ||
protected ScriptContext<StringScriptFieldScript.Factory> context() { | ||
return StringScriptFieldScript.CONTEXT; | ||
} | ||
|
||
@Override | ||
protected StringScriptFieldScript.Factory dummyScript() { | ||
return DUMMY; | ||
} | ||
} |
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