Skip to content

Commit

Permalink
Merge branch 'main' into esql-binary-comparators-part-1
Browse files Browse the repository at this point in the history
  • Loading branch information
not-napoleon committed Apr 11, 2024
2 parents 1dd3fd2 + 648c9cb commit 5573ca7
Show file tree
Hide file tree
Showing 2,203 changed files with 50,004 additions and 17,580 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipelines/intake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ steps:
timeout_in_minutes: 300
matrix:
setup:
BWC_VERSION: ["7.17.20", "8.13.1", "8.14.0"]
BWC_VERSION: ["7.17.21", "8.13.3", "8.14.0"]
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2004
Expand Down
12 changes: 6 additions & 6 deletions .buildkite/pipelines/periodic-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ steps:
env:
BWC_VERSION: 7.16.3

- label: "{{matrix.image}} / 7.17.20 / packaging-tests-upgrade"
command: ./.ci/scripts/packaging-test.sh -Dbwc.checkout.align=true destructiveDistroUpgradeTest.v7.17.20
- label: "{{matrix.image}} / 7.17.21 / packaging-tests-upgrade"
command: ./.ci/scripts/packaging-test.sh -Dbwc.checkout.align=true destructiveDistroUpgradeTest.v7.17.21
timeout_in_minutes: 300
matrix:
setup:
Expand All @@ -319,7 +319,7 @@ steps:
machineType: custom-16-32768
buildDirectory: /dev/shm/bk
env:
BWC_VERSION: 7.17.20
BWC_VERSION: 7.17.21

- label: "{{matrix.image}} / 8.0.1 / packaging-tests-upgrade"
command: ./.ci/scripts/packaging-test.sh -Dbwc.checkout.align=true destructiveDistroUpgradeTest.v8.0.1
Expand Down Expand Up @@ -529,8 +529,8 @@ steps:
env:
BWC_VERSION: 8.12.2

- label: "{{matrix.image}} / 8.13.1 / packaging-tests-upgrade"
command: ./.ci/scripts/packaging-test.sh -Dbwc.checkout.align=true destructiveDistroUpgradeTest.v8.13.1
- label: "{{matrix.image}} / 8.13.3 / packaging-tests-upgrade"
command: ./.ci/scripts/packaging-test.sh -Dbwc.checkout.align=true destructiveDistroUpgradeTest.v8.13.3
timeout_in_minutes: 300
matrix:
setup:
Expand All @@ -543,7 +543,7 @@ steps:
machineType: custom-16-32768
buildDirectory: /dev/shm/bk
env:
BWC_VERSION: 8.13.1
BWC_VERSION: 8.13.3

