Merge branch 'master' into feature/search-request-refactoring
This commit is contained in:
commit
1915c74e93
|
@ -32,7 +32,10 @@ Vagrant.configure(2) do |config|
|
|||
end
|
||||
config.vm.define "vivid" do |config|
|
||||
config.vm.box = "ubuntu/vivid64"
|
||||
ubuntu_common config
|
||||
ubuntu_common config, extra: <<-SHELL
|
||||
# Install Jayatana so we can work around it being present.
|
||||
[ -f /usr/share/java/jayatanaag.jar ] || install jayatana
|
||||
SHELL
|
||||
end
|
||||
# Wheezy's backports don't contain Openjdk 8 and the backflips required to
|
||||
# get the sun jdk on there just aren't worth it. We have jessie for testing
|
||||
|
@ -116,11 +119,11 @@ SOURCE_PROMPT
|
|||
end
|
||||
end
|
||||
|
||||
def ubuntu_common(config)
|
||||
deb_common config, 'apt-add-repository -y ppa:openjdk-r/ppa > /dev/null 2>&1', 'openjdk-r-*'
|
||||
def ubuntu_common(config, extra: '')
|
||||
deb_common config, 'apt-add-repository -y ppa:openjdk-r/ppa > /dev/null 2>&1', 'openjdk-r-*', extra: extra
|
||||
end
|
||||
|
||||
def deb_common(config, add_openjdk_repository_command, openjdk_list)
|
||||
def deb_common(config, add_openjdk_repository_command, openjdk_list, extra: '')
|
||||
# http://foo-o-rama.com/vagrant--stdin-is-not-a-tty--fix.html
|
||||
config.vm.provision "fix-no-tty", type: "shell" do |s|
|
||||
s.privileged = false
|
||||
|
@ -137,6 +140,7 @@ def deb_common(config, add_openjdk_repository_command, openjdk_list)
|
|||
(echo "Importing java-8 ppa" &&
|
||||
#{add_openjdk_repository_command} &&
|
||||
apt-get update)
|
||||
#{extra}
|
||||
SHELL
|
||||
)
|
||||
end
|
||||
|
|
|
@ -195,7 +195,7 @@ final class Bootstrap {
|
|||
private static void setupLogging(Settings settings, Environment environment) {
|
||||
try {
|
||||
Class.forName("org.apache.log4j.Logger");
|
||||
LogConfigurator.configure(settings);
|
||||
LogConfigurator.configure(settings, true);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// no log4j
|
||||
} catch (NoClassDefFoundError e) {
|
||||
|
|
|
@ -70,6 +70,7 @@ public class LogConfigurator {
|
|||
.put("socketHub", "org.apache.log4j.net.SocketHubAppender")
|
||||
.put("syslog", "org.apache.log4j.net.SyslogAppender")
|
||||
.put("telnet", "org.apache.log4j.net.TelnetAppender")
|
||||
.put("terminal", "org.elasticsearch.common.logging.log4j.TerminalAppender")
|
||||
// policies
|
||||
.put("timeBased", "org.apache.log4j.rolling.TimeBasedRollingPolicy")
|
||||
.put("sizeBased", "org.apache.log4j.rolling.SizeBasedTriggeringPolicy")
|
||||
|
@ -83,15 +84,24 @@ public class LogConfigurator {
|
|||
.put("xml", "org.apache.log4j.XMLLayout")
|
||||
.immutableMap();
|
||||
|
||||
public static void configure(Settings settings) {
|
||||
/**
|
||||
* Consolidates settings and converts them into actual log4j settings, then initializes loggers and appenders.
|
||||
*
|
||||
* @param settings custom settings that should be applied
|
||||
* @param resolveConfig controls whether the logging conf file should be read too or not.
|
||||
*/
|
||||
public static void configure(Settings settings, boolean resolveConfig) {
|
||||
if (loaded) {
|
||||
return;
|
||||
}
|
||||
loaded = true;
|
||||
// TODO: this is partly a copy of InternalSettingsPreparer...we should pass in Environment and not do all this...
|
||||
Environment environment = new Environment(settings);
|
||||
|
||||
Settings.Builder settingsBuilder = settingsBuilder();
|
||||
resolveConfig(environment, settingsBuilder);
|
||||
if (resolveConfig) {
|
||||
resolveConfig(environment, settingsBuilder);
|
||||
}
|
||||
settingsBuilder
|
||||
.putProperties("elasticsearch.", System.getProperties())
|
||||
.putProperties("es.", System.getProperties());
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.elasticsearch.common.logging.log4j;
|
||||
|
||||
import org.apache.log4j.AppenderSkeleton;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
import org.elasticsearch.common.cli.Terminal;
|
||||
|
||||
/**
|
||||
* TerminalAppender logs event to Terminal.DEFAULT. It is used for example by the PluginManagerCliParser.
|
||||
* */
|
||||
public class TerminalAppender extends AppenderSkeleton {
|
||||
@Override
|
||||
protected void append(LoggingEvent event) {
|
||||
Terminal.DEFAULT.println(event.getRenderedMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresLayout() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -70,7 +70,7 @@ public class GeoShapeQueryBuilder extends AbstractQueryBuilder<GeoShapeQueryBuil
|
|||
// and Equals so ShapeBuilder can be used here
|
||||
private BytesReference shapeBytes;
|
||||
|
||||
private SpatialStrategy strategy = null;
|
||||
private SpatialStrategy strategy;
|
||||
|
||||
private final String indexedShapeId;
|
||||
private final String indexedShapeType;
|
||||
|
@ -449,9 +449,10 @@ public class GeoShapeQueryBuilder extends AbstractQueryBuilder<GeoShapeQueryBuil
|
|||
out.writeOptionalString(indexedShapePath);
|
||||
}
|
||||
relation.writeTo(out);
|
||||
boolean hasStrategy = strategy != null;
|
||||
out.writeBoolean(hasStrategy);
|
||||
if (hasStrategy) {
|
||||
if (strategy == null) {
|
||||
out.writeBoolean(false);
|
||||
} else {
|
||||
out.writeBoolean(true);
|
||||
strategy.writeTo(out);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class InternalSettingsPreparer {
|
|||
* and then replacing all property placeholders. If a {@link Terminal} is provided and configuration settings are loaded,
|
||||
* settings with a value of <code>${prompt.text}</code> or <code>${prompt.secret}</code> will result in a prompt for
|
||||
* the setting to the user.
|
||||
* @param input The initial settings to use
|
||||
* @param input The custom settings to use. These are not overwritten by settings in the configuration file.
|
||||
* @param terminal the Terminal to use for input/output
|
||||
* @return the {@link Settings} and {@link Environment} as a {@link Tuple}
|
||||
*/
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.cli.CliTool;
|
||||
import org.elasticsearch.common.cli.CliToolConfig;
|
||||
import org.elasticsearch.common.cli.Terminal;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.logging.log4j.LogConfigurator;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
@ -39,7 +38,6 @@ import java.util.Locale;
|
|||
|
||||
import static org.elasticsearch.common.cli.CliToolConfig.Builder.cmd;
|
||||
import static org.elasticsearch.common.cli.CliToolConfig.Builder.option;
|
||||
import static org.elasticsearch.common.settings.Settings.EMPTY;
|
||||
|
||||
public class PluginManagerCliParser extends CliTool {
|
||||
|
||||
|
@ -51,8 +49,21 @@ public class PluginManagerCliParser extends CliTool {
|
|||
.build();
|
||||
|
||||
public static void main(String[] args) {
|
||||
Environment env = InternalSettingsPreparer.prepareEnvironment(EMPTY, Terminal.DEFAULT);
|
||||
LogConfigurator.configure(env.settings());
|
||||
// initialize default for es.logger.level because we will not read the logging.yml
|
||||
String loggerLevel = System.getProperty("es.logger.level", "INFO");
|
||||
// Set the appender for all potential log files to terminal so that other components that use the logger print out the
|
||||
// same terminal.
|
||||
// The reason for this is that the plugin cli cannot be configured with a file appender because when the plugin command is
|
||||
// executed there is no way of knowing where the logfiles should be placed. For example, if elasticsearch
|
||||
// is run as service then the logs should be at /var/log/elasticsearch but when started from the tar they should be at es.home/logs.
|
||||
// Therefore we print to Terminal.
|
||||
Environment env = InternalSettingsPreparer.prepareEnvironment(Settings.builder()
|
||||
.put("appender.terminal.type", "terminal")
|
||||
.put("rootLogger", "${es.logger.level}, terminal")
|
||||
.put("es.logger.level", loggerLevel)
|
||||
.build(), Terminal.DEFAULT);
|
||||
// configure but do not read the logging conf file
|
||||
LogConfigurator.configure(env.settings(), false);
|
||||
int status = new PluginManagerCliParser().execute(args).status();
|
||||
System.exit(status);
|
||||
}
|
||||
|
|
|
@ -93,11 +93,6 @@ public class NativeScriptEngineService extends AbstractComponent implements Scri
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(CompiledScript compiledScript, Map<String, Object> vars) {
|
||||
return executable(compiledScript, vars).run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
|
|
@ -42,8 +42,6 @@ public interface ScriptEngineService extends Closeable {
|
|||
|
||||
SearchScript search(CompiledScript compiledScript, SearchLookup lookup, @Nullable Map<String, Object> vars);
|
||||
|
||||
Object execute(CompiledScript compiledScript, Map<String, Object> vars);
|
||||
|
||||
/**
|
||||
* Handler method called when a script is removed from the Guava cache.
|
||||
*
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.elasticsearch.script.mustache;
|
||||
|
||||
import com.github.mustachejava.Mustache;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -34,7 +33,6 @@ import org.elasticsearch.script.ScriptException;
|
|||
import org.elasticsearch.script.SearchScript;
|
||||
import org.elasticsearch.search.lookup.SearchLookup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
@ -88,29 +86,6 @@ public class MustacheScriptEngineService extends AbstractComponent implements Sc
|
|||
return (new JsonEscapingMustacheFactory()).compile(new FastStringReader(template), "query-template");
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a compiled template object (as retrieved from the compile method)
|
||||
* and fill potential place holders with the variables given.
|
||||
*
|
||||
* @param template
|
||||
* compiled template object.
|
||||
* @param vars
|
||||
* map of variables to use during substitution.
|
||||
*
|
||||
* @return the processed string with all given variables substitued.
|
||||
* */
|
||||
@Override
|
||||
public Object execute(CompiledScript template, Map<String, Object> vars) {
|
||||
BytesStreamOutput result = new BytesStreamOutput();
|
||||
try (UTF8StreamWriter writer = utf8StreamWriter().setOutput(result)) {
|
||||
((Mustache) template.compiled()).execute(writer, vars);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error executing " + template, e);
|
||||
throw new ScriptException("Error executing " + template, e);
|
||||
}
|
||||
return result.bytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] types() {
|
||||
return new String[] {NAME};
|
||||
|
|
|
@ -57,7 +57,7 @@ public class Log4jESLoggerTests extends ESTestCase {
|
|||
.put("path.conf", configDir.toAbsolutePath())
|
||||
.put("path.home", createTempDir().toString())
|
||||
.build();
|
||||
LogConfigurator.configure(settings);
|
||||
LogConfigurator.configure(settings, true);
|
||||
|
||||
esTestLogger = Log4jESLoggerFactory.getLogger("test");
|
||||
Logger testLogger = ((Log4jESLogger) esTestLogger).logger();
|
||||
|
|
|
@ -32,8 +32,10 @@ import org.junit.Test;
|
|||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.OpenOption;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
|
@ -56,7 +58,7 @@ public class LoggingConfigurationTests extends ESTestCase {
|
|||
.put("path.conf", configDir.toAbsolutePath())
|
||||
.put("path.home", createTempDir().toString())
|
||||
.build();
|
||||
LogConfigurator.configure(settings);
|
||||
LogConfigurator.configure(settings, true);
|
||||
|
||||
ESLogger esLogger = Log4jESLoggerFactory.getLogger("test");
|
||||
Logger logger = ((Log4jESLogger) esLogger).logger();
|
||||
|
@ -157,20 +159,20 @@ public class LoggingConfigurationTests extends ESTestCase {
|
|||
public void testResolveOrder() throws Exception {
|
||||
Path tmpDir = createTempDir();
|
||||
Path loggingConf = tmpDir.resolve(loggingConfiguration("yaml"));
|
||||
Files.write(loggingConf, "logger.test: INFO, file\n".getBytes(StandardCharsets.UTF_8));
|
||||
Files.write(loggingConf, "logger.test_resolve_order: INFO, file\n".getBytes(StandardCharsets.UTF_8));
|
||||
Files.write(loggingConf, "appender.file.type: file\n".getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND);
|
||||
Environment environment = InternalSettingsPreparer.prepareEnvironment(
|
||||
Settings.builder()
|
||||
.put("path.conf", tmpDir.toAbsolutePath())
|
||||
.put("path.home", createTempDir().toString())
|
||||
.put("logger.test", "TRACE, console")
|
||||
.put("logger.test_resolve_order", "TRACE, console")
|
||||
.put("appender.console.type", "console")
|
||||
.put("appender.console.layout.type", "consolePattern")
|
||||
.put("appender.console.layout.conversionPattern", "[%d{ISO8601}][%-5p][%-25c] %m%n")
|
||||
.build(), new CliToolTestCase.MockTerminal());
|
||||
LogConfigurator.configure(environment.settings());
|
||||
LogConfigurator.configure(environment.settings(), true);
|
||||
// args should overwrite whatever is in the config
|
||||
ESLogger esLogger = Log4jESLoggerFactory.getLogger("test");
|
||||
ESLogger esLogger = Log4jESLoggerFactory.getLogger("test_resolve_order");
|
||||
Logger logger = ((Log4jESLogger) esLogger).logger();
|
||||
Appender appender = logger.getAppender("console");
|
||||
assertThat(appender, notNullValue());
|
||||
|
@ -179,6 +181,31 @@ public class LoggingConfigurationTests extends ESTestCase {
|
|||
assertThat(appender, nullValue());
|
||||
}
|
||||
|
||||
// tests that config file is not read when we call LogConfigurator.configure(Settings, false)
|
||||
@Test
|
||||
public void testConfigNotRead() throws Exception {
|
||||
Path tmpDir = createTempDir();
|
||||
Path loggingConf = tmpDir.resolve(loggingConfiguration("yaml"));
|
||||
Files.write(loggingConf,
|
||||
Arrays.asList(
|
||||
"logger.test_config_not_read: INFO, console",
|
||||
"appender.console.type: console"),
|
||||
StandardCharsets.UTF_8);
|
||||
Environment environment = InternalSettingsPreparer.prepareEnvironment(
|
||||
Settings.builder()
|
||||
.put("path.conf", tmpDir.toAbsolutePath())
|
||||
.put("path.home", createTempDir().toString())
|
||||
.build(), new CliToolTestCase.MockTerminal());
|
||||
LogConfigurator.configure(environment.settings(), false);
|
||||
ESLogger esLogger = Log4jESLoggerFactory.getLogger("test_config_not_read");
|
||||
|
||||
assertNotNull(esLogger);
|
||||
Logger logger = ((Log4jESLogger) esLogger).logger();
|
||||
Appender appender = logger.getAppender("console");
|
||||
// config was not read
|
||||
assertNull(appender);
|
||||
}
|
||||
|
||||
private static String loggingConfiguration(String suffix) {
|
||||
return "logging." + randomAsciiOfLength(randomIntBetween(0, 10)) + "." + suffix;
|
||||
}
|
||||
|
|
|
@ -77,10 +77,12 @@ public class GeoShapeQueryBuilderTests extends AbstractQueryTestCase<GeoShapeQue
|
|||
builder.indexedShapePath(indexedShapePath);
|
||||
}
|
||||
}
|
||||
SpatialStrategy strategy = randomFrom(SpatialStrategy.values());
|
||||
builder.strategy(strategy);
|
||||
if (strategy != SpatialStrategy.TERM) {
|
||||
builder.relation(randomFrom(ShapeRelation.values()));
|
||||
if (randomBoolean()) {
|
||||
SpatialStrategy strategy = randomFrom(SpatialStrategy.values());
|
||||
builder.strategy(strategy);
|
||||
if (strategy != SpatialStrategy.TERM) {
|
||||
builder.relation(randomFrom(ShapeRelation.values()));
|
||||
}
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
@ -105,9 +107,7 @@ public class GeoShapeQueryBuilderTests extends AbstractQueryTestCase<GeoShapeQue
|
|||
} catch (IOException ex) {
|
||||
throw new ElasticsearchException("boom", ex);
|
||||
}
|
||||
GetResponse response = new GetResponse(new GetResult(indexedShapeIndex, indexedShapeType, indexedShapeId, 0, true, new BytesArray(
|
||||
json), null));
|
||||
return response;
|
||||
return new GetResponse(new GetResult(indexedShapeIndex, indexedShapeType, indexedShapeId, 0, true, new BytesArray(json), null));
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -149,7 +149,7 @@ public class GeoShapeQueryBuilderTests extends AbstractQueryTestCase<GeoShapeQue
|
|||
@Test
|
||||
public void testNoShape() throws IOException {
|
||||
try {
|
||||
GeoShapeQueryBuilder builder = new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, (ShapeBuilder) null);
|
||||
new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, (ShapeBuilder) null);
|
||||
fail("exception expected");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
|
@ -158,12 +158,12 @@ public class GeoShapeQueryBuilderTests extends AbstractQueryTestCase<GeoShapeQue
|
|||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNoIndexedShape() throws IOException {
|
||||
new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, (String) null, "type");
|
||||
new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, null, "type");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNoIndexedShapeType() throws IOException {
|
||||
new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, "id", (String) null);
|
||||
new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, "id", null);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
|
|
|
@ -103,11 +103,6 @@ public class MockScriptEngine implements ScriptEngineService {
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(CompiledScript compiledScript, Map<String, Object> vars) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scriptRemoved(@Nullable CompiledScript script) {
|
||||
}
|
||||
|
|
|
@ -285,11 +285,6 @@ public class ScriptModesTests extends ESTestCase {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(CompiledScript compiledScript, Map<String, Object> vars) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
|
||||
|
|
|
@ -496,11 +496,6 @@ public class ScriptServiceTests extends ESTestCase {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(CompiledScript compiledScript, Map<String, Object> vars) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class MustacheScriptEngineTests extends ESTestCase {
|
|||
+ "\"negative\": {\"term\": {\"body\": {\"value\": \"solr\"}" + "}}, \"negative_boost\": {{boost_val}} } }}";
|
||||
Map<String, Object> vars = new HashMap<>();
|
||||
vars.put("boost_val", "0.3");
|
||||
BytesReference o = (BytesReference) qe.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "", "mustache", qe.compile(template)), vars);
|
||||
BytesReference o = (BytesReference) qe.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "", "mustache", qe.compile(template)), vars).run();
|
||||
assertEquals("GET _search {\"query\": {\"boosting\": {\"positive\": {\"match\": {\"body\": \"gift\"}},"
|
||||
+ "\"negative\": {\"term\": {\"body\": {\"value\": \"solr\"}}}, \"negative_boost\": 0.3 } }}",
|
||||
new String(o.toBytes(), Charset.forName("UTF-8")));
|
||||
|
@ -65,7 +65,7 @@ public class MustacheScriptEngineTests extends ESTestCase {
|
|||
Map<String, Object> vars = new HashMap<>();
|
||||
vars.put("boost_val", "0.3");
|
||||
vars.put("body_val", "\"quick brown\"");
|
||||
BytesReference o = (BytesReference) qe.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "", "mustache", qe.compile(template)), vars);
|
||||
BytesReference o = (BytesReference) qe.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "", "mustache", qe.compile(template)), vars).run();
|
||||
assertEquals("GET _search {\"query\": {\"boosting\": {\"positive\": {\"match\": {\"body\": \"gift\"}},"
|
||||
+ "\"negative\": {\"term\": {\"body\": {\"value\": \"\\\"quick brown\\\"\"}}}, \"negative_boost\": 0.3 } }}",
|
||||
new String(o.toBytes(), Charset.forName("UTF-8")));
|
||||
|
|
|
@ -236,12 +236,6 @@ public class ExpressionScriptEngineService extends AbstractComponent implements
|
|||
return new ExpressionExecutableScript(compiledScript, vars);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(CompiledScript compiledScript, Map<String, Object> vars) {
|
||||
ExpressionExecutableScript expressionExecutableScript = new ExpressionExecutableScript(compiledScript, vars);
|
||||
return expressionExecutableScript.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {}
|
||||
|
||||
|
|
|
@ -244,20 +244,6 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(CompiledScript compiledScript, Map<String, Object> vars) {
|
||||
try {
|
||||
Map<String, Object> allVars = new HashMap<>();
|
||||
if (vars != null) {
|
||||
allVars.putAll(vars);
|
||||
}
|
||||
Script scriptObject = createScript(compiledScript.compiled(), allVars);
|
||||
return scriptObject.run();
|
||||
} catch (Exception e) {
|
||||
throw new ScriptException("failed to execute " + compiledScript, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class GroovyScript implements ExecutableScript, LeafSearchScript {
|
||||
|
||||
private final CompiledScript compiledScript;
|
||||
|
|
|
@ -178,26 +178,6 @@ public class JavaScriptScriptEngineService extends AbstractComponent implements
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(CompiledScript compiledScript, Map<String, Object> vars) {
|
||||
Context ctx = Context.enter();
|
||||
ctx.setWrapFactory(wrapFactory);
|
||||
try {
|
||||
Script script = (Script) compiledScript.compiled();
|
||||
Scriptable scope = ctx.newObject(globalScope);
|
||||
scope.setPrototype(globalScope);
|
||||
scope.setParentScope(null);
|
||||
|
||||
for (Map.Entry<String, Object> entry : vars.entrySet()) {
|
||||
ScriptableObject.putProperty(scope, entry.getKey(), entry.getValue());
|
||||
}
|
||||
Object ret = script.exec(ctx, scope);
|
||||
return ScriptValueConverter.unwrapValue(ret);
|
||||
} finally {
|
||||
Context.exit();
|
||||
}
|
||||
}
|
||||
|
||||
private String generateScriptName() {
|
||||
return "Script" + counter.incrementAndGet() + ".js";
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class JavaScriptScriptEngineTests extends ESTestCase {
|
|||
@Test
|
||||
public void testSimpleEquation() {
|
||||
Map<String, Object> vars = new HashMap<String, Object>();
|
||||
Object o = se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testSimpleEquation", "js", se.compile("1 + 2")), vars);
|
||||
Object o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testSimpleEquation", "js", se.compile("1 + 2")), vars).run();
|
||||
assertThat(((Number) o).intValue(), equalTo(3));
|
||||
}
|
||||
|
||||
|
@ -68,21 +68,21 @@ public class JavaScriptScriptEngineTests extends ESTestCase {
|
|||
Map<String, Object> obj2 = MapBuilder.<String, Object>newMapBuilder().put("prop2", "value2").map();
|
||||
Map<String, Object> obj1 = MapBuilder.<String, Object>newMapBuilder().put("prop1", "value1").put("obj2", obj2).put("l", Arrays.asList("2", "1")).map();
|
||||
vars.put("obj1", obj1);
|
||||
Object o = se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testMapAccess", "js", se.compile("obj1")), vars);
|
||||
Object o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testMapAccess", "js", se.compile("obj1")), vars).run();
|
||||
assertThat(o, instanceOf(Map.class));
|
||||
obj1 = (Map<String, Object>) o;
|
||||
assertThat((String) obj1.get("prop1"), equalTo("value1"));
|
||||
assertThat((String) ((Map<String, Object>) obj1.get("obj2")).get("prop2"), equalTo("value2"));
|
||||
|
||||
o = se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testMapAccess", "js", se.compile("obj1.l[0]")), vars);
|
||||
o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testMapAccess", "js", se.compile("obj1.l[0]")), vars).run();
|
||||
assertThat(((String) o), equalTo("2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJavaScriptObjectToMap() {
|
||||
Map<String, Object> vars = new HashMap<String, Object>();
|
||||
Object o = se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testJavaScriptObjectToMap", "js",
|
||||
se.compile("var obj1 = {}; obj1.prop1 = 'value1'; obj1.obj2 = {}; obj1.obj2.prop2 = 'value2'; obj1")), vars);
|
||||
Object o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testJavaScriptObjectToMap", "js",
|
||||
se.compile("var obj1 = {}; obj1.prop1 = 'value1'; obj1.obj2 = {}; obj1.obj2.prop2 = 'value2'; obj1")), vars).run();
|
||||
Map obj1 = (Map) o;
|
||||
assertThat((String) obj1.get("prop1"), equalTo("value1"));
|
||||
assertThat((String) ((Map<String, Object>) obj1.get("obj2")).get("prop2"), equalTo("value2"));
|
||||
|
@ -131,22 +131,22 @@ public class JavaScriptScriptEngineTests extends ESTestCase {
|
|||
Map<String, Object> obj1 = MapBuilder.<String, Object>newMapBuilder().put("prop1", "value1").put("obj2", obj2).map();
|
||||
vars.put("l", Arrays.asList("1", "2", "3", obj1));
|
||||
|
||||
Object o = se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testAccessInScript", "js",
|
||||
se.compile("l.length")), vars);
|
||||
Object o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testAccessInScript", "js",
|
||||
se.compile("l.length")), vars).run();
|
||||
assertThat(((Number) o).intValue(), equalTo(4));
|
||||
|
||||
o = se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testAccessInScript", "js",
|
||||
se.compile("l[0]")), vars);
|
||||
o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testAccessInScript", "js",
|
||||
se.compile("l[0]")), vars).run();
|
||||
assertThat(((String) o), equalTo("1"));
|
||||
|
||||
o = se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testAccessInScript", "js",
|
||||
se.compile("l[3]")), vars);
|
||||
o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testAccessInScript", "js",
|
||||
se.compile("l[3]")), vars).run();
|
||||
obj1 = (Map<String, Object>) o;
|
||||
assertThat((String) obj1.get("prop1"), equalTo("value1"));
|
||||
assertThat((String) ((Map<String, Object>) obj1.get("obj2")).get("prop2"), equalTo("value2"));
|
||||
|
||||
o = se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testAccessInScript", "js",
|
||||
se.compile("l[3].prop1")), vars);
|
||||
o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testAccessInScript", "js",
|
||||
se.compile("l[3].prop1")), vars).run();
|
||||
assertThat(((String) o), equalTo("value1"));
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ public class JavaScriptScriptMultiThreadedTests extends ESTestCase {
|
|||
long addition = x + y;
|
||||
runtimeVars.put("x", x);
|
||||
runtimeVars.put("y", y);
|
||||
long result = ((Number) se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testExecutableNoRuntimeParams", "js", compiled), runtimeVars)).longValue();
|
||||
long result = ((Number) se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testExecutableNoRuntimeParams", "js", compiled), runtimeVars).run()).longValue();
|
||||
assertThat(result, equalTo(addition));
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
|
|
|
@ -50,7 +50,7 @@ public class JavaScriptSecurityTests extends ESTestCase {
|
|||
/** runs a script */
|
||||
private void doTest(String script) {
|
||||
Map<String, Object> vars = new HashMap<String, Object>();
|
||||
se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "test", "js", se.compile(script)), vars);
|
||||
se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "test", "js", se.compile(script)), vars).run();
|
||||
}
|
||||
|
||||
/** asserts that a script runs without exception */
|
||||
|
|
|
@ -43,14 +43,14 @@ public class SimpleBench {
|
|||
for (int i = 0; i < 1000; i++) {
|
||||
vars.put("x", i);
|
||||
vars.put("y", i + 1);
|
||||
se.execute(compiledScript, vars);
|
||||
se.executable(compiledScript, vars).run();
|
||||
}
|
||||
|
||||
final long ITER = 100000;
|
||||
|
||||
StopWatch stopWatch = new StopWatch().start();
|
||||
for (long i = 0; i < ITER; i++) {
|
||||
se.execute(compiledScript, vars);
|
||||
se.executable(compiledScript, vars).run();
|
||||
}
|
||||
System.out.println("Execute Took: " + stopWatch.stop().lastTaskTime());
|
||||
|
||||
|
|
|
@ -124,18 +124,6 @@ public class PythonScriptEngineService extends AbstractComponent implements Scri
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(CompiledScript compiledScript, Map<String, Object> vars) {
|
||||
PyObject pyVars = Py.java2py(vars);
|
||||
interp.setLocals(pyVars);
|
||||
// eval the script with reduced privileges
|
||||
PyObject ret = evalRestricted((PyCode) compiledScript.compiled());
|
||||
if (ret == null) {
|
||||
return null;
|
||||
}
|
||||
return ret.__tojava__(Object.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
interp.cleanup();
|
||||
|
|
|
@ -59,7 +59,7 @@ public class PythonScriptEngineTests extends ESTestCase {
|
|||
@Test
|
||||
public void testSimpleEquation() {
|
||||
Map<String, Object> vars = new HashMap<String, Object>();
|
||||
Object o = se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testSimpleEquation", "python", se.compile("1 + 2")), vars);
|
||||
Object o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testSimpleEquation", "python", se.compile("1 + 2")), vars).run();
|
||||
assertThat(((Number) o).intValue(), equalTo(3));
|
||||
}
|
||||
|
||||
|
@ -70,13 +70,13 @@ public class PythonScriptEngineTests extends ESTestCase {
|
|||
Map<String, Object> obj2 = MapBuilder.<String, Object>newMapBuilder().put("prop2", "value2").map();
|
||||
Map<String, Object> obj1 = MapBuilder.<String, Object>newMapBuilder().put("prop1", "value1").put("obj2", obj2).put("l", Arrays.asList("2", "1")).map();
|
||||
vars.put("obj1", obj1);
|
||||
Object o = se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testMapAccess", "python", se.compile("obj1")), vars);
|
||||
Object o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testMapAccess", "python", se.compile("obj1")), vars).run();
|
||||
assertThat(o, instanceOf(Map.class));
|
||||
obj1 = (Map<String, Object>) o;
|
||||
assertThat((String) obj1.get("prop1"), equalTo("value1"));
|
||||
assertThat((String) ((Map<String, Object>) obj1.get("obj2")).get("prop2"), equalTo("value2"));
|
||||
|
||||
o = se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testMapAccess", "python", se.compile("obj1['l'][0]")), vars);
|
||||
o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testMapAccess", "python", se.compile("obj1['l'][0]")), vars).run();
|
||||
assertThat(((String) o), equalTo("2"));
|
||||
}
|
||||
|
||||
|
@ -110,15 +110,15 @@ public class PythonScriptEngineTests extends ESTestCase {
|
|||
// Object o = se.execute(se.compile("l.length"), vars);
|
||||
// assertThat(((Number) o).intValue(), equalTo(4));
|
||||
|
||||
Object o = se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testAccessListInScript", "python", se.compile("l[0]")), vars);
|
||||
Object o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testAccessListInScript", "python", se.compile("l[0]")), vars).run();
|
||||
assertThat(((String) o), equalTo("1"));
|
||||
|
||||
o = se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testAccessListInScript", "python", se.compile("l[3]")), vars);
|
||||
o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testAccessListInScript", "python", se.compile("l[3]")), vars).run();
|
||||
obj1 = (Map<String, Object>) o;
|
||||
assertThat((String) obj1.get("prop1"), equalTo("value1"));
|
||||
assertThat((String) ((Map<String, Object>) obj1.get("obj2")).get("prop2"), equalTo("value2"));
|
||||
|
||||
o = se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "testAccessListInScript", "python", se.compile("l[3]['prop1']")), vars);
|
||||
o = se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "testAccessListInScript", "python", se.compile("l[3]['prop1']")), vars).run();
|
||||
assertThat(((String) o), equalTo("value1"));
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ public class PythonScriptMultiThreadedTests extends ESTestCase {
|
|||
long addition = x + y;
|
||||
runtimeVars.put("x", x);
|
||||
runtimeVars.put("y", y);
|
||||
long result = ((Number) se.execute(compiledScript, runtimeVars)).longValue();
|
||||
long result = ((Number) se.executable(compiledScript, runtimeVars).run()).longValue();
|
||||
assertThat(result, equalTo(addition));
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
|
|
|
@ -53,7 +53,7 @@ public class PythonSecurityTests extends ESTestCase {
|
|||
/** runs a script */
|
||||
private void doTest(String script) {
|
||||
Map<String, Object> vars = new HashMap<String, Object>();
|
||||
se.execute(new CompiledScript(ScriptService.ScriptType.INLINE, "test", "python", se.compile(script)), vars);
|
||||
se.executable(new CompiledScript(ScriptService.ScriptType.INLINE, "test", "python", se.compile(script)), vars).run();
|
||||
}
|
||||
|
||||
/** asserts that a script runs without exception */
|
||||
|
@ -68,7 +68,10 @@ public class PythonSecurityTests extends ESTestCase {
|
|||
fail("did not get expected exception");
|
||||
} catch (PyException expected) {
|
||||
Throwable cause = expected.getCause();
|
||||
assertNotNull("null cause for exception: " + expected, cause);
|
||||
// TODO: fix jython localization bugs: https://github.com/elastic/elasticsearch/issues/13967
|
||||
// this is the correct assert:
|
||||
// assertNotNull("null cause for exception: " + expected, cause);
|
||||
assertNotNull("null cause for exception", cause);
|
||||
assertTrue("unexpected exception: " + cause, cause instanceof SecurityException);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,14 +44,14 @@ public class SimpleBench {
|
|||
for (int i = 0; i < 1000; i++) {
|
||||
vars.put("x", i);
|
||||
vars.put("y", i + 1);
|
||||
se.execute(compiledScript, vars);
|
||||
se.executable(compiledScript, vars).run();
|
||||
}
|
||||
|
||||
final long ITER = 100000;
|
||||
|
||||
StopWatch stopWatch = new StopWatch().start();
|
||||
for (long i = 0; i < ITER; i++) {
|
||||
se.execute(compiledScript, vars);
|
||||
se.executable(compiledScript, vars).run();
|
||||
}
|
||||
System.out.println("Execute Took: " + stopWatch.stop().lastTaskTime());
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
# Load test utilities
|
||||
load packaging_test_utils
|
||||
load tar
|
||||
load plugins
|
||||
|
||||
setup() {
|
||||
skip_not_tar_gz
|
||||
|
@ -91,12 +92,9 @@ setup() {
|
|||
# starting Elasticsearch so we don't have to wait for elasticsearch to scan for
|
||||
# them.
|
||||
install_elasticsearch_test_scripts
|
||||
|
||||
ESPLUGIN_COMMAND_USER=elasticsearch install_and_check_plugin lang groovy
|
||||
start_elasticsearch_service
|
||||
|
||||
run_elasticsearch_tests
|
||||
|
||||
stop_elasticsearch_service
|
||||
|
||||
rm -rf "/tmp/elasticsearch"
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
# Load test utilities
|
||||
load packaging_test_utils
|
||||
load os_package
|
||||
load plugins
|
||||
|
||||
# Cleans everything for the 1st execution
|
||||
setup() {
|
||||
|
@ -85,6 +86,7 @@ setup() {
|
|||
# starting Elasticsearch so we don't have to wait for elasticsearch to scan for
|
||||
# them.
|
||||
install_elasticsearch_test_scripts
|
||||
ESPLUGIN_COMMAND_USER=root install_and_check_plugin lang groovy
|
||||
start_elasticsearch_service
|
||||
run_elasticsearch_tests
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
# Load test utilities
|
||||
load packaging_test_utils
|
||||
load os_package
|
||||
load plugins
|
||||
|
||||
# Cleans everything for the 1st execution
|
||||
setup() {
|
||||
|
@ -80,6 +81,7 @@ setup() {
|
|||
# starting Elasticsearch so we don't have to wait for elasticsearch to scan for
|
||||
# them.
|
||||
install_elasticsearch_test_scripts
|
||||
ESPLUGIN_COMMAND_USER=root install_and_check_plugin lang groovy
|
||||
start_elasticsearch_service
|
||||
run_elasticsearch_tests
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
# Load test utilities
|
||||
load packaging_test_utils
|
||||
load os_package
|
||||
load plugins
|
||||
|
||||
# Cleans everything for the 1st execution
|
||||
setup() {
|
||||
|
@ -67,6 +68,7 @@ setup() {
|
|||
# starting Elasticsearch so we don't have to wait for elasticsearch to scan for
|
||||
# them.
|
||||
install_elasticsearch_test_scripts
|
||||
ESPLUGIN_COMMAND_USER=root install_and_check_plugin lang groovy
|
||||
systemctl start elasticsearch.service
|
||||
wait_for_elasticsearch_status
|
||||
assert_file_exist "/var/run/elasticsearch/elasticsearch.pid"
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
# Load test utilities
|
||||
load packaging_test_utils
|
||||
load os_package
|
||||
load plugins
|
||||
|
||||
# Cleans everything for the 1st execution
|
||||
setup() {
|
||||
|
@ -69,6 +70,7 @@ setup() {
|
|||
# Install scripts used to test script filters and search templates before
|
||||
# starting Elasticsearch so we don't have to wait for elasticsearch to scan for
|
||||
# them.
|
||||
ESPLUGIN_COMMAND_USER=root install_and_check_plugin lang groovy
|
||||
install_elasticsearch_test_scripts
|
||||
service elasticsearch start
|
||||
wait_for_elasticsearch_status
|
||||
|
|
|
@ -243,8 +243,14 @@ start_elasticsearch_service() {
|
|||
# su and the Elasticsearch init script work together to break bats.
|
||||
# sudo isolates bats enough from the init script so everything continues
|
||||
# to tick along
|
||||
sudo -u elasticsearch /tmp/elasticsearch/bin/elasticsearch -d \
|
||||
-p /tmp/elasticsearch/elasticsearch.pid
|
||||
sudo -u elasticsearch bash <<BASH
|
||||
# If jayatana is installed then we try to use it. Elasticsearch should ignore it even when we try.
|
||||
# If it doesn't ignore it then Elasticsearch will fail to start because of security errors.
|
||||
# This line is attempting to emulate the on login behavior of /usr/share/upstart/sessions/jayatana.conf
|
||||
[ -f /usr/share/java/jayatanaag.jar ] && export JAVA_TOOL_OPTIONS="-javaagent:/usr/share/java/jayatanaag.jar"
|
||||
# And now we can start Elasticsearch normally, in the background (-d) and with a pidfile (-p).
|
||||
/tmp/elasticsearch/bin/elasticsearch -d -p /tmp/elasticsearch/elasticsearch.pid
|
||||
BASH
|
||||
elif is_systemd; then
|
||||
run systemctl daemon-reload
|
||||
[ "$status" -eq 0 ]
|
||||
|
|
|
@ -352,3 +352,26 @@ fi
|
|||
@test "[$GROUP] stop elasticsearch" {
|
||||
stop_elasticsearch_service
|
||||
}
|
||||
|
||||
@test "[$GROUP] install jvm-example with different logging modes and check output" {
|
||||
local relativePath=${1:-$(readlink -m jvm-example-*.zip)}
|
||||
sudo -E -u $ESPLUGIN_COMMAND_USER "$ESHOME/bin/plugin" install "file://$relativePath" > /tmp/plugin-cli-output
|
||||
local loglines=$(cat /tmp/plugin-cli-output | wc -l)
|
||||
[ "$loglines" = "6" ] || {
|
||||
echo "Expected 6 lines but the output was:"
|
||||
cat /tmp/plugin-cli-output
|
||||
false
|
||||
}
|
||||
remove_jvm_example
|
||||
|
||||
local relativePath=${1:-$(readlink -m jvm-example-*.zip)}
|
||||
sudo -E -u $ESPLUGIN_COMMAND_USER "$ESHOME/bin/plugin" install "file://$relativePath" -Des.logger.level=DEBUG > /tmp/plugin-cli-output
|
||||
local loglines=$(cat /tmp/plugin-cli-output | wc -l)
|
||||
[ "$loglines" -gt "6" ] || {
|
||||
echo "Expected more than 6 lines but the output was:"
|
||||
cat /tmp/plugin-cli-output
|
||||
false
|
||||
}
|
||||
remove_jvm_example
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ install_plugin() {
|
|||
|
||||
assert_file_exist "$ESPLUGINS/$name"
|
||||
assert_file_exist "$ESPLUGINS/$name/plugin-descriptor.properties"
|
||||
#check we did not accidentially create a log file as root as /usr/share/elasticsearch
|
||||
assert_file_not_exist "/usr/share/elasticsearch/logs"
|
||||
|
||||
# At some point installing or removing plugins caused elasticsearch's logs
|
||||
# to be owned by root. This is bad so we want to make sure it doesn't
|
||||
|
|
|
@ -18,7 +18,7 @@ setup:
|
|||
|
||||
- do:
|
||||
indices.get_field_mapping:
|
||||
field: text
|
||||
fields: text
|
||||
|
||||
- match: {test_index.mappings.test_type.text.mapping.text.type: string}
|
||||
|
||||
|
@ -27,7 +27,7 @@ setup:
|
|||
- do:
|
||||
indices.get_field_mapping:
|
||||
index: test_index
|
||||
field: text
|
||||
fields: text
|
||||
|
||||
- match: {test_index.mappings.test_type.text.mapping.text.type: string}
|
||||
|
||||
|
@ -38,7 +38,7 @@ setup:
|
|||
indices.get_field_mapping:
|
||||
index: test_index
|
||||
type: test_type
|
||||
field: text
|
||||
fields: text
|
||||
|
||||
- match: {test_index.mappings.test_type.text.mapping.text.type: string}
|
||||
|
||||
|
@ -49,7 +49,7 @@ setup:
|
|||
indices.get_field_mapping:
|
||||
index: test_index
|
||||
type: test_type
|
||||
field: [ text , text1 ]
|
||||
fields: [ text , text1 ]
|
||||
|
||||
- match: {test_index.mappings.test_type.text.mapping.text.type: string}
|
||||
- is_false: test_index.mappings.test_type.text1
|
||||
|
@ -61,19 +61,19 @@ setup:
|
|||
indices.get_field_mapping:
|
||||
index: test_index
|
||||
type: test_type
|
||||
field: text
|
||||
fields: text
|
||||
include_defaults: true
|
||||
|
||||
- match: {test_index.mappings.test_type.text.mapping.text.type: string}
|
||||
- match: {test_index.mappings.test_type.text.mapping.text.analyzer: default}
|
||||
|
||||
---
|
||||
"Get field mapping should work without index specifying type and field":
|
||||
"Get field mapping should work without index specifying type and fields":
|
||||
|
||||
- do:
|
||||
indices.get_field_mapping:
|
||||
type: test_type
|
||||
field: text
|
||||
fields: text
|
||||
|
||||
- match: {test_index.mappings.test_type.text.mapping.text.type: string}
|
||||
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
indices.get_field_mapping:
|
||||
index: test_index
|
||||
type: test_type
|
||||
field: not_existent
|
||||
fields: not_existent
|
||||
|
||||
- match: { '': {}}
|
||||
|
|
|
@ -20,5 +20,5 @@
|
|||
indices.get_field_mapping:
|
||||
index: test_index
|
||||
type: not_test_type
|
||||
field: text
|
||||
fields: text
|
||||
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
indices.get_field_mapping:
|
||||
index: test_index
|
||||
type: type
|
||||
field: field
|
||||
fields: field
|
||||
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ setup:
|
|||
|
||||
- do:
|
||||
indices.get_field_mapping:
|
||||
field: "*"
|
||||
fields: "*"
|
||||
|
||||
- match: {test_index.mappings.test_type.t1.full_name: t1 }
|
||||
- match: {test_index.mappings.test_type.t2.full_name: t2 }
|
||||
|
@ -63,7 +63,7 @@ setup:
|
|||
- do:
|
||||
indices.get_field_mapping:
|
||||
index: test_index
|
||||
field: "t*"
|
||||
fields: "t*"
|
||||
|
||||
- match: {test_index.mappings.test_type.t1.full_name: t1 }
|
||||
- match: {test_index.mappings.test_type.t2.full_name: t2 }
|
||||
|
@ -75,7 +75,7 @@ setup:
|
|||
- do:
|
||||
indices.get_field_mapping:
|
||||
index: test_index
|
||||
field: "*t1"
|
||||
fields: "*t1"
|
||||
- match: {test_index.mappings.test_type.t1.full_name: t1 }
|
||||
- match: {test_index.mappings.test_type.obj\.t1.full_name: obj.t1 }
|
||||
- match: {test_index.mappings.test_type.obj\.i_t1.full_name: obj.i_t1 }
|
||||
|
@ -87,7 +87,7 @@ setup:
|
|||
- do:
|
||||
indices.get_field_mapping:
|
||||
index: test_index
|
||||
field: "obj.i_*"
|
||||
fields: "obj.i_*"
|
||||
- match: {test_index.mappings.test_type.obj\.i_t1.full_name: obj.i_t1 }
|
||||
- match: {test_index.mappings.test_type.obj\.i_t3.full_name: obj.i_t3 }
|
||||
- length: {test_index.mappings.test_type: 2}
|
||||
|
@ -99,7 +99,7 @@ setup:
|
|||
indices.get_field_mapping:
|
||||
index: _all
|
||||
type: _all
|
||||
field: "t*"
|
||||
fields: "t*"
|
||||
- match: {test_index.mappings.test_type.t1.full_name: t1 }
|
||||
- match: {test_index.mappings.test_type.t2.full_name: t2 }
|
||||
- length: {test_index.mappings.test_type: 2}
|
||||
|
@ -114,7 +114,7 @@ setup:
|
|||
indices.get_field_mapping:
|
||||
index: '*'
|
||||
type: '*'
|
||||
field: "t*"
|
||||
fields: "t*"
|
||||
- match: {test_index.mappings.test_type.t1.full_name: t1 }
|
||||
- match: {test_index.mappings.test_type.t2.full_name: t2 }
|
||||
- length: {test_index.mappings.test_type: 2}
|
||||
|
@ -129,7 +129,7 @@ setup:
|
|||
indices.get_field_mapping:
|
||||
index: 'test_index,test_index_2'
|
||||
type: 'test_type,test_type_2'
|
||||
field: "t*"
|
||||
fields: "t*"
|
||||
- match: {test_index.mappings.test_type.t1.full_name: t1 }
|
||||
- match: {test_index.mappings.test_type.t2.full_name: t2 }
|
||||
- length: {test_index.mappings.test_type: 2}
|
||||
|
|
Loading…
Reference in New Issue