-
Notifications
You must be signed in to change notification settings - Fork 25.4k
Enable caching of rest tests which use integ-test distribution #43782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3fb5468
Enable caching of rest tests which use integ-test distribution
mark-vieira f5f4ecf
Don't explicit track plugins and modules since they are part of the c…
mark-vieira 1c92f5f
Ensure we use relative path sensitivity for test cluster distribution
mark-vieira cb82aa9
Address PR feedback
mark-vieira def871f
Properly handle snapshotting installed plugins and modules
mark-vieira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
buildSrc/src/main/java/org/elasticsearch/gradle/AbstractLazyPropertyCollection.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.elasticsearch.gradle; | ||
|
||
import java.util.List; | ||
|
||
public abstract class AbstractLazyPropertyCollection { | ||
|
||
final String name; | ||
final Object owner; | ||
|
||
public AbstractLazyPropertyCollection(String name) { | ||
this(name, null); | ||
} | ||
|
||
public AbstractLazyPropertyCollection(String name, Object owner) { | ||
this.name = name; | ||
this.owner = owner; | ||
} | ||
|
||
abstract List<? extends Object> getNormalizedCollection(); | ||
|
||
void assertNotNull(Object value, String description) { | ||
if (value == null) { | ||
throw new NullPointerException(name + " " + description + " was null" + (owner != null ? " when configuring " + owner : "")); | ||
} | ||
} | ||
|
||
} |
205 changes: 205 additions & 0 deletions
205
buildSrc/src/main/java/org/elasticsearch/gradle/LazyPropertyList.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
package org.elasticsearch.gradle; | ||
|
||
import org.gradle.api.tasks.Input; | ||
import org.gradle.api.tasks.Nested; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.ListIterator; | ||
import java.util.function.Supplier; | ||
import java.util.stream.Collectors; | ||
|
||
public class LazyPropertyList<T> extends AbstractLazyPropertyCollection implements List<T> { | ||
|
||
private final List<PropertyListEntry<T>> delegate = new ArrayList<>(); | ||
|
||
public LazyPropertyList(String name) { | ||
super(name); | ||
} | ||
|
||
public LazyPropertyList(String name, Object owner) { | ||
super(name, owner); | ||
} | ||
|
||
@Override | ||
public int size() { | ||
return delegate.size(); | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return delegate.isEmpty(); | ||
} | ||
|
||
@Override | ||
public boolean contains(Object o) { | ||
return delegate.stream().anyMatch(entry -> entry.getValue().equals(o)); | ||
} | ||
|
||
@Override | ||
public Iterator<T> iterator() { | ||
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).iterator(); | ||
} | ||
|
||
@Override | ||
public Object[] toArray() { | ||
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).toArray(); | ||
} | ||
|
||
@Override | ||
public <T1> T1[] toArray(T1[] a) { | ||
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).collect(Collectors.toList()).toArray(a); | ||
} | ||
|
||
@Override | ||
public boolean add(T t) { | ||
return delegate.add(new PropertyListEntry<>(() -> t, PropertyNormalization.DEFAULT)); | ||
} | ||
|
||
public boolean add(Supplier<T> supplier) { | ||
return delegate.add(new PropertyListEntry<>(supplier, PropertyNormalization.DEFAULT)); | ||
} | ||
|
||
public boolean add(Supplier<T> supplier, PropertyNormalization normalization) { | ||
return delegate.add(new PropertyListEntry<>(supplier, normalization)); | ||
} | ||
|
||
@Override | ||
public boolean remove(Object o) { | ||
throw new UnsupportedOperationException(this.getClass().getName() + " does not support remove()"); | ||
} | ||
|
||
@Override | ||
public boolean containsAll(Collection<?> c) { | ||
return delegate.stream().map(PropertyListEntry::getValue).collect(Collectors.toList()).containsAll(c); | ||
} | ||
|
||
@Override | ||
public boolean addAll(Collection<? extends T> c) { | ||
c.forEach(this::add); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean addAll(int index, Collection<? extends T> c) { | ||
int i = index; | ||
for (T item : c) { | ||
this.add(i++, item); | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean removeAll(Collection<?> c) { | ||
throw new UnsupportedOperationException(this.getClass().getName() + " does not support removeAll()"); | ||
} | ||
|
||
@Override | ||
public boolean retainAll(Collection<?> c) { | ||
throw new UnsupportedOperationException(this.getClass().getName() + " does not support retainAll()"); | ||
} | ||
|
||
@Override | ||
public void clear() { | ||
delegate.clear(); | ||
} | ||
|
||
@Override | ||
public T get(int index) { | ||
PropertyListEntry<T> entry = delegate.get(index); | ||
validate(entry); | ||
return entry.getValue(); | ||
} | ||
|
||
@Override | ||
public T set(int index, T element) { | ||
return delegate.set(index, new PropertyListEntry<>(() -> element, PropertyNormalization.DEFAULT)).getValue(); | ||
} | ||
|
||
@Override | ||
public void add(int index, T element) { | ||
delegate.add(index, new PropertyListEntry<>(() -> element, PropertyNormalization.DEFAULT)); | ||
} | ||
|
||
@Override | ||
public T remove(int index) { | ||
return delegate.remove(index).getValue(); | ||
} | ||
|
||
@Override | ||
public int indexOf(Object o) { | ||
for (int i = 0; i < delegate.size(); i++) { | ||
if (delegate.get(i).getValue().equals(o)) { | ||
return i; | ||
} | ||
} | ||
|
||
return -1; | ||
} | ||
|
||
@Override | ||
public int lastIndexOf(Object o) { | ||
int lastIndex = -1; | ||
for (int i = 0; i < delegate.size(); i++) { | ||
if (delegate.get(i).getValue().equals(o)) { | ||
lastIndex = i; | ||
} | ||
} | ||
|
||
return lastIndex; | ||
} | ||
|
||
@Override | ||
public ListIterator<T> listIterator() { | ||
return delegate.stream().map(PropertyListEntry::getValue).collect(Collectors.toList()).listIterator(); | ||
} | ||
|
||
@Override | ||
public ListIterator<T> listIterator(int index) { | ||
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).collect(Collectors.toList()).listIterator(index); | ||
} | ||
|
||
@Override | ||
public List<T> subList(int fromIndex, int toIndex) { | ||
return delegate.stream() | ||
.peek(this::validate) | ||
.map(PropertyListEntry::getValue) | ||
.collect(Collectors.toList()) | ||
.subList(fromIndex, toIndex); | ||
} | ||
|
||
@Override | ||
@Nested | ||
List<? extends Object> getNormalizedCollection() { | ||
return delegate.stream() | ||
.peek(this::validate) | ||
.filter(entry -> entry.getNormalization() != PropertyNormalization.IGNORE_VALUE) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
private void validate(PropertyListEntry<T> entry) { | ||
assertNotNull(entry.getValue(), "entry"); | ||
} | ||
|
||
private class PropertyListEntry<T> { | ||
private final Supplier<T> supplier; | ||
private final PropertyNormalization normalization; | ||
|
||
PropertyListEntry(Supplier<T> supplier, PropertyNormalization normalization) { | ||
this.supplier = supplier; | ||
this.normalization = normalization; | ||
} | ||
|
||
public PropertyNormalization getNormalization() { | ||
return normalization; | ||
} | ||
|
||
@Input | ||
public T getValue() { | ||
assertNotNull(supplier, "supplier"); | ||
return supplier.get(); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be wrong, but it looks like we could use generics instead of
Objects
here ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean for
getNormalizedCollection()
? If so we cannot because implementations might map the value type to any other type for the purposes of input snapshotting. Since this is only used by Gradle for input snapshotting, we only really care about the type at runtime.