Skip to content

Commit 55a39e9

Browse files
committed
Merge remote-tracking branch 'origin/snapshot-lifecycle-management' into slm-retention
2 parents d349af5 + aacd841 commit 55a39e9

File tree

1,406 files changed

+24261
-10740
lines changed

Some content is hidden

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

1,406 files changed

+24261
-10740
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ html_docs
4141
# random old stuff that we should look at the necessity of...
4242
/tmp/
4343
eclipse-build
44+
45+
# projects using testfixtures
46+
testfixtures_shared/

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ class BuildPlugin implements Plugin<Project> {
825825

826826
test.executable = "${ext.get('runtimeJavaHome')}/bin/java"
827827
test.workingDir = project.file("${project.buildDir}/testrun/${test.name}")
828-
test.maxParallelForks = project.rootProject.extensions.getByType(ExtraPropertiesExtension).get('defaultParallel') as Integer
828+
test.maxParallelForks = System.getProperty('tests.jvms', project.rootProject.extensions.extraProperties.get('defaultParallel').toString()) as Integer
829829

830830
test.exclude '**/*$*.class'
831831

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
353353

354354
private void testSetup(Snippet snippet) {
355355
if (lastDocsPath == snippet.path) {
356-
throw new InvalidUserDataException("$snippet: wasn't first")
356+
throw new InvalidUserDataException("$snippet: wasn't first. TESTSETUP can only be used in the first snippet of a document.")
357357
}
358358
setupCurrent(snippet)
359359
current.println('---')

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ import org.elasticsearch.gradle.tool.ClasspathUtils
2727
import org.gradle.api.JavaVersion
2828
import org.gradle.api.Project
2929
import org.gradle.api.Task
30+
import org.gradle.api.artifacts.Configuration
3031
import org.gradle.api.plugins.JavaBasePlugin
32+
import org.gradle.api.plugins.JavaPluginConvention
3133
import org.gradle.api.plugins.quality.Checkstyle
3234

3335
/**
@@ -45,13 +47,23 @@ class PrecommitTasks {
4547
forbiddenApisCliJar('de.thetaphi:forbiddenapis:2.6')
4648
}
4749

50+
Configuration jarHellConfig = project.configurations.create("jarHell")
51+
if (ClasspathUtils.isElasticsearchProject() && project.path.equals(":libs:elasticsearch-core") == false) {
52+
// External plugins will depend on this already via transitive dependencies.
53+
// Internal projects are not all plugins, so make sure the check is available
54+
// we are not doing this for this project itself to avoid jar hell with itself
55+
project.dependencies {
56+
jarHell project.project(":libs:elasticsearch-core")
57+
}
58+
}
59+
4860
List<Task> precommitTasks = [
4961
configureCheckstyle(project),
5062
configureForbiddenApisCli(project),
5163
project.tasks.create('forbiddenPatterns', ForbiddenPatternsTask.class),
5264
project.tasks.create('licenseHeaders', LicenseHeadersTask.class),
5365
project.tasks.create('filepermissions', FilePermissionsTask.class),
54-
configureJarHell(project),
66+
configureJarHell(project, jarHellConfig),
5567
configureThirdPartyAudit(project),
5668
configureTestingConventions(project)
5769
]
@@ -108,12 +120,13 @@ class PrecommitTasks {
108120
return task
109121
}
110122

111-
private static Task configureJarHell(Project project) {
123+
private static Task configureJarHell(Project project, Configuration jarHelConfig) {
112124
return project.tasks.create('jarHell', JarHellTask) { task ->
113-
task.classpath = project.sourceSets.test.runtimeClasspath
125+
task.classpath = project.sourceSets.test.runtimeClasspath + jarHelConfig;
114126
if (project.plugins.hasPlugin(ShadowPlugin)) {
115127
task.classpath += project.configurations.bundle
116128
}
129+
task.dependsOn(jarHelConfig);
117130
}
118131
}
119132

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/AntFixture.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public class AntFixture extends AntTask implements Fixture {
5858
@Input
5959
boolean useShell = false
6060

61+
@Input
62+
int maxWaitInSeconds = 30
63+
6164
/**
6265
* A flag to indicate whether the fixture should be run in the foreground, or spawned.
6366
* It is protected so subclasses can override (eg RunTask).
@@ -128,7 +131,7 @@ public class AntFixture extends AntTask implements Fixture {
128131

129132
String failedProp = "failed${name}"
130133
// first wait for resources, or the failure marker from the wrapper script
131-
ant.waitfor(maxwait: '30', maxwaitunit: 'second', checkevery: '500', checkeveryunit: 'millisecond', timeoutproperty: failedProp) {
134+
ant.waitfor(maxwait: maxWaitInSeconds, maxwaitunit: 'second', checkevery: '500', checkeveryunit: 'millisecond', timeoutproperty: failedProp) {
132135
or {
133136
resourceexists {
134137
file(file: failureMarker.toString())

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class RestIntegTestTask extends DefaultTask {
5959
Boolean includePackaged = false
6060

6161
RestIntegTestTask() {
62-
runner = project.tasks.create("${name}Runner", Test.class)
62+
runner = project.tasks.create("${name}Runner", RestTestRunnerTask.class)
6363
super.dependsOn(runner)
6464
clusterInit = project.tasks.create(name: "${name}Cluster#init", dependsOn: project.testClasses)
6565
runner.dependsOn(clusterInit)
@@ -77,10 +77,6 @@ class RestIntegTestTask extends DefaultTask {
7777
runner.useCluster project.testClusters."$name"
7878
}
7979

80-
// disable the build cache for rest test tasks
81-
// there are a number of inputs we aren't properly tracking here so we'll just not cache these for now
82-
runner.getOutputs().doNotCacheIf("Caching is disabled for REST integration tests", Specs.SATISFIES_ALL)
83-
8480
// override/add more for rest tests
8581
runner.maxParallelForks = 1
8682
runner.include('**/*IT.class')
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.elasticsearch.gradle;
2+
3+
import java.util.List;
4+
5+
public abstract class AbstractLazyPropertyCollection {
6+
7+
final String name;
8+
final Object owner;
9+
10+
public AbstractLazyPropertyCollection(String name) {
11+
this(name, null);
12+
}
13+
14+
public AbstractLazyPropertyCollection(String name, Object owner) {
15+
this.name = name;
16+
this.owner = owner;
17+
}
18+
19+
abstract List<? extends Object> getNormalizedCollection();
20+
21+
void assertNotNull(Object value, String description) {
22+
if (value == null) {
23+
throw new NullPointerException(name + " " + description + " was null" + (owner != null ? " when configuring " + owner : ""));
24+
}
25+
}
26+
27+
}
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
package org.elasticsearch.gradle;
2+
3+
import org.gradle.api.tasks.Input;
4+
import org.gradle.api.tasks.Nested;
5+
6+
import java.util.ArrayList;
7+
import java.util.Collection;
8+
import java.util.Iterator;
9+
import java.util.List;
10+
import java.util.ListIterator;
11+
import java.util.function.Supplier;
12+
import java.util.stream.Collectors;
13+
14+
public class LazyPropertyList<T> extends AbstractLazyPropertyCollection implements List<T> {
15+
16+
private final List<PropertyListEntry<T>> delegate = new ArrayList<>();
17+
18+
public LazyPropertyList(String name) {
19+
super(name);
20+
}
21+
22+
public LazyPropertyList(String name, Object owner) {
23+
super(name, owner);
24+
}
25+
26+
@Override
27+
public int size() {
28+
return delegate.size();
29+
}
30+
31+
@Override
32+
public boolean isEmpty() {
33+
return delegate.isEmpty();
34+
}
35+
36+
@Override
37+
public boolean contains(Object o) {
38+
return delegate.stream().anyMatch(entry -> entry.getValue().equals(o));
39+
}
40+
41+
@Override
42+
public Iterator<T> iterator() {
43+
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).iterator();
44+
}
45+
46+
@Override
47+
public Object[] toArray() {
48+
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).toArray();
49+
}
50+
51+
@Override
52+
public <T1> T1[] toArray(T1[] a) {
53+
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).collect(Collectors.toList()).toArray(a);
54+
}
55+
56+
@Override
57+
public boolean add(T t) {
58+
return delegate.add(new PropertyListEntry<>(() -> t, PropertyNormalization.DEFAULT));
59+
}
60+
61+
public boolean add(Supplier<T> supplier) {
62+
return delegate.add(new PropertyListEntry<>(supplier, PropertyNormalization.DEFAULT));
63+
}
64+
65+
public boolean add(Supplier<T> supplier, PropertyNormalization normalization) {
66+
return delegate.add(new PropertyListEntry<>(supplier, normalization));
67+
}
68+
69+
@Override
70+
public boolean remove(Object o) {
71+
throw new UnsupportedOperationException(this.getClass().getName() + " does not support remove()");
72+
}
73+
74+
@Override
75+
public boolean containsAll(Collection<?> c) {
76+
return delegate.stream().map(PropertyListEntry::getValue).collect(Collectors.toList()).containsAll(c);
77+
}
78+
79+
@Override
80+
public boolean addAll(Collection<? extends T> c) {
81+
c.forEach(this::add);
82+
return true;
83+
}
84+
85+
@Override
86+
public boolean addAll(int index, Collection<? extends T> c) {
87+
int i = index;
88+
for (T item : c) {
89+
this.add(i++, item);
90+
}
91+
return true;
92+
}
93+
94+
@Override
95+
public boolean removeAll(Collection<?> c) {
96+
throw new UnsupportedOperationException(this.getClass().getName() + " does not support removeAll()");
97+
}
98+
99+
@Override
100+
public boolean retainAll(Collection<?> c) {
101+
throw new UnsupportedOperationException(this.getClass().getName() + " does not support retainAll()");
102+
}
103+
104+
@Override
105+
public void clear() {
106+
delegate.clear();
107+
}
108+
109+
@Override
110+
public T get(int index) {
111+
PropertyListEntry<T> entry = delegate.get(index);
112+
validate(entry);
113+
return entry.getValue();
114+
}
115+
116+
@Override
117+
public T set(int index, T element) {
118+
return delegate.set(index, new PropertyListEntry<>(() -> element, PropertyNormalization.DEFAULT)).getValue();
119+
}
120+
121+
@Override
122+
public void add(int index, T element) {
123+
delegate.add(index, new PropertyListEntry<>(() -> element, PropertyNormalization.DEFAULT));
124+
}
125+
126+
@Override
127+
public T remove(int index) {
128+
return delegate.remove(index).getValue();
129+
}
130+
131+
@Override
132+
public int indexOf(Object o) {
133+
for (int i = 0; i < delegate.size(); i++) {
134+
if (delegate.get(i).getValue().equals(o)) {
135+
return i;
136+
}
137+
}
138+
139+
return -1;
140+
}
141+
142+
@Override
143+
public int lastIndexOf(Object o) {
144+
int lastIndex = -1;
145+
for (int i = 0; i < delegate.size(); i++) {
146+
if (delegate.get(i).getValue().equals(o)) {
147+
lastIndex = i;
148+
}
149+
}
150+
151+
return lastIndex;
152+
}
153+
154+
@Override
155+
public ListIterator<T> listIterator() {
156+
return delegate.stream().map(PropertyListEntry::getValue).collect(Collectors.toList()).listIterator();
157+
}
158+
159+
@Override
160+
public ListIterator<T> listIterator(int index) {
161+
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).collect(Collectors.toList()).listIterator(index);
162+
}
163+
164+
@Override
165+
public List<T> subList(int fromIndex, int toIndex) {
166+
return delegate.stream()
167+
.peek(this::validate)
168+
.map(PropertyListEntry::getValue)
169+
.collect(Collectors.toList())
170+
.subList(fromIndex, toIndex);
171+
}
172+
173+
@Override
174+
@Nested
175+
List<? extends Object> getNormalizedCollection() {
176+
return delegate.stream()
177+
.peek(this::validate)
178+
.filter(entry -> entry.getNormalization() != PropertyNormalization.IGNORE_VALUE)
179+
.collect(Collectors.toList());
180+
}
181+
182+
private void validate(PropertyListEntry<T> entry) {
183+
assertNotNull(entry.getValue(), "entry");
184+
}
185+
186+
private class PropertyListEntry<T> {
187+
private final Supplier<T> supplier;
188+
private final PropertyNormalization normalization;
189+
190+
PropertyListEntry(Supplier<T> supplier, PropertyNormalization normalization) {
191+
this.supplier = supplier;
192+
this.normalization = normalization;
193+
}
194+
195+
public PropertyNormalization getNormalization() {
196+
return normalization;
197+
}
198+
199+
@Input
200+
public T getValue() {
201+
assertNotNull(supplier, "supplier");
202+
return supplier.get();
203+
}
204+
}
205+
}

0 commit comments

Comments
 (0)