Search in sources :

Example 1 with ScriptModule

use of org.elasticsearch.script.ScriptModule in project elasticsearch by elastic.

the class ESTestCase method newTestScriptModule.

public static ScriptModule newTestScriptModule() {
    Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).put(ScriptService.SCRIPT_AUTO_RELOAD_ENABLED_SETTING.getKey(), false).build();
    Environment environment = new Environment(settings);
    MockScriptEngine scriptEngine = new MockScriptEngine(MockScriptEngine.NAME, Collections.singletonMap("1", script -> "1"));
    return new ScriptModule(settings, environment, null, singletonList(scriptEngine), emptyList());
}
Also used : DateTimeZone(org.joda.time.DateTimeZone) Arrays(java.util.Arrays) LoggerContext(org.apache.logging.log4j.core.LoggerContext) TestRuleAdapter(com.carrotsearch.randomizedtesting.rules.TestRuleAdapter) ThreadContext(org.elasticsearch.common.util.concurrent.ThreadContext) TokenizerFactory(org.elasticsearch.index.analysis.TokenizerFactory) Level(org.apache.logging.log4j.Level) IndexAnalyzers(org.elasticsearch.index.analysis.IndexAnalyzers) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) JsonXContent(org.elasticsearch.common.xcontent.json.JsonXContent) BooleanSupplier(java.util.function.BooleanSupplier) Collections.singletonList(java.util.Collections.singletonList) DirectoryStream(java.nio.file.DirectoryStream) RandomNumbers(com.carrotsearch.randomizedtesting.generators.RandomNumbers) ThreadLeakLingering(com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering) Map(java.util.Map) TimeUnits(org.apache.lucene.util.TimeUnits) AnalysisModule(org.elasticsearch.indices.analysis.AnalysisModule) Path(java.nio.file.Path) RandomStrings(com.carrotsearch.randomizedtesting.generators.RandomStrings) AfterClass(org.junit.AfterClass) CharFilterFactory(org.elasticsearch.index.analysis.CharFilterFactory) LoggingListener(org.elasticsearch.test.junit.listeners.LoggingListener) Set(java.util.Set) CollectionUtils.arrayAsArrayList(org.elasticsearch.common.util.CollectionUtils.arrayAsArrayList) MockBigArrays(org.elasticsearch.common.util.MockBigArrays) RandomizedTest(com.carrotsearch.randomizedtesting.RandomizedTest) MockPageCacheRecycler(org.elasticsearch.common.util.MockPageCacheRecycler) UncheckedIOException(java.io.UncheckedIOException) StatusConsoleListener(org.apache.logging.log4j.status.StatusConsoleListener) ReproduceInfoPrinter(org.elasticsearch.test.junit.listeners.ReproduceInfoPrinter) Logger(org.apache.logging.log4j.Logger) Stream(java.util.stream.Stream) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData) XContentFactory(org.elasticsearch.common.xcontent.XContentFactory) RandomPicks(com.carrotsearch.randomizedtesting.generators.RandomPicks) SuppressCodecs(org.apache.lucene.util.LuceneTestCase.SuppressCodecs) TimeoutSuite(com.carrotsearch.randomizedtesting.annotations.TimeoutSuite) NamedWriteable(org.elasticsearch.common.io.stream.NamedWriteable) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) ScriptModule(org.elasticsearch.script.ScriptModule) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) TestRuleMarkFailure(org.apache.lucene.util.TestRuleMarkFailure) XContentHelper(org.elasticsearch.common.xcontent.XContentHelper) BootstrapForTesting(org.elasticsearch.bootstrap.BootstrapForTesting) NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) ThreadLeakScope(com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope) IndicesModule(org.elasticsearch.indices.IndicesModule) IndicesService(org.elasticsearch.indices.IndicesService) PathUtils(org.elasticsearch.common.io.PathUtils) Before(org.junit.Before) Loggers(org.elasticsearch.common.logging.Loggers) Files(java.nio.file.Files) PathUtilsForTesting(org.elasticsearch.common.io.PathUtilsForTesting) IOException(java.io.IOException) XContentParser(org.elasticsearch.common.xcontent.XContentParser) NamedWriteableAwareStreamInput(org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput) TreeMap(java.util.TreeMap) ScriptService(org.elasticsearch.script.ScriptService) UninvertingReader(org.apache.lucene.uninverting.UninvertingReader) AnalysisPlugin(org.elasticsearch.plugins.AnalysisPlugin) Environment(org.elasticsearch.env.Environment) XContent(org.elasticsearch.common.xcontent.XContent) Random(java.util.Random) Settings(org.elasticsearch.common.settings.Settings) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) After(org.junit.After) ThreadPool(org.elasticsearch.threadpool.ThreadPool) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) Setting(org.elasticsearch.common.settings.Setting) MockSearchService(org.elasticsearch.search.MockSearchService) Predicate(java.util.function.Predicate) Collections.emptyList(java.util.Collections.emptyList) Collection(java.util.Collection) ToXContent(org.elasticsearch.common.xcontent.ToXContent) AnalysisRegistry(org.elasticsearch.index.analysis.AnalysisRegistry) ClusterModule(org.elasticsearch.cluster.ClusterModule) BytesReference(org.elasticsearch.common.bytes.BytesReference) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) Version(org.elasticsearch.Version) TransportAddress(org.elasticsearch.common.transport.TransportAddress) MockScriptEngine(org.elasticsearch.script.MockScriptEngine) Matchers.equalTo(org.hamcrest.Matchers.equalTo) LuceneTestCase(org.apache.lucene.util.LuceneTestCase) StatusData(org.apache.logging.log4j.status.StatusData) DeprecationLogger(org.elasticsearch.common.logging.DeprecationLogger) BeforeClass(org.junit.BeforeClass) XContentType(org.elasticsearch.common.xcontent.XContentType) TestUtil(org.apache.lucene.util.TestUtil) Index(org.elasticsearch.index.Index) HashSet(java.util.HashSet) Configurator(org.apache.logging.log4j.core.config.Configurator) IndexSettings(org.elasticsearch.index.IndexSettings) Listeners(com.carrotsearch.randomizedtesting.annotations.Listeners) Requests(org.elasticsearch.client.Requests) MapperPlugin(org.elasticsearch.plugins.MapperPlugin) ExecutorService(java.util.concurrent.ExecutorService) Scope(com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope) Matchers.empty(org.hamcrest.Matchers.empty) Mapper(org.elasticsearch.index.mapper.Mapper) RuleChain(org.junit.rules.RuleChain) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) Rule(org.junit.Rule) StreamInput(org.elasticsearch.common.io.stream.StreamInput) StatusLogger(org.apache.logging.log4j.status.StatusLogger) TokenFilterFactory(org.elasticsearch.index.analysis.TokenFilterFactory) CodepointSetGenerator(com.carrotsearch.randomizedtesting.generators.CodepointSetGenerator) Writeable(org.elasticsearch.common.io.stream.Writeable) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) MetadataFieldMapper(org.elasticsearch.index.mapper.MetadataFieldMapper) InputStream(java.io.InputStream) ScriptModule(org.elasticsearch.script.ScriptModule) Environment(org.elasticsearch.env.Environment) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) MockScriptEngine(org.elasticsearch.script.MockScriptEngine) Settings(org.elasticsearch.common.settings.Settings) IndexSettings(org.elasticsearch.index.IndexSettings)

Aggregations

RandomizedTest (com.carrotsearch.randomizedtesting.RandomizedTest)1 Listeners (com.carrotsearch.randomizedtesting.annotations.Listeners)1 ThreadLeakLingering (com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering)1 ThreadLeakScope (com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope)1 Scope (com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope)1 TimeoutSuite (com.carrotsearch.randomizedtesting.annotations.TimeoutSuite)1 CodepointSetGenerator (com.carrotsearch.randomizedtesting.generators.CodepointSetGenerator)1 RandomNumbers (com.carrotsearch.randomizedtesting.generators.RandomNumbers)1 RandomPicks (com.carrotsearch.randomizedtesting.generators.RandomPicks)1 RandomStrings (com.carrotsearch.randomizedtesting.generators.RandomStrings)1 TestRuleAdapter (com.carrotsearch.randomizedtesting.rules.TestRuleAdapter)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 UncheckedIOException (java.io.UncheckedIOException)1 DirectoryStream (java.nio.file.DirectoryStream)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1