Skip to content

Commit 4c2f020

Browse files
Merge pull request #166 from elastic/master
🤖 ESQL: Merge upstream
2 parents 8b82c02 + aa6f31f commit 4c2f020

File tree

320 files changed

+5117
-2906
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

320 files changed

+5117
-2906
lines changed

.ci/bwcVersions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ BWC_VERSION:
5454
- "7.17.3"
5555
- "7.17.4"
5656
- "7.17.5"
57+
- "7.17.6"
5758
- "8.0.0"
5859
- "8.0.1"
5960
- "8.1.0"

.ci/snapshotBwcVersions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
BWC_VERSION:
2-
- "7.17.5"
2+
- "7.17.6"
33
- "8.3.1"
44
- "8.4.0"

TESTING.asciidoc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -771,10 +771,6 @@ as its build system. Since the switch to Gradle though, this is no longer possib
771771
the code currently used to build Elasticsearch does not allow JaCoCo to recognize its tests.
772772
For more information on this, see the discussion in https://github.com/elastic/elasticsearch/issues/28867[issue #28867].
773773

774-
---------------------------------------------------------------------------
775-
776-
Read your IDE documentation for how to attach a debugger to a JVM process.
777-
778774
== Building with extra plugins
779775
Additional plugins may be built alongside elasticsearch, where their
780776
dependency on elasticsearch will be substituted with the local elasticsearch

