Skip to content

Commit 00089cc

Browse files
committed
Merge branch 'upstream/master' into rollup-support-cancel
* upstream/master: (38 commits) Simplify map copying (elastic#88432) Make DiffableUtils.diff implementation agnostic (elastic#88403) Ingest: Start separating Metadata from IngestSourceAndMetadata (elastic#88401) Move runtime fields base scripts out of scripting fields api package. (elastic#88488) Enable TRACE Logging for test and increase timeout (elastic#88477) Mute ReactiveStorageIT#testScaleDuringSplitOrClone (elastic#88480) Track the count of failed invocations since last successful policy snapshot (elastic#88398) Avoid noisy exceptions on data nodes when aborting snapshots (elastic#88476) Fix ReactiveStorageDeciderServiceTests testNodeSizeForDataBelowLowWatermark (elastic#88452) INFO logging of snapshot restore and completion (elastic#88257) unmute test (elastic#88454) Updatable API keys - noop check (elastic#88346) Corrected an incomplete sentence. (elastic#86542) Use consistent shard map type in IndexService (elastic#88465) Stop registering TestGeoShapeFieldMapperPlugin in ESIntegTestCase (elastic#88460) TSDB: RollupShardIndexer logging improvements (elastic#88416) Audit API key ID when create or grant API keys (elastic#88456) Bound random negative size test in SearchSourceBuilderTests#testNegativeSizeErrors (elastic#88457) Updatable API keys - logging audit trail event (elastic#88276) Polish reworked LoggedExec task (elastic#88424) ... # Conflicts: # x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/v2/RollupShardIndexer.java
2 parents d02067d + 0768557 commit 00089cc

File tree

188 files changed

+3026
-1620
lines changed

Some content is hidden

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

188 files changed

+3026
-1620
lines changed

build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/InternalBwcGitPluginFuncTest.groovy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import org.gradle.testkit.runner.TaskOutcome
1414
class InternalBwcGitPluginFuncTest extends AbstractGitAwareGradleFuncTest {
1515

1616
def setup() {
17-
// using LoggedExec is not cc compatible
18-
configurationCacheCompatible = false
1917
internalBuild()
2018
buildFile << """
2119
import org.elasticsearch.gradle.Version;

build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPluginFuncTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ import spock.lang.Unroll
1717
/*
1818
* Test is ignored on ARM since this test case tests the ability to build certain older BWC branches that we don't support on ARM
1919
*/
20-
2120
@IgnoreIf({ Architecture.current() == Architecture.AARCH64 })
2221
class InternalDistributionBwcSetupPluginFuncTest extends AbstractGitAwareGradleFuncTest {
2322

2423
def setup() {
25-
// used LoggedExec task is not configuration cache compatible and
24+
// Cannot serialize BwcSetupExtension containing project object
2625
configurationCacheCompatible = false
2726
internalBuild()
2827
buildFile << """
@@ -119,4 +118,5 @@ class InternalDistributionBwcSetupPluginFuncTest extends AbstractGitAwareGradleF
119118
result.output.contains("nested folder /distribution/bwc/minor/build/bwc/checkout-8.0/" +
120119
"distribution/archives/darwin-tar/build/install/elasticsearch-8.0.0-SNAPSHOT")
121120
}
121+
122122
}

build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/AntFixtureStop.groovy

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,20 @@ import org.apache.tools.ant.taskdefs.condition.Os
1212
import org.elasticsearch.gradle.LoggedExec
1313
import org.elasticsearch.gradle.internal.test.AntFixture
1414
import org.gradle.api.file.FileSystemOperations
15+
import org.gradle.api.file.ProjectLayout
1516
import org.gradle.api.tasks.Internal
17+
import org.gradle.process.ExecOperations
1618

1719
import javax.inject.Inject
1820

19-
class AntFixtureStop extends LoggedExec implements FixtureStop {
21+
abstract class AntFixtureStop extends LoggedExec implements FixtureStop {
2022

2123
@Internal
2224
AntFixture fixture
2325

24-
@Internal
25-
FileSystemOperations fileSystemOperations
26-
2726
@Inject
28-
AntFixtureStop(FileSystemOperations fileSystemOperations) {
29-
super(fileSystemOperations)
30-
this.fileSystemOperations = fileSystemOperations
27+
AntFixtureStop(ProjectLayout projectLayout, ExecOperations execOperations, FileSystemOperations fileSystemOperations) {
28+
super(projectLayout, execOperations, fileSystemOperations)
3129
}
3230

3331
void setFixture(AntFixture fixture) {
@@ -40,10 +38,10 @@ class AntFixtureStop extends LoggedExec implements FixtureStop {
4038
}
4139

4240
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
43-
executable = 'Taskkill'
41+
getExecutable().set('Taskkill')
4442
args('/PID', pid, '/F')
4543
} else {
46-
executable = 'kill'
44+
getExecutable().set('kill')
4745
args('-9', pid)
4846
}
4947
doLast {

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

Lines changed: 11 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@
1515
import org.gradle.api.Action;
1616
import org.gradle.api.GradleException;
1717
import org.gradle.api.Project;
18-
import org.gradle.api.Task;
1918
import org.gradle.api.logging.LogLevel;
2019
import org.gradle.api.provider.Provider;
2120
import org.gradle.api.tasks.TaskProvider;
2221

2322
import java.io.File;
2423
import java.io.IOException;
25-
import java.io.OutputStream;
26-
import java.nio.charset.StandardCharsets;
2724
import java.util.Arrays;
2825
import java.util.List;
2926
import java.util.Locale;
@@ -64,26 +61,21 @@ private TaskProvider<LoggedExec> createRunBwcGradleTask(Project project, String
6461
return project.getTasks().register(name, LoggedExec.class, loggedExec -> {
6562
loggedExec.dependsOn("checkoutBwcBranch");
6663
loggedExec.usesService(bwcTaskThrottleProvider);
67-
loggedExec.setSpoolOutput(true);
68-
loggedExec.setWorkingDir(checkoutDir.get());
69-
loggedExec.doFirst(new Action<Task>() {
70-
@Override
71-
public void execute(Task t) {
72-
// Execution time so that the checkouts are available
73-
String compilerVersionInfoPath = minimumCompilerVersionPath(unreleasedVersionInfo.get().version());
74-
String minimumCompilerVersion = readFromFile(new File(checkoutDir.get(), compilerVersionInfoPath));
75-
loggedExec.environment("JAVA_HOME", getJavaHome(Integer.parseInt(minimumCompilerVersion)));
76-
}
77-
});
64+
loggedExec.getWorkingDir().set(checkoutDir.get());
65+
66+
loggedExec.getEnvironment().put("JAVA_HOME", unreleasedVersionInfo.zip(checkoutDir, (version, checkoutDir) -> {
67+
String minimumCompilerVersion = readFromFile(new File(checkoutDir, minimumCompilerVersionPath(version.version())));
68+
return getJavaHome(Integer.parseInt(minimumCompilerVersion));
69+
}));
7870

7971
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
80-
loggedExec.executable("cmd");
72+
loggedExec.getExecutable().set("cmd");
8173
loggedExec.args("/C", "call", new File(checkoutDir.get(), "gradlew").toString());
8274
} else {
83-
loggedExec.executable(new File(checkoutDir.get(), "gradlew").toString());
75+
loggedExec.getExecutable().set(new File(checkoutDir.get(), "gradlew").toString());
8476
}
8577

86-
loggedExec.args("-g", project.getGradle().getGradleUserHomeDir());
78+
loggedExec.args("-g", project.getGradle().getGradleUserHomeDir().toString());
8779
if (project.getGradle().getStartParameter().isOffline()) {
8880
loggedExec.args("--offline");
8981
}
@@ -93,8 +85,7 @@ public void execute(Task t) {
9385
loggedExec.args("-Dorg.elasticsearch.build.cache.url=" + buildCacheUrl);
9486
}
9587

96-
loggedExec.args("-Dbuild.snapshot=true");
97-
loggedExec.args("-Dscan.tag.NESTED");
88+
loggedExec.args("-Dbuild.snapshot=true", "-Dscan.tag.NESTED");
9889
final LogLevel logLevel = project.getGradle().getStartParameter().getLogLevel();
9990
List<LogLevel> nonDefaultLogLevels = Arrays.asList(LogLevel.QUIET, LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG);
10091
if (nonDefaultLogLevels.contains(logLevel)) {
@@ -110,8 +101,7 @@ public void execute(Task t) {
110101
if (project.getGradle().getStartParameter().isParallelProjectExecutionEnabled()) {
111102
loggedExec.args("--parallel");
112103
}
113-
loggedExec.setStandardOutput(new IndentingOutputStream(System.out, unreleasedVersionInfo.get().version()));
114-
loggedExec.setErrorOutput(new IndentingOutputStream(System.err, unreleasedVersionInfo.get().version()));
104+
loggedExec.getIndentingConsoleOutput().set(unreleasedVersionInfo.map(v -> v.version().toString()));
115105
configAction.execute(loggedExec);
116106
});
117107
}
@@ -122,32 +112,6 @@ private String minimumCompilerVersionPath(Version bwcVersion) {
122112
: "buildSrc/" + MINIMUM_COMPILER_VERSION_PATH;
123113
}
124114

125-
private static class IndentingOutputStream extends OutputStream {
126-
127-
public final byte[] indent;
128-
private final OutputStream delegate;
129-
130-
IndentingOutputStream(OutputStream delegate, Object version) {
131-
this.delegate = delegate;
132-
indent = (" [" + version + "] ").getBytes(StandardCharsets.UTF_8);
133-
}
134-
135-
@Override
136-
public void write(int b) throws IOException {
137-
int[] arr = { b };
138-
write(arr, 0, 1);
139-
}
140-
141-
public void write(int[] bytes, int offset, int length) throws IOException {
142-
for (int i = 0; i < bytes.length; i++) {
143-
delegate.write(bytes[i]);
144-
if (bytes[i] == '\n') {
145-
delegate.write(indent);
146-
}
147-
}
148-
}
149-
}
150-
151115
private static String readFromFile(File file) {
152116
try {
153117
return FileUtils.readFileToString(file).trim();

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,29 +69,27 @@ public void apply(Project project) {
6969
TaskContainer tasks = project.getTasks();
7070
TaskProvider<LoggedExec> createCloneTaskProvider = tasks.register("createClone", LoggedExec.class, createClone -> {
7171
createClone.onlyIf(task -> this.gitExtension.getCheckoutDir().get().exists() == false);
72-
createClone.setCommandLine(asList("git", "clone", buildLayout.getRootDirectory(), gitExtension.getCheckoutDir().get()));
72+
createClone.commandLine("git", "clone", buildLayout.getRootDirectory(), gitExtension.getCheckoutDir().get());
7373
});
7474

7575
ExtraPropertiesExtension extraProperties = project.getExtensions().getExtraProperties();
7676
TaskProvider<LoggedExec> findRemoteTaskProvider = tasks.register("findRemote", LoggedExec.class, findRemote -> {
7777
findRemote.dependsOn(createCloneTaskProvider);
78-
// TODO Gradle should provide property based configuration here
79-
findRemote.setWorkingDir(gitExtension.getCheckoutDir().get());
80-
findRemote.setCommandLine(asList("git", "remote", "-v"));
81-
ByteArrayOutputStream output = new ByteArrayOutputStream();
82-
findRemote.setStandardOutput(output);
83-
findRemote.doLast(t -> { extraProperties.set("remoteExists", isRemoteAvailable(remote, output)); });
78+
findRemote.getWorkingDir().set(gitExtension.getCheckoutDir());
79+
findRemote.commandLine("git", "remote", "-v");
80+
findRemote.getCaptureOutput().set(true);
81+
findRemote.doLast(t -> { extraProperties.set("remoteExists", isRemoteAvailable(remote, findRemote.getOutput())); });
8482
});
8583

8684
TaskProvider<LoggedExec> addRemoteTaskProvider = tasks.register("addRemote", LoggedExec.class, addRemote -> {
8785
addRemote.dependsOn(findRemoteTaskProvider);
8886
addRemote.onlyIf(task -> ((boolean) extraProperties.get("remoteExists")) == false);
89-
addRemote.setWorkingDir(gitExtension.getCheckoutDir().get());
87+
addRemote.getWorkingDir().set(gitExtension.getCheckoutDir().get());
9088
String remoteRepo = remote.get();
9189
// for testing only we can override the base remote url
9290
String remoteRepoUrl = providerFactory.systemProperty("testRemoteRepo")
9391
.getOrElse("https://github.com/" + remoteRepo + "/elasticsearch.git");
94-
addRemote.setCommandLine(asList("git", "remote", "add", remoteRepo, remoteRepoUrl));
92+
addRemote.commandLine("git", "remote", "add", remoteRepo, remoteRepoUrl);
9593
});
9694

9795
boolean isOffline = project.getGradle().getStartParameter().isOffline();
@@ -107,8 +105,8 @@ public void apply(Project project) {
107105
});
108106
fetchLatest.onlyIf(t -> isOffline == false && gitFetchLatest.get());
109107
fetchLatest.dependsOn(addRemoteTaskProvider);
110-
fetchLatest.setWorkingDir(gitExtension.getCheckoutDir().get());
111-
fetchLatest.setCommandLine(asList("git", "fetch", "--all"));
108+
fetchLatest.getWorkingDir().set(gitExtension.getCheckoutDir().get());
109+
fetchLatest.commandLine("git", "fetch", "--all");
112110
});
113111

114112
String projectPath = project.getPath();
@@ -210,7 +208,7 @@ private String execInCheckoutDir(Action<ExecSpec> execSpecConfig) {
210208
return os.toString().trim();
211209
}
212210

213-
private static boolean isRemoteAvailable(Provider<String> remote, ByteArrayOutputStream output) {
214-
return new String(output.toByteArray()).lines().anyMatch(l -> l.contains(remote.get() + "\t"));
211+
private static boolean isRemoteAvailable(Provider<String> remote, String output) {
212+
return output.lines().anyMatch(l -> l.contains(remote.get() + "\t"));
215213
}
216214
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ static void createBuildBwcTask(
241241
return BuildParams.isCi()
242242
&& (gitBranch == null || gitBranch.endsWith("master") == false || gitBranch.endsWith("main") == false);
243243
});
244-
c.args(projectPath.replace('/', ':') + ":" + assembleTaskName);
244+
c.getArgs().add(projectPath.replace('/', ':') + ":" + assembleTaskName);
245245
if (project.getGradle().getStartParameter().isBuildCacheEnabled()) {
246-
c.args("--build-cache");
246+
c.getArgs().add("--build-cache");
247247
}
248248
c.doLast(new Action<Task>() {
249249
@Override

0 commit comments

Comments
 (0)