From 6e70856cf54a9b9e40a8c579b4c8f487f5609659 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Mon, 9 May 2016 15:49:52 -0600 Subject: [PATCH 1/3] Fix Watcher tests for 'sandbox' option removal Relates to https://github.com/elastic/elasticsearch/pull/18226 Original commit: elastic/x-pack-elasticsearch@b30d623dfbd542333b95302419a752d80d66b50e --- .../java/org/elasticsearch/script/SleepScriptEngine.java | 5 ----- .../watcher/test/AbstractWatcherIntegrationTestCase.java | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java index 2a1cfcdd893..e8764f2ec98 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java @@ -54,11 +54,6 @@ public class SleepScriptEngine implements ScriptEngineService { return TYPES; } - @Override - public boolean isSandboxed() { - return true; - } - @Override public Object compile(String script, Map params) { return script; diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java index 7ce32199a56..86a16d50abf 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java @@ -136,6 +136,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase .put("xpack.watcher.watch.scroll.size", randomIntBetween(1, 100)) .put(ShieldSettings.settings(shieldEnabled)) .put("xpack.watcher.trigger.schedule.engine", scheduleImplName) + .put("script.inline", "true") .build(); } From fd6cf7d3d3d021e4a5dd3df8a250f1367660bbe8 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Tue, 10 May 2016 12:10:12 -0600 Subject: [PATCH 2/3] Register engines with a default of `ScriptMode.ON` Original commit: elastic/x-pack-elasticsearch@d367b4028e0f5a30b5158740b62a6a21c365ec13 --- .../org/elasticsearch/script/MockMustacheScriptEngine.java | 3 ++- .../test/java/org/elasticsearch/script/SleepScriptEngine.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java index c0d1c7bce39..17db57da230 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.script; +import org.elasticsearch.script.ScriptMode; import org.elasticsearch.xpack.common.text.DefaultTextTemplateEngine; import java.util.Collections; @@ -29,7 +30,7 @@ public class MockMustacheScriptEngine extends MockScriptEngine { public void onModule(ScriptModule module) { module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(MockMustacheScriptEngine.class, - Collections.singletonList(NAME))); + Collections.singletonList(NAME), ScriptMode.ON)); } } diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java index e8764f2ec98..dadaee3024d 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java @@ -7,6 +7,7 @@ package org.elasticsearch.script; import org.elasticsearch.common.Nullable; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.script.ScriptMode; import org.elasticsearch.search.lookup.SearchLookup; import java.io.IOException; @@ -39,7 +40,7 @@ public class SleepScriptEngine implements ScriptEngineService { } public void onModule(ScriptModule module) { - module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(SleepScriptEngine.class, SleepScriptEngine.TYPES)); + module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(SleepScriptEngine.class, SleepScriptEngine.TYPES, ScriptMode.ON)); } } From 91f2e94ac7b4598b7975b9c699c4eb4f24550ff8 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Wed, 11 May 2016 10:12:55 -0600 Subject: [PATCH 3/3] Fix scripting engines for singular type Original commit: elastic/x-pack-elasticsearch@ed014cefc31fc8980fc6b67e10d7b60392414b0d --- .../org/elasticsearch/messy/tests/MessyTestUtils.java | 2 +- .../org/elasticsearch/smoketest/WatcherTemplateTests.java | 2 +- .../elasticsearch/script/MockMustacheScriptEngine.java | 8 ++++---- .../java/org/elasticsearch/script/SleepScriptEngine.java | 7 ++++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/MessyTestUtils.java b/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/MessyTestUtils.java index 05330ac5ad0..c4bbc2186b9 100644 --- a/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/MessyTestUtils.java +++ b/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/MessyTestUtils.java @@ -42,7 +42,7 @@ public final class MessyTestUtils { engineServiceSet.add(groovyScriptEngineService); ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry( Arrays.asList( - new ScriptEngineRegistry.ScriptEngineRegistration(GroovyScriptEngineService.class, GroovyScriptEngineService.TYPES) + new ScriptEngineRegistry.ScriptEngineRegistration(GroovyScriptEngineService.class, GroovyScriptEngineService.NAME) ) ); ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(Arrays.asList(ScriptServiceProxy.INSTANCE)); diff --git a/elasticsearch/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateTests.java b/elasticsearch/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateTests.java index 8665dd318a3..efe00900d07 100644 --- a/elasticsearch/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateTests.java +++ b/elasticsearch/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateTests.java @@ -56,7 +56,7 @@ public class WatcherTemplateTests extends ESTestCase { ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry( Arrays.asList( new ScriptEngineRegistry.ScriptEngineRegistration(MustacheScriptEngineService.class, - MustacheScriptEngineService.TYPES) + MustacheScriptEngineService.NAME) ) ); ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, registry); diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java index 17db57da230..a1fd6ca0fa2 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java @@ -30,19 +30,19 @@ public class MockMustacheScriptEngine extends MockScriptEngine { public void onModule(ScriptModule module) { module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(MockMustacheScriptEngine.class, - Collections.singletonList(NAME), ScriptMode.ON)); + NAME, ScriptMode.ON)); } } @Override - public List getTypes() { - return Collections.singletonList(NAME); + public String getType() { + return NAME; } @Override public List getExtensions() { - return getTypes(); + return Collections.singletonList(NAME); } @Override diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java index dadaee3024d..c79ebec978a 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java @@ -40,14 +40,15 @@ public class SleepScriptEngine implements ScriptEngineService { } public void onModule(ScriptModule module) { - module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(SleepScriptEngine.class, SleepScriptEngine.TYPES, ScriptMode.ON)); + module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(SleepScriptEngine.class, + SleepScriptEngine.NAME, ScriptMode.ON)); } } @Override - public List getTypes() { - return TYPES; + public String getType() { + return NAME; } @Override