build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/info/GitInfo.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ private static String readFirstLine(final Path path) throws IOException {
168168

169169
/** Find the reponame. */
170170
public String urlFromOrigin() {
171-
String oritin = getOrigin();
172171
if (origin == null) {
173172
return null; // best effort, the url doesnt really matter, it is just required by maven central
174173
}

build-tools-internal/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ dependencies {
291291
exclude module: "groovy"
292292
}
293293
testImplementation buildLibs.spock.junit4
294+
testImplementation buildLibs.json.assert
294295
integTestImplementation buildLibs.xmlunit.core
295296
}
296297

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
package org.elasticsearch.gradle.internal.snyk
10+
11+
import org.elasticsearch.gradle.fixtures.AbstractGradleInternalPluginFuncTest
12+
import org.gradle.api.Plugin
13+
import org.gradle.testkit.runner.TaskOutcome
14+
import org.skyscreamer.jsonassert.JSONAssert
15+
16+
import static java.net.HttpURLConnection.HTTP_CREATED
17+
import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR
18+
import static org.elasticsearch.gradle.fixtures.WiremockFixture.PUT
19+
import static org.elasticsearch.gradle.fixtures.WiremockFixture.withWireMock
20+
import static org.elasticsearch.gradle.internal.snyk.UploadSnykDependenciesGraph.GRADLE_GRAPH_ENDPOINT
21+
22+
class SnykDependencyMonitoringGradlePluginFuncTest extends AbstractGradleInternalPluginFuncTest {
23+
24+
Class<? extends Plugin> pluginClassUnderTest = SnykDependencyMonitoringGradlePlugin.class
25+
26+
def setup() {
27+
configurationCacheCompatible = false // configuration is not cc compliant
28+
}
29+
30+
def "can calculate snyk dependency graph"() {
31+
given:
32+
buildFile << """
33+
apply plugin:'java'
34+
version = "1.0-SNAPSHOT"
35+
36+
repositories {
37+
mavenCentral()
38+
}
39+
40+
dependencies {
41+
implementation 'org.apache.lucene:lucene-monitor:9.2.0'
42+
}
43+
"""
44+
when:
45+
def build = gradleRunner("generateSnykDependencyGraph").build()
46+
then:
47+
build.task(":generateSnykDependencyGraph").outcome == TaskOutcome.SUCCESS
48+
JSONAssert.assertEquals(file( "build/snyk/dependencies.json").text, """{
49+
"meta": {
50+
"method": "custom gradle",
51+
"id": "gradle",
52+
"node": "v16.15.1",
53+
"name": "gradle",
54+
"plugin": "extern:gradle",
55+
"pluginRuntime": "unknown",
56+
"monitorGraph": true
57+
},
58+
"depGraphJSON": {
59+
"pkgManager": {
60+
"version": "7.4.2",
61+
"name": "gradle"
62+
},
63+
"schemaVersion": "1.2.0",
64+
"graph": {
65+
"rootNodeId": "root-node",
66+
"nodes": [
67+
{
68+
"nodeId": "root-node",
69+
"deps": [
70+
{
71+
"nodeId": "org.apache.lucene:[email protected]"
72+
}
73+
],
74+
"pkgId": "[email protected]"
75+
},
76+
{
77+
"nodeId": "org.apache.lucene:[email protected]",
78+
"deps": [
79+
{
80+
"nodeId": "org.apache.lucene:[email protected]"
81+
},
82+
{
83+
"nodeId": "org.apache.lucene:[email protected]"
84+
},
85+
{
86+
"nodeId": "org.apache.lucene:[email protected]"
87+
}
88+
],
89+
"pkgId": "org.apache.lucene:[email protected]"
90+
},
91+
{
92+
"nodeId": "org.apache.lucene:[email protected]",
93+
"deps": [
94+
{
95+
"nodeId": "org.apache.lucene:[email protected]"
96+
}
97+
],
98+
"pkgId": "org.apache.lucene:[email protected]"
99+
},
100+
{
101+
"nodeId": "org.apache.lucene:[email protected]",
102+
"deps": [
103+
104+
],
105+
"pkgId": "org.apache.lucene:[email protected]"
106+
},
107+
{
108+
"nodeId": "org.apache.lucene:[email protected]",
109+
"deps": [
110+
{
111+
"nodeId": "org.apache.lucene:[email protected]"
112+
}
113+
],
114+
"pkgId": "org.apache.lucene:[email protected]"
115+
}
116+
]
117+
},
118+
"pkgs": [
119+
{
120+
121+
"info": {
122+
"name": "hello-world",
123+
"version": "1.0-SNAPSHOT"
124+
}
125+
},
126+
{
127+
"id": "org.apache.lucene:[email protected]",
128+
"info": {
129+
"name": "org.apache.lucene:lucene-monitor",
130+
"version": "9.2.0"
131+
}
132+
},
133+
{
134+
"id": "org.apache.lucene:[email protected]",
135+
"info": {
136+
"name": "org.apache.lucene:lucene-memory",
137+
"version": "9.2.0"
138+
}
139+
},
140+
{
141+
"id": "org.apache.lucene:[email protected]",
142+
"info": {
143+
"name": "org.apache.lucene:lucene-core",
144+
"version": "9.2.0"
145+
}
146+
},
147+
{
148+
"id": "org.apache.lucene:[email protected]",
149+
"info": {
150+
"name": "org.apache.lucene:lucene-analysis-common",
151+
"version": "9.2.0"
152+
}
153+
}
154+
]
155+
},
156+
"target": {
157+
"remoteUrl": "http://github.com/elastic/elasticsearch.git",
158+
"branch": "unknown"
159+
}
160+
}""", true)
161+
}
162+
163+
def "upload fails with reasonable error message"() {
164+
given:
165+
buildFile << """
166+
apply plugin:'java'
167+
"""
168+
when:
169+
def result = withWireMock(PUT, "/api/v1/monitor/gradle/graph", "OK", HTTP_CREATED) { server ->
170+
buildFile << """
171+
tasks.named('uploadSnykDependencyGraph').configure {
172+
getUrl().set('${server.baseUrl()}/api/v1/monitor/gradle/graph')
173+
getToken().set("myToken")
174+
}
175+
"""
176+
gradleRunner("uploadSnykDependencyGraph", '-i', '--stacktrace').build()
177+
}
178+
then:
179+
result.task(":uploadSnykDependencyGraph").outcome == TaskOutcome.SUCCESS
180+
result.output.contains("Snyk API call response status: 201")
181+
182+
when:
183+
result = withWireMock(PUT, GRADLE_GRAPH_ENDPOINT, "Internal Error", HTTP_INTERNAL_ERROR) { server ->
184+
buildFile << """
185+
tasks.named('uploadSnykDependencyGraph').configure {
186+
getUrl().set('${server.baseUrl()}/api/v1/monitor/gradle/graph')
187+
}
188+
"""
189+
gradleRunner("uploadSnykDependencyGraph", '-i').buildAndFail()
190+
}
191+
192+
then:
193+
result.task(":uploadSnykDependencyGraph").outcome == TaskOutcome.FAILED
194+
result.output.contains("Uploading Snyk Graph failed with http code 500: Internal Error")
195+
}
196+
}

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BuildPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import org.elasticsearch.gradle.internal.info.GlobalBuildInfoPlugin;
1212
import org.elasticsearch.gradle.internal.precommit.InternalPrecommitTasks;
13+
import org.elasticsearch.gradle.internal.snyk.SnykDependencyMonitoringGradlePlugin;
1314
import org.gradle.api.InvalidUserDataException;
1415
import org.gradle.api.Plugin;
1516
import org.gradle.api.Project;
@@ -59,7 +60,7 @@ public void apply(final Project project) {
5960
project.getPluginManager().apply("elasticsearch.publish");
6061
project.getPluginManager().apply(ElasticsearchJavadocPlugin.class);
6162
project.getPluginManager().apply(DependenciesInfoPlugin.class);
62-
project.getPluginManager().apply(DependenciesGraphPlugin.class);
63+
project.getPluginManager().apply(SnykDependencyMonitoringGradlePlugin.class);
6364
InternalPrecommitTasks.create(project, true);
6465
configureLicenseAndNotice(project);
6566
}

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DependenciesGraphPlugin.java

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)