diff --git a/docs/en/watcher/condition/script.asciidoc b/docs/en/watcher/condition/script.asciidoc index c3de6dd8adf..964703755e3 100644 --- a/docs/en/watcher/condition/script.asciidoc +++ b/docs/en/watcher/condition/script.asciidoc @@ -72,7 +72,7 @@ file: -------------------------------------------------- "condition" : { "script" : { - "file" : "my_script" + "id" : "my_script" } } -------------------------------------------------- @@ -84,7 +84,7 @@ script language and parameters: -------------------------------------------------- "condition" : { "script" : { - "file" : "my_script", + "id" : "my_script", "lang" : "javascript", "params" : { "result" : true diff --git a/docs/en/watcher/example-watches/watching-time-series-data.asciidoc b/docs/en/watcher/example-watches/watching-time-series-data.asciidoc index e8761694aea..ec5530b07b2 100644 --- a/docs/en/watcher/example-watches/watching-time-series-data.asciidoc +++ b/docs/en/watcher/example-watches/watching-time-series-data.asciidoc @@ -116,7 +116,7 @@ you can then reference it by name in the watch condition. -------------------------------------------------- "condition" : { "script" : { - "file" : "threshold_hits", + "id" : "threshold_hits", "params" : { "threshold" : 0 <1> } @@ -181,7 +181,7 @@ PUT _xpack/watcher/watch/rss_watch }, "condition" : { "script" : { - "file" : "threshold_hits", + "id" : "threshold_hits", "params" : { "threshold" : 0 } @@ -204,7 +204,7 @@ PUT _xpack/watcher/watch/rss_watch } -------------------------------------------------- // CONSOLE -// TEST[s/"file" : "threshold_hits"/"inline": "return ctx.payload.hits.total > params.threshold"/] +// TEST[s/"id" : "threshold_hits"/"inline": "return ctx.payload.hits.total > params.threshold"/] <1> Replace `@` with your email address to receive notifications. diff --git a/docs/en/watcher/how-watcher-works.asciidoc b/docs/en/watcher/how-watcher-works.asciidoc index a8c939f5bc5..bf20c2fd2b3 100644 --- a/docs/en/watcher/how-watcher-works.asciidoc +++ b/docs/en/watcher/how-watcher-works.asciidoc @@ -458,7 +458,7 @@ references the script file `threshold_hits.painless`: -------------------------------------------------- "condition" : { "script" : { - "file" : "threshold_hits", + "id" : "threshold_hits", "params" : { "threshold" : 0 } diff --git a/plugin/src/test/java/org/elasticsearch/script/LatchScriptEngine.java b/plugin/src/test/java/org/elasticsearch/script/LatchScriptEngine.java index 395b65165b0..b6073358567 100644 --- a/plugin/src/test/java/org/elasticsearch/script/LatchScriptEngine.java +++ b/plugin/src/test/java/org/elasticsearch/script/LatchScriptEngine.java @@ -38,11 +38,6 @@ public class LatchScriptEngine implements ScriptEngine { return NAME; } - @Override - public String getExtension() { - return NAME; - } - @Override public Object compile(String scriptName, String scriptSource, Map params) { return scriptSource; diff --git a/plugin/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java b/plugin/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java index d1bf003da0b..5a8c5073147 100644 --- a/plugin/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java +++ b/plugin/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java @@ -38,11 +38,6 @@ public class MockMustacheScriptEngine extends MockScriptEngine { return NAME; } - @Override - public String getExtension() { - return NAME; - } - @Override public Object compile(String name, String script, Map params) { if (script.contains("{{") && script.contains("}}")) { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/common/text/TextTemplateTests.java b/plugin/src/test/java/org/elasticsearch/xpack/common/text/TextTemplateTests.java index 0e7b5b0820f..277d782718b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/common/text/TextTemplateTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/common/text/TextTemplateTests.java @@ -102,9 +102,6 @@ public class TextTemplateTests extends ESTestCase { case INLINE: builder.field("inline", template.getTemplate()); break; - case FILE: - builder.field("file", template.getTemplate()); - break; case STORED: builder.field("stored", template.getTemplate()); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/test/MockPainlessScriptEngine.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/test/MockPainlessScriptEngine.java index 7a042bc33c5..bd69312d46b 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/test/MockPainlessScriptEngine.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/test/MockPainlessScriptEngine.java @@ -38,11 +38,6 @@ public class MockPainlessScriptEngine extends MockScriptEngine { return NAME; } - @Override - public String getExtension() { - return NAME; - } - @Override public Object compile(String name, String script, Map params) { // We always return the script's source as it is diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionTests.java index f45b63ef417..ab430dbd149 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/condition/ScriptConditionTests.java @@ -92,11 +92,8 @@ public class ScriptConditionTests extends ESTestCase { ScriptContextRegistry contextRegistry = new ScriptContextRegistry(singleton(new ScriptContext.Plugin("xpack", "watch"))); ScriptSettings scriptSettings = new ScriptSettings(registry, contextRegistry); - Settings settings = Settings.builder() - .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) - .build(); - scriptService = new ScriptService(settings, new Environment(settings), null, registry, contextRegistry, scriptSettings); + scriptService = new ScriptService(Settings.EMPTY, registry, contextRegistry, scriptSettings); ClusterState.Builder clusterState = new ClusterState.Builder(new ClusterName("_name")); clusterState.metaData(MetaData.builder().putCustom(ScriptMetaData.TYPE, new ScriptMetaData.Builder(null).build())); ClusterState cs = clusterState.build(); @@ -152,7 +149,7 @@ public class ScriptConditionTests extends ESTestCase { fail("expected a condition exception trying to parse an invalid condition XContent"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), - containsString("must specify either code for an [inline] script or an id for a [stored] script or [file] script")); + containsString("must specify either code for an [inline] script or an id for a [stored] script")); } } @@ -165,10 +162,6 @@ public class ScriptConditionTests extends ESTestCase { expectedException = ResourceNotFoundException.class; script = "nonExisting_script"; break; - case FILE: - expectedException = IllegalArgumentException.class; - script = "nonExisting_script"; - break; default: expectedException = GeneralScriptException.class; script = "foo = = 1"; @@ -228,9 +221,6 @@ public class ScriptConditionTests extends ESTestCase { case INLINE: builder.field("inline", script); break; - case FILE: - builder.field("file", script); - break; case STORED: builder.field("stored", script); break; diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java index 918b468ff41..438511d6a67 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java @@ -24,7 +24,7 @@ public class WatcherSearchTemplateRequestTests extends ESTestCase { } public void testFromXContentWithTemplateCustomLang() throws IOException { - String source = "{\"template\":{\"file\":\"custom-script\", \"lang\":\"painful\",\"params\":{\"bar\":\"baz\"}}}"; + String source = "{\"template\":{\"inline\":\"custom-script\", \"lang\":\"painful\",\"params\":{\"bar\":\"baz\"}}}"; assertTemplate(source, "custom-script", "painful", singletonMap("bar", "baz")); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java index e4130d3bff0..c084dc25a33 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java @@ -248,8 +248,7 @@ public final class WatcherTestUtils { ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(Collections.emptyList()); ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry); - return new ScriptService(settings, new Environment(settings), new ResourceWatcherService(settings, tp), - scriptEngineRegistry, scriptContextRegistry, scriptSettings); + return new ScriptService(settings, scriptEngineRegistry, scriptContextRegistry, scriptSettings); } public static SearchType getRandomSupportedSearchType() { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchTransformTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchTransformTests.java index 71eba9985dc..85ede1f0ef6 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchTransformTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/test/integration/SearchTransformTests.java @@ -192,7 +192,7 @@ public class SearchTransformTests extends ESIntegTestCase { builder.field("search_type", searchType.name()); } if (templateName != null) { - TextTemplate template = new TextTemplate(templateName, null, ScriptType.FILE, null); + TextTemplate template = new TextTemplate(templateName, null, ScriptType.INLINE, null); builder.field("template", template); } @@ -228,7 +228,7 @@ public class SearchTransformTests extends ESIntegTestCase { } if (templateName != null) { assertThat(executable.transform().getRequest().getTemplate(), - equalTo(new Script(ScriptType.FILE, "mustache", "template1", Collections.emptyMap()))); + equalTo(new Script(ScriptType.INLINE, "mustache", "template1", Collections.emptyMap()))); } assertThat(executable.transform().getRequest().getSearchSource().utf8ToString(), equalTo("{\"query\":{\"match_all\":{}}}")); assertThat(executable.transform().getTimeout(), equalTo(readTimeout)); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transform/TransformIntegrationTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/transform/TransformIntegrationTests.java index 90b9db89f78..061724e38c8 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transform/TransformIntegrationTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/transform/TransformIntegrationTests.java @@ -130,7 +130,7 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas if (randomBoolean()) { logger.info("testing script transform with an inline script"); script = mockScript("['key3' : ctx.payload.key1 + ctx.payload.key2]"); - } else if (randomBoolean()) { + } else { logger.info("testing script transform with an indexed script"); assertAcked(client().admin().cluster().preparePutStoredScript() .setId("my-script") @@ -138,9 +138,6 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas .setContent(new BytesArray("{\"script\" : \"['key3' : ctx.payload.key1 + ctx.payload.key2]\"}"), XContentType.JSON) .get()); script = new Script(ScriptType.STORED, "mockscript", "my-script", Collections.emptyMap()); - } else { - logger.info("testing script transform with a file script"); - script = new Script(ScriptType.FILE, "mockscript", "my-script", Collections.emptyMap()); } // put a watch that has watch level transform: diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java index a7cf66e4401..a0ab00cb377 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/transform/script/ScriptTransformTests.java @@ -213,7 +213,6 @@ public class ScriptTransformTests extends ESTestCase { static String scriptTypeField(ScriptType type) { switch (type) { case INLINE: return "inline"; - case FILE: return "file"; case STORED: return "stored"; default: throw illegalArgument("unsupported script type [{}]", type); diff --git a/qa/smoke-test-security-with-mustache/build.gradle b/qa/smoke-test-security-with-mustache/build.gradle index c7c441bf277..a8bf4214edf 100644 --- a/qa/smoke-test-security-with-mustache/build.gradle +++ b/qa/smoke-test-security-with-mustache/build.gradle @@ -11,7 +11,6 @@ integTestCluster { plugin ':x-pack-elasticsearch:plugin' setting 'xpack.watcher.enabled', 'false' setting 'xpack.monitoring.enabled', 'false' - setting 'path.scripts', "${project.buildDir}/resources/test/templates" setupCommand 'setupDummyUser', 'bin/x-pack/users', 'useradd', 'test_admin', '-p', 'changeme', '-r', 'superuser' waitCondition = { node, ant -> diff --git a/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/10_templated_role_query.yml b/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/10_templated_role_query.yml index a70dbde7070..7487b85f61f 100644 --- a/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/10_templated_role_query.yml +++ b/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/10_templated_role_query.yml @@ -111,7 +111,7 @@ setup: "privileges": ["all"], "query" : { "template" : { - "file" : "query" + "id" : "query" } } } diff --git a/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/11_templated_role_query_runas.yml b/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/11_templated_role_query_runas.yml index f0e90cecd15..b3c4a41b455 100644 --- a/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/11_templated_role_query_runas.yml +++ b/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/11_templated_role_query_runas.yml @@ -111,7 +111,7 @@ setup: "privileges": ["all"], "query" : { "template" : { - "file" : "query" + "id" : "query" } } } diff --git a/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateIT.java b/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateIT.java index 83fdaa3e007..9d85b76feb7 100644 --- a/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateIT.java +++ b/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateIT.java @@ -41,17 +41,13 @@ public class WatcherTemplateIT extends ESTestCase { @Before public void init() throws Exception { - Settings setting = Settings.builder().put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING, true).build(); - Environment environment = Mockito.mock(Environment.class); - ResourceWatcherService resourceWatcherService = Mockito.mock(ResourceWatcherService.class); ScriptContextRegistry registry = new ScriptContextRegistry(Collections.singletonList(new ScriptContext.Plugin("xpack", "watch"))); ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry( Collections.singleton(new MustacheScriptEngine()) ); ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, registry); - ScriptService scriptService = new ScriptService(setting, environment, resourceWatcherService, scriptEngineRegistry, - registry, scriptSettings); + ScriptService scriptService = new ScriptService(Settings.EMPTY, scriptEngineRegistry, registry, scriptSettings); engine = new TextTemplateEngine(Settings.EMPTY, scriptService); }