Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into lucene_snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticsearchmachine committed Apr 26, 2024
2 parents c6b08d5 + d604621 commit 18361d7
Show file tree
Hide file tree
Showing 151 changed files with 3,661 additions and 961 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipelines/periodic-platform-support.yml
Expand Up @@ -52,7 +52,7 @@ steps:
agents:
provider: gcp
image: family/elasticsearch-{{matrix.image}}
machineType: n1-standard-32
machineType: n1-standard-16
diskType: pd-ssd
diskSizeGb: 350
env:
Expand Down
Expand Up @@ -8,23 +8,34 @@

package org.elasticsearch.gradle.internal.test;

import org.elasticsearch.gradle.internal.conventions.util.Util;
import org.elasticsearch.gradle.internal.info.BuildParams;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.file.RegularFile;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.testing.Test;

import java.io.File;
import java.util.Arrays;
import java.util.List;

public class MutedTestPlugin implements Plugin<Project> {
private static final String ADDITIONAL_FILES_PROPERTY = "org.elasticsearch.additional.muted.tests";

@Override
public void apply(Project project) {
File infoPath = new File(Util.locateElasticsearchWorkspace(project.getGradle()), "build-tools-internal");
String additionalFilePaths = project.hasProperty(ADDITIONAL_FILES_PROPERTY)
? project.property(ADDITIONAL_FILES_PROPERTY).toString()
: "";
List<RegularFile> additionalFiles = Arrays.stream(additionalFilePaths.split(","))
.filter(p -> p.isEmpty() == false)
.map(p -> project.getRootProject().getLayout().getProjectDirectory().file(p))
.toList();

Provider<MutedTestsBuildService> mutedTestsProvider = project.getGradle()
.getSharedServices()
.registerIfAbsent("mutedTests", MutedTestsBuildService.class, spec -> {
spec.getParameters().getInfoPath().set(infoPath);
spec.getParameters().getInfoPath().set(project.getRootProject().getProjectDir());
spec.getParameters().getAdditionalFiles().set(additionalFiles);
});

project.getTasks().withType(Test.class).configureEach(test -> {
Expand Down
Expand Up @@ -13,7 +13,9 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

import org.gradle.api.file.RegularFile;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.services.BuildService;
import org.gradle.api.services.BuildServiceParameters;

Expand All @@ -28,25 +30,34 @@
import java.util.List;

public abstract class MutedTestsBuildService implements BuildService<MutedTestsBuildService.Params> {
private final List<String> excludePatterns;
private final List<String> excludePatterns = new ArrayList<>();
private final ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());

public MutedTestsBuildService() {
File infoPath = getParameters().getInfoPath().get().getAsFile();
File mutedTestsFile = new File(infoPath, "muted-tests.yml");
try (InputStream is = new BufferedInputStream(new FileInputStream(mutedTestsFile))) {
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
List<MutedTest> mutedTests = objectMapper.readValue(is, MutedTests.class).getTests();
excludePatterns = buildExcludePatterns(mutedTests == null ? Collections.emptyList() : mutedTests);
} catch (IOException e) {
throw new UncheckedIOException(e);
excludePatterns.addAll(buildExcludePatterns(mutedTestsFile));
for (RegularFile regularFile : getParameters().getAdditionalFiles().get()) {
excludePatterns.addAll(buildExcludePatterns(regularFile.getAsFile()));
}
}

public List<String> getExcludePatterns() {
return excludePatterns;
}

private static List<String> buildExcludePatterns(List<MutedTest> mutedTests) {
private List<String> buildExcludePatterns(File file) {
List<MutedTest> mutedTests;

try (InputStream is = new BufferedInputStream(new FileInputStream(file))) {
mutedTests = objectMapper.readValue(is, MutedTests.class).getTests();
if (mutedTests == null) {
return Collections.emptyList();
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}

List<String> excludes = new ArrayList<>();
if (mutedTests.isEmpty() == false) {
for (MutedTestsBuildService.MutedTest mutedTest : mutedTests) {
Expand Down Expand Up @@ -84,6 +95,8 @@ private static List<String> buildExcludePatterns(List<MutedTest> mutedTests) {

public interface Params extends BuildServiceParameters {
RegularFileProperty getInfoPath();

ListProperty<RegularFile> getAdditionalFiles();
}

public static class MutedTest {
Expand Down
Expand Up @@ -59,7 +59,7 @@ abstract class AbstractGradleFuncTest extends Specification {
id 'base'
}
"""
def mutedTestsFile = Files.createFile(Path.of(testProjectDir.newFolder("build-tools-internal").path, "muted-tests.yml"))
def mutedTestsFile = testProjectDir.newFile("muted-tests.yml")
mutedTestsFile << """
tests: []
"""
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog/106253.yaml
@@ -0,0 +1,6 @@
pr: 106253
summary: Fix for from parameter when using `sub_searches` and rank
area: Ranking
type: bug
issues:
- 99011
5 changes: 5 additions & 0 deletions docs/changelog/107735.yaml
@@ -0,0 +1,5 @@
pr: 107735
summary: Implement synthetic source support for annotated text field
area: Mapping
type: feature
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/107792.yaml
@@ -0,0 +1,5 @@
pr: 107792
summary: Halt Indexer on Stop/Abort API
area: Transform
type: bug
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/107897.yaml
@@ -0,0 +1,5 @@
pr: 107897
summary: Optimise composite aggregations for single value fields
area: Aggregations
type: enhancement
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/107902.yaml
@@ -0,0 +1,5 @@
pr: 107902
summary: Update several references to `TransportVersion.toString` to use `toReleaseVersion`
area: Infra/Core
type: bug
issues: []

0 comments on commit 18361d7

Please sign in to comment.