mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 13:08:29 +00:00
Well, we have a test here that intentionally causes an OutOfMemoryError, to ensure that Painless handles it (I still strongly disagree with doing this). This causes two things to happen: an OutOfMemoryError to be dumped to the console, and the heap to be dumped to disk. This makes it look like we had an OutOfMemoryError while running tests, and the tests did not fail properly. This commit changes the tests configuration so that we suppress the heap dump, which also causes the OutOfMemoryError to no longer be dumped to the console.
178 lines
5.6 KiB
Groovy
178 lines
5.6 KiB
Groovy
/*
|
|
* 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.
|
|
*/
|
|
|
|
import org.elasticsearch.gradle.test.ClusterConfiguration
|
|
import org.elasticsearch.gradle.test.ClusterFormationTasks
|
|
|
|
esplugin {
|
|
description 'An easy, safe and fast scripting language for Elasticsearch'
|
|
classname 'org.elasticsearch.painless.PainlessPlugin'
|
|
}
|
|
|
|
testClusters.integTest {
|
|
module file(project(':modules:mapper-extras').tasks.bundlePlugin.archiveFile)
|
|
systemProperty 'es.scripting.update.ctx_in_params', 'false'
|
|
}
|
|
|
|
dependencies {
|
|
compile 'org.antlr:antlr4-runtime:4.5.3'
|
|
compile 'org.ow2.asm:asm-debug-all:5.1'
|
|
compile project('spi')
|
|
}
|
|
|
|
dependencyLicenses {
|
|
mapping from: /asm-.*/, to: 'asm'
|
|
}
|
|
|
|
test {
|
|
// in WhenThingsGoWrongTests we intentionally generate an out of memory error, this prevents the heap from being dumped to disk
|
|
jvmArgs '-XX:-OmitStackTraceInFastThrow', '-XX:-HeapDumpOnOutOfMemoryError'
|
|
}
|
|
|
|
/* Build Javadoc for the Java classes in Painless's public API that are in the
|
|
* Painless plugin */
|
|
task apiJavadoc(type: Javadoc) {
|
|
source = sourceSets.main.allJava
|
|
classpath = sourceSets.main.runtimeClasspath
|
|
include '**/org/elasticsearch/painless/api/'
|
|
destinationDir = new File(docsDir, 'apiJavadoc')
|
|
}
|
|
|
|
task apiJavadocJar(type: Jar) {
|
|
classifier = 'apiJavadoc'
|
|
from apiJavadoc
|
|
}
|
|
|
|
assemble.dependsOn apiJavadocJar
|
|
|
|
/**********************************************
|
|
* Context API Generation *
|
|
**********************************************/
|
|
|
|
sourceSets {
|
|
doc
|
|
}
|
|
|
|
dependencies {
|
|
docCompile project(':server')
|
|
docCompile project(':modules:lang-painless')
|
|
}
|
|
|
|
ClusterConfiguration clusterConfig = project.extensions.create("generateContextCluster", ClusterConfiguration.class, project)
|
|
gradle.projectsEvaluated {
|
|
project.ext.generateContextNodes = ClusterFormationTasks.setup(project, "generateContextCluster", generateContextDoc, clusterConfig)
|
|
}
|
|
clusterConfig.distribution = 'default'
|
|
|
|
task generateContextDoc(type: JavaExec) {
|
|
main = 'org.elasticsearch.painless.ContextDocGenerator'
|
|
classpath = sourceSets.doc.runtimeClasspath
|
|
systemProperty "cluster.uri", "${-> project.ext.generateContextNodes.collect { it.httpUri() }.join(',') }"
|
|
}
|
|
|
|
/**********************************************
|
|
* Parser regeneration *
|
|
**********************************************/
|
|
|
|
configurations {
|
|
regenerate
|
|
}
|
|
|
|
dependencies {
|
|
regenerate 'org.antlr:antlr4:4.5.3'
|
|
}
|
|
|
|
String grammarPath = 'src/main/antlr'
|
|
String outputPath = 'src/main/java/org/elasticsearch/painless/antlr'
|
|
|
|
task cleanGenerated(type: Delete) {
|
|
delete fileTree(grammarPath) {
|
|
include '*.tokens'
|
|
}
|
|
delete fileTree(outputPath) {
|
|
include 'Painless*.java'
|
|
}
|
|
}
|
|
|
|
task regenLexer(type: JavaExec) {
|
|
dependsOn cleanGenerated
|
|
main = 'org.antlr.v4.Tool'
|
|
classpath = configurations.regenerate
|
|
systemProperty 'file.encoding', 'UTF-8'
|
|
systemProperty 'user.language', 'en'
|
|
systemProperty 'user.country', 'US'
|
|
systemProperty 'user.variant', ''
|
|
args '-Werror',
|
|
'-package', 'org.elasticsearch.painless.antlr',
|
|
'-o', outputPath,
|
|
"${file(grammarPath)}/PainlessLexer.g4"
|
|
}
|
|
|
|
task regenParser(type: JavaExec) {
|
|
dependsOn regenLexer
|
|
main = 'org.antlr.v4.Tool'
|
|
classpath = configurations.regenerate
|
|
systemProperty 'file.encoding', 'UTF-8'
|
|
systemProperty 'user.language', 'en'
|
|
systemProperty 'user.country', 'US'
|
|
systemProperty 'user.variant', ''
|
|
args '-Werror',
|
|
'-package', 'org.elasticsearch.painless.antlr',
|
|
'-no-listener',
|
|
'-visitor',
|
|
// '-Xlog',
|
|
'-o', outputPath,
|
|
"${file(grammarPath)}/PainlessParser.g4"
|
|
}
|
|
|
|
task regen {
|
|
dependsOn regenParser
|
|
doLast {
|
|
// moves token files to grammar directory for use with IDE's
|
|
ant.move(file: "${outputPath}/PainlessLexer.tokens", toDir: grammarPath)
|
|
ant.move(file: "${outputPath}/PainlessParser.tokens", toDir: grammarPath)
|
|
// make the generated classes package private
|
|
ant.replaceregexp(match: 'public ((interface|class) \\QPainless\\E\\w+)',
|
|
replace: '\\1',
|
|
encoding: 'UTF-8') {
|
|
fileset(dir: outputPath, includes: 'Painless*.java')
|
|
}
|
|
// make the lexer abstract
|
|
ant.replaceregexp(match: '(class \\QPainless\\ELexer)',
|
|
replace: 'abstract \\1',
|
|
encoding: 'UTF-8') {
|
|
fileset(dir: outputPath, includes: 'PainlessLexer.java')
|
|
}
|
|
// nuke timestamps/filenames in generated files
|
|
ant.replaceregexp(match: '\\Q// Generated from \\E.*',
|
|
replace: '\\/\\/ ANTLR GENERATED CODE: DO NOT EDIT',
|
|
encoding: 'UTF-8') {
|
|
fileset(dir: outputPath, includes: 'Painless*.java')
|
|
}
|
|
// remove tabs in antlr generated files
|
|
ant.replaceregexp(match: '\t', flags: 'g', replace: ' ', encoding: 'UTF-8') {
|
|
fileset(dir: outputPath, includes: 'Painless*.java')
|
|
}
|
|
// fix line endings
|
|
ant.fixcrlf(srcdir: outputPath, eol: 'lf') {
|
|
patternset(includes: 'Painless*.java')
|
|
}
|
|
}
|
|
}
|