Skip to content

Commit 4e7b3c1

Browse files
author
David Roberts
committed
Merge branch 'master' into add_memory_override
2 parents b4c646c + 0f9848e commit 4e7b3c1

File tree

434 files changed

+8124
-7171
lines changed

Some content is hidden

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

434 files changed

+8124
-7171
lines changed

BUILDING.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,99 @@ dependencies {
135135
}
136136
}
137137
```
138+
139+
## FAQ
140+
141+
### How do I test a development version of a third party dependency?
142+
143+
To test an unreleased development version of a third party dependency you have several options.
144+
145+
#### How to use a maven based third party dependency via mavenlocal?
146+
147+
1. Clone the third party repository locally
148+
2. Run `mvn install` to install copy into your `~/.m2/repository` folder.
149+
3. Add this to the root build script:
150+
151+
```
152+
allprojects {
153+
repositories {
154+
mavenLocal()
155+
}
156+
}
157+
```
158+
4. Update the version in your dependency declaration accordingly (likely a snapshot version)
159+
5. Run the gradle build as needed
160+
161+
#### How to use a maven built based third party dependency with jitpack repository?
162+
163+
https://jitpack.io is an adhoc repository that supports building maven projects transparently in the background when
164+
resolving unreleased snapshots from a github repository. This approach also works as temporally solution
165+
and is compliant with our CI builds.
166+
167+
1. Add the JitPack repository to the root build file:
168+
169+
```
170+
allprojects {
171+
repositories {
172+
maven { url "https://jitpack.io" }
173+
}
174+
}
175+
```
176+
2. Add the dependency in the following format
177+
```
178+
dependencies {
179+
implementation 'com.github.User:Repo:Tag'
180+
}
181+
```
182+
183+
As version you could also use a certain short commit hash or `master-SNAPSHOT`.
184+
In addition to snapshot builds JitPack supports building Pull Requests. Simply use PR<NR>-SNAPSHOT as the version.
185+
186+
3. Run the gradle build as needed. Keep in mind the initial resolution might take a bit longer as this needs to be built
187+
by JitPack in the background before we can resolve the adhoc built dependency.
188+
189+
---
190+
191+
**NOTE**
192+
193+
You should only use that approach locally or on a developer branch for for production dependencies as we do
194+
not want to ship unreleased libraries into our releases.
195+
---
196+
197+
#### How to use a custom third party artifact?
198+
199+
For third party libraries that are not built with maven (e.g. ant) or provided as a plain jar artifact we can leverage
200+
a flat directory repository that resolves artifacts from a flat directory on your filesystem.
201+
202+
1. Put the jar artifact with the format `artifactName-version.jar` into a directory named `localRepo` (you have to create this manually)
203+
2. Declare a flatDir repository in your root build.gradle file
204+
205+
```
206+
allprojects {
207+
repositories {
208+
flatDir {
209+
dirs 'localRepo'
210+
}
211+
}
212+
}
213+
```
214+
215+
3. Update the dependency declaration of the artifact in question to match the custom build version. For a file named e.g. `jmxri-1.2.1.jar` the
216+
dependency definition would be `:jmxri:1.2.1` as it comes with no group information:
217+
218+
```
219+
dependencies {
220+
implementation ':jmxri:1.2.1'
221+
}
222+
```
223+
4. Run the gradle build as needed.
224+
225+
---
226+
**NOTE**
227+
228+
As Gradle prefers to use modules whose descriptor has been created from real meta-data rather than being generated,
229+
flat directory repositories cannot be used to override artifacts with real meta-data from other repositories declared in the build.
230+
For example, if Gradle finds only `jmxri-1.2.1.jar` in a flat directory repository, but `jmxri-1.2.1.pom` in another repository
231+
that supports meta-data, it will use the second repository to provide the module.
232+
Therefore it is recommended to declare a version that is not resolveable from public repositories we use (e.g. maven central)
233+
---

benchmarks/src/main/java/org/elasticsearch/benchmark/time/DateFormatterBenchmark.java

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

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.io.File;
2323
import java.io.IOException;
2424
import java.util.Properties;
25-
import java.util.function.Function;
2625

2726
abstract class VersionPropertiesBuildService implements BuildService<VersionPropertiesBuildService.Params>, AutoCloseable {
2827

@@ -42,7 +41,7 @@ public VersionPropertiesBuildService(ProviderFactory providerFactory) {
4241

4342
private JavaVersion resolveMinimumJavaVersion(File infoPath) {
4443
final JavaVersion minimumJavaVersion;
45-
File minimumJavaInfoSource = new File(infoPath, "src/main/resources/minimumCompilerVersion");
44+
File minimumJavaInfoSource = new File(infoPath, "src/main/resources/minimumRuntimeVersion");
4645
try {
4746
String versionString = FileUtils.readFileToString(minimumJavaInfoSource);
4847
minimumJavaVersion = JavaVersion.toVersion(versionString);

build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/YamlRestCompatTestPluginFuncTest.groovy

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest {
8282
String wrongTest = "wrong_version.yml"
8383
String additionalTest = "additional_test.yml"
8484
setupRestResources([wrongApi], [wrongTest]) //setups up resources for current version, which should not be used for this test
85-
addRestTestsToProject([additionalTest], "yamlRestCompatTest")
85+
String sourceSetName = "yamlRestTestV" + compatibleVersion + "Compat"
86+
addRestTestsToProject([additionalTest], sourceSetName)
8687
//intentionally adding to yamlRestTest source set since the .classes are copied from there
8788
file("src/yamlRestTest/java/MockIT.java") << "import org.junit.Test;class MockIT { @Test public void doNothing() { }}"
8889

@@ -107,17 +108,17 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest {
107108
file("/build/${testIntermediateDir}/original/rest-api-spec/test/" + test).exists()
108109
file("/build/${testIntermediateDir}/transformed/rest-api-spec/test/" + test).exists()
109110
file("/build/${testIntermediateDir}/transformed/rest-api-spec/test/" + test).text.contains("headers") //transformation adds this
110-
file("/build/resources/yamlRestCompatTest/rest-api-spec/test/" + additionalTest).exists()
111+
file("/build/resources/${sourceSetName}/rest-api-spec/test/" + additionalTest).exists()
111112

112113
//additionalTest is not copied from the prior version, and thus not in the intermediate directory, nor transformed
113-
file("/build/resources/yamlRestCompatTest/" + testIntermediateDir + "/rest-api-spec/test/" + additionalTest).exists() == false
114-
file("/build/resources/yamlRestCompatTest/rest-api-spec/test/" + additionalTest).text.contains("headers") == false
114+
file("/build/resources/${sourceSetName}/" + testIntermediateDir + "/rest-api-spec/test/" + additionalTest).exists() == false
115+
file("/build/resources/${sourceSetName}/rest-api-spec/test/" + additionalTest).text.contains("headers") == false
115116

116117
file("/build/classes/java/yamlRestTest/MockIT.class").exists() //The "standard" runner is used to execute the compat test
117118

118-
file("/build/resources/yamlRestCompatTest/rest-api-spec/api/" + wrongApi).exists() == false
119-
file("/build/resources/yamlRestCompatTest/" + testIntermediateDir + "/rest-api-spec/test/" + wrongTest).exists() == false
120-
file("/build/resources/yamlRestCompatTest/rest-api-spec/test/" + wrongTest).exists() == false
119+
file("/build/resources/${sourceSetName}/rest-api-spec/api/" + wrongApi).exists() == false
120+
file("/build/resources/${sourceSetName}/" + testIntermediateDir + "/rest-api-spec/test/" + wrongTest).exists() == false
121+
file("/build/resources/${sourceSetName}/rest-api-spec/test/" + wrongTest).exists() == false
121122

122123
result.task(':copyRestApiSpecsTask').outcome == TaskOutcome.NO_SOURCE
123124
result.task(':copyYamlTestsTask').outcome == TaskOutcome.NO_SOURCE

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/rest/compat/YamlRestCompatTestPlugin.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88

99
package org.elasticsearch.gradle.internal.rest.compat;
1010

11-
import org.elasticsearch.gradle.internal.ElasticsearchJavaBasePlugin;
1211
import org.elasticsearch.gradle.Version;
1312
import org.elasticsearch.gradle.VersionProperties;
13+
import org.elasticsearch.gradle.internal.ElasticsearchJavaBasePlugin;
1414
import org.elasticsearch.gradle.internal.test.RestIntegTestTask;
1515
import org.elasticsearch.gradle.internal.test.RestTestBasePlugin;
1616
import org.elasticsearch.gradle.internal.test.rest.CopyRestApiTask;
1717
import org.elasticsearch.gradle.internal.test.rest.CopyRestTestsTask;
18+
import org.elasticsearch.gradle.internal.test.rest.InternalYamlRestTestPlugin;
1819
import org.elasticsearch.gradle.internal.test.rest.RestResourcesExtension;
1920
import org.elasticsearch.gradle.internal.test.rest.RestResourcesPlugin;
2021
import org.elasticsearch.gradle.internal.test.rest.RestTestUtil;
21-
import org.elasticsearch.gradle.internal.test.rest.InternalYamlRestTestPlugin;
2222
import org.elasticsearch.gradle.testclusters.TestClustersPlugin;
2323
import org.elasticsearch.gradle.util.GradleUtils;
2424
import org.gradle.api.Plugin;
@@ -46,21 +46,22 @@
4646
* Apply this plugin to run the YAML based REST tests from a prior major version against this version's cluster.
4747
*/
4848
public class YamlRestCompatTestPlugin implements Plugin<Project> {
49+
public static final String BWC_MINOR_CONFIG_NAME = "bwcMinor";
4950
private static final String REST_COMPAT_CHECK_TASK_NAME = "checkRestCompat";
5051
private static final String COMPATIBILITY_APIS_CONFIGURATION = "restCompatSpecs";
5152
private static final String COMPATIBILITY_TESTS_CONFIGURATION = "restCompatTests";
52-
private static final String SOURCE_SET_NAME = "yamlRestCompatTest";
5353
private static final Path RELATIVE_API_PATH = Path.of("rest-api-spec/api");
5454
private static final Path RELATIVE_TEST_PATH = Path.of("rest-api-spec/test");
5555
private static final Path RELATIVE_REST_API_RESOURCES = Path.of("rest-api-spec/src/main/resources");
5656
private static final Path RELATIVE_REST_XPACK_RESOURCES = Path.of("x-pack/plugin/src/test/resources");
5757
private static final Path RELATIVE_REST_PROJECT_RESOURCES = Path.of("src/yamlRestTest/resources");
58-
public static final String BWC_MINOR_CONFIG_NAME = "bwcMinor";
58+
private static final int COMPATIBLE_VERSION = Version.fromString(VersionProperties.getVersions().get("elasticsearch")).getMajor() - 1;
59+
private static final String SOURCE_SET_NAME = "yamlRestTestV" + COMPATIBLE_VERSION + "Compat";
5960

6061
@Override
6162
public void apply(Project project) {
62-
final int compatibleVersion = Version.fromString(VersionProperties.getVersions().get("elasticsearch")).getMajor() - 1;
63-
final Path compatRestResourcesDir = Path.of("restResources").resolve("v" + compatibleVersion);
63+
64+
final Path compatRestResourcesDir = Path.of("restResources").resolve("v" + COMPATIBLE_VERSION);
6465
final Path compatSpecsDir = compatRestResourcesDir.resolve("yamlSpecs");
6566
final Path compatTestsDir = compatRestResourcesDir.resolve("yamlTests");
6667

@@ -160,7 +161,7 @@ public void apply(Project project) {
160161

161162
// transform the copied tests task
162163
TaskProvider<RestCompatTestTransformTask> transformCompatTestTask = project.getTasks()
163-
.register("yamlRestTestV" + compatibleVersion + "CompatTransform", RestCompatTestTransformTask.class, task -> {
164+
.register("yamlRestTestV" + COMPATIBLE_VERSION + "CompatTransform", RestCompatTestTransformTask.class, task -> {
164165
task.getSourceDirectory().set(copyCompatYamlTestTask.flatMap(CopyRestTestsTask::getOutputResourceDir));
165166
task.getOutputDirectory()
166167
.set(project.getLayout().getBuildDirectory().dir(compatTestsDir.resolve("transformed").toString()));
@@ -191,7 +192,7 @@ public void apply(Project project) {
191192
.named(RestResourcesPlugin.COPY_YAML_TESTS_TASK)
192193
.flatMap(CopyRestTestsTask::getOutputResourceDir);
193194

194-
String testTaskName = "yamlRestTestV" + compatibleVersion + "CompatTest";
195+
String testTaskName = "yamlRestTestV" + COMPATIBLE_VERSION + "CompatTest";
195196

196197
// setup the test task
197198
Provider<RestIntegTestTask> yamlRestCompatTestTask = RestTestUtil.registerTestTask(project, yamlCompatTestSourceSet, testTaskName);
@@ -207,11 +208,13 @@ public void apply(Project project) {
207208
.minus(project.files(originalYamlSpecsDir))
208209
.minus(project.files(originalYamlTestsDir))
209210
);
211+
210212
// run compatibility tests after "normal" tests
211213
testTask.mustRunAfter(project.getTasks().named(InternalYamlRestTestPlugin.SOURCE_SET_NAME));
212214
testTask.onlyIf(t -> isEnabled(project));
213215
});
214216

217+
215218
setupTestDependenciesDefaults(project, yamlCompatTestSourceSet);
216219

217220
// setup IDE

build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchCluster.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,12 @@ private void commonNodeConfig() {
321321
for (ElasticsearchNode node : nodes) {
322322
if (node.getTestDistribution().equals(TestDistribution.INTEG_TEST)) {
323323
node.defaultConfig.put("xpack.security.enabled", "false");
324+
} else {
325+
if (node.getVersion().onOrAfter("8.0.0")) {
326+
node.defaultConfig.put("cluster.deprecation_indexing.enabled", "false");
327+
}
324328
}
329+
325330
// Can only configure master nodes if we have node names defined
326331
if (nodeNames != null) {
327332
if (node.getVersion().onOrAfter("7.0.0")) {

build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public class ElasticsearchNode implements TestClusterConfiguration {
103103
private static final TimeUnit ADDITIONAL_CONFIG_TIMEOUT_UNIT = TimeUnit.SECONDS;
104104
private static final List<String> OVERRIDABLE_SETTINGS = Arrays.asList(
105105
"path.repo",
106-
"discovery.seed_providers"
106+
"discovery.seed_providers",
107+
"cluster.deprecation_indexing.enabled"
107108

108109
);
109110

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ tasks.register("verifyVersions") {
134134
* after the backport of the backcompat code is complete.
135135
*/
136136

137-
boolean bwc_tests_enabled = false
137+
boolean bwc_tests_enabled = true
138138
// place a PR link here when committing bwc changes:
139-
String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/77552"
139+
String bwc_tests_disabled_issue = ""
140140
/*
141141
* FIPS 140-2 behavior was fixed in 7.11.0. Before that there is no way to run elasticsearch in a
142142
* JVM that is properly configured to be in fips mode with BCFIPS. For now we need to disable
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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.client.transform;
10+
11+
import org.elasticsearch.client.Validatable;
12+
13+
import java.util.Objects;
14+
15+
public class UpgradeTransformsRequest implements Validatable {
16+
17+
private Boolean dryRun;
18+
19+
public UpgradeTransformsRequest() {}
20+
21+
public Boolean isDryRun() {
22+
return dryRun;
23+
}
24+
25+
/**
26+
* Whether to only check for an upgrade without taking action
27+
*
28+
* @param dryRun {@code true} will only check for upgrades
29+
*/
30+
public void setDryRun(boolean dryRun) {
31+
this.dryRun = dryRun;
32+
}
33+
34+
@Override
35+
public int hashCode() {
36+
return Objects.hash(dryRun);
37+
}
38+
39+
@Override
40+
public boolean equals(Object obj) {
41+
if (obj == null) {
42+
return false;
43+
}
44+
if (getClass() != obj.getClass()) {
45+
return false;
46+
}
47+
UpgradeTransformsRequest other = (UpgradeTransformsRequest) obj;
48+
return Objects.equals(dryRun, other.dryRun);
49+
}
50+
51+
}

0 commit comments

Comments
 (0)