- label: "{{matrix.image}} / 8.14.0 / packaging-tests-upgrade"
command: ./.ci/scripts/packaging-test.sh -Dbwc.checkout.align=true destructiveDistroUpgradeTest.v8.14.0
Expand Down
2 changes: 0 additions & 2 deletions .buildkite/pipelines/periodic.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ steps:
- graalvm-ce17
- openjdk17
- openjdk21
- openjdk22
GRADLE_TASK:
- checkPart1
- checkPart2
Expand All @@ -108,7 +107,6 @@ steps:
- graalvm-ce17
- openjdk17
- openjdk21
- openjdk22
BWC_VERSION: $BWC_LIST
agents:
provider: gcp
Expand Down
18 changes: 8 additions & 10 deletions .buildkite/pipelines/periodic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,16 @@ steps:
buildDirectory: /dev/shm/bk
env:
BWC_VERSION: 7.16.3
- label: 7.17.20 / bwc
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v7.17.20#bwcTest
- label: 7.17.21 / bwc
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v7.17.21#bwcTest
timeout_in_minutes: 300
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2004
machineType: n1-standard-32
buildDirectory: /dev/shm/bk
env:
BWC_VERSION: 7.17.20
BWC_VERSION: 7.17.21
- label: 8.0.1 / bwc
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v8.0.1#bwcTest
timeout_in_minutes: 300
Expand Down Expand Up @@ -312,16 +312,16 @@ steps:
buildDirectory: /dev/shm/bk
env:
BWC_VERSION: 8.12.2
- label: 8.13.1 / bwc
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v8.13.1#bwcTest
- label: 8.13.3 / bwc
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v8.13.3#bwcTest
timeout_in_minutes: 300
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2004
machineType: n1-standard-32
buildDirectory: /dev/shm/bk
env:
BWC_VERSION: 8.13.1
BWC_VERSION: 8.13.3
- label: 8.14.0 / bwc
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v8.14.0#bwcTest
timeout_in_minutes: 300
Expand Down Expand Up @@ -396,7 +396,7 @@ steps:
setup:
ES_RUNTIME_JAVA:
- openjdk17
BWC_VERSION: ["7.17.20", "8.13.1", "8.14.0"]
BWC_VERSION: ["7.17.21", "8.13.3", "8.14.0"]
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2004
Expand All @@ -416,7 +416,6 @@ steps:
- graalvm-ce17
- openjdk17
- openjdk21
- openjdk22
GRADLE_TASK:
- checkPart1
- checkPart2
Expand All @@ -439,8 +438,7 @@ steps:
- graalvm-ce17
- openjdk17
- openjdk21
- openjdk22
BWC_VERSION: ["7.17.20", "8.13.1", "8.14.0"]
BWC_VERSION: ["7.17.21", "8.13.3", "8.14.0"]
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2004
Expand Down
4 changes: 2 additions & 2 deletions .ci/bwcVersions
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ BWC_VERSION:
- "7.14.2"
- "7.15.2"
- "7.16.3"
- "7.17.20"
- "7.17.21"
- "8.0.1"
- "8.1.3"
- "8.2.3"
Expand All @@ -30,5 +30,5 @@ BWC_VERSION:
- "8.10.4"
- "8.11.4"
- "8.12.2"
- "8.13.1"
- "8.13.3"
- "8.14.0"
4 changes: 2 additions & 2 deletions .ci/snapshotBwcVersions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BWC_VERSION:
- "7.17.20"
- "8.13.1"
- "7.17.21"
- "8.13.3"
- "8.14.0"
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.ProjectLayout;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.tasks.CacheableTask;
import org.gradle.api.tasks.IgnoreEmptyDirectories;
Expand All @@ -39,21 +40,22 @@
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import org.gradle.api.model.ObjectFactory;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Serializable;
import java.io.Writer;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import javax.inject.Inject;
import java.io.Serializable;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

/**
* Checks files for license headers..
Expand Down Expand Up @@ -232,7 +234,7 @@ private ClaimStatistic toXmlReportFile(ReportConfiguration config, Writer writer

private static List<String> unapprovedFiles(File xmlReportFile) {
try {
NodeList resourcesNodes = DocumentBuilderFactory.newInstance()
NodeList resourcesNodes = createXmlDocumentBuilderFactory()
.newDocumentBuilder()
.parse(xmlReportFile)
.getElementsByTagName("resource");
Expand All @@ -249,6 +251,21 @@ private static List<String> unapprovedFiles(File xmlReportFile) {
}
}

private static DocumentBuilderFactory createXmlDocumentBuilderFactory() throws ParserConfigurationException {
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setXIncludeAware(false);
dbf.setIgnoringComments(true);
dbf.setExpandEntityReferences(false);
dbf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
dbf.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
return dbf;
}

private static List<Element> elementList(NodeList resourcesNodes) {
List<Element> nodeList = new ArrayList<>(resourcesNodes.getLength());
for (int idx = 0; idx < resourcesNodes.getLength(); idx++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

package org.elasticsearch.gradle.internal.doc

import org.elasticsearch.gradle.fixtures.AbstractGradleInternalPluginFuncTest
import org.elasticsearch.gradle.internal.conventions.precommit.PrecommitPlugin
import org.gradle.testkit.runner.TaskOutcome

class DocsTestPluginFuncTest extends AbstractGradleInternalPluginFuncTest {
Class<? extends PrecommitPlugin> pluginClassUnderTest = DocsTestPlugin.class

def setup() {
File docDir = new File(projectDir, 'doc');
docDir.mkdirs()
addSampleDoc(docDir)
buildApiRestrictionsDisabled = true
configurationCacheCompatible = false;
buildFile << """
tasks.named('listSnippets') {
docs = fileTree('doc')
}
tasks.named('listConsoleCandidates') {
docs = fileTree('doc')
}
"""
}

def "can list snippets"() {
when:
def result = gradleRunner("listSnippets").build()
then:
result.task(":listSnippets").outcome == TaskOutcome.SUCCESS
assertOutputContains(result.output, """
> Task :listSnippets
mapper-annotated-text.asciidoc[37:39](Painless)
mapper-annotated-text.asciidoc[42:44](js)
mapper-annotated-text.asciidoc[51:69](console)// TEST[setup:seats]
""")
}

def "can console candidates"() {
when:
def result = gradleRunner("listConsoleCandidates").build()
then:
result.task(":listConsoleCandidates").outcome == TaskOutcome.SUCCESS
assertOutputContains(result.output, """
> Task :listConsoleCandidates
mapper-annotated-text.asciidoc[42:44](js)
""")
}

void addSampleDoc(File docFolder) {
new File(docFolder, "mapper-annotated-text.asciidoc").text = """
[[painless-filter-context]]
=== Filter context
Use a Painless script as a {ref}/query-dsl-script-query.html[filter] in a
query to include and exclude documents.
*Variables*
`params` (`Map`, read-only)::
User-defined parameters passed in as part of the query.
`doc` (`Map`, read-only)::
Contains the fields of the current document where each field is a
`List` of values.
*Return*
`boolean`::
Return `true` if the current document should be returned as a result of
the query, and `false` otherwise.
*API*
The standard <<painless-api-reference-shared, Painless API>> is available.
*Example*
To run this example, first follow the steps in
<<painless-context-examples, context examples>>.
This script finds all unsold documents that cost less than \$25.
[source,Painless]
----
doc['sold'].value == false && doc['cost'].value < 25
----
[source,js]
----
curl 'hello world'
----
Defining `cost` as a script parameter enables the cost to be configured
in the script query request. For example, the following request finds
all available theatre seats for evening performances that are under \$25.
[source,console]
----
GET seats/_search
{
"query": {
"bool": {
"filter": {
"script": {
"script": {
"source": "doc['sold'].value == false && doc['cost'].value < params.cost",
"params": {
"cost": 25
}
}
}
}
}
}
}
----
// TEST[setup:seats]
"""
}
}
27 changes: 15 additions & 12 deletions build-tools-internal/src/main/groovy/elasticsearch.ide.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ if (providers.systemProperty('idea.active').getOrNull() == 'true') {
':server:generateModulesList',
':server:generatePluginsList',
':generateProviderImpls',
':libs:elasticsearch-native:elasticsearch-native-libraries:extractLibs'].collect { elasticsearchProject.right()?.task(it) ?: it })
':libs:elasticsearch-native:elasticsearch-native-libraries:extractLibs',
':x-pack:libs:es-opensaml-security-api:shadowJar'].collect { elasticsearchProject.right()?.task(it) ?: it })
}

// this path is produced by the extractLibs task above
Expand Down Expand Up @@ -239,20 +240,22 @@ if (providers.systemProperty('idea.active').getOrNull() == 'true') {
* but before the XML document, e.g. a doctype or comment
*/
void modifyXml(Object path, Action<? super Node> action, String preface = null) {
Node xml = parseXml(path)
action.execute(xml)
if (project.file(path).exists()) {
Node xml = parseXml(path)
action.execute(xml)

File xmlFile = project.file(path)
xmlFile.withPrintWriter { writer ->
def printer = new XmlNodePrinter(writer)
printer.namespaceAware = true
printer.preserveWhitespace = true
writer.write("<?xml version=\"1.0\"?>\n")
File xmlFile = project.file(path)
xmlFile.withPrintWriter { writer ->
def printer = new XmlNodePrinter(writer)
printer.namespaceAware = true
printer.preserveWhitespace = true
writer.write("<?xml version=\"1.0\"?>\n")

if (preface != null) {
writer.write(preface)
if (preface != null) {
writer.write(preface)
}
printer.print(xml)
}
printer.print(xml)
}
}

Expand Down
Loading

0 comments on commit 5573ca7

Please sign in to comment.