Skip to content

Commit

Permalink
Merge branch 'main' into fix/coord_rewrite_timestamp_alias
Browse files Browse the repository at this point in the history
  • Loading branch information
javanna authored Nov 21, 2024
2 parents 59a2ac7 + 35116c3 commit 6aca8a5
Show file tree
Hide file tree
Showing 488 changed files with 13,980 additions and 6,845 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.elasticsearch.index.mapper.NumberFieldMapper.NumberType;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
import org.elasticsearch.plugins.PluginsLoader;
import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.plugins.ScriptPlugin;
import org.elasticsearch.script.DocReader;
Expand Down Expand Up @@ -76,8 +77,7 @@ public class ScriptScoreBenchmark {
private final PluginsService pluginsService = new PluginsService(
Settings.EMPTY,
null,
null,
Path.of(System.getProperty("plugins.dir"))
new PluginsLoader(null, Path.of(System.getProperty("plugins.dir")))
);
private final ScriptModule scriptModule = new ScriptModule(Settings.EMPTY, pluginsService.filterPlugins(ScriptPlugin.class).toList());

Expand Down
3 changes: 3 additions & 0 deletions branches.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
{
"branch": "8.16"
},
{
"branch": "8.17"
},
{
"branch": "8.x"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

package org.elasticsearch.gradle.internal


import spock.lang.Unroll
import com.github.tomakehurst.wiremock.WireMockServer

Expand All @@ -24,22 +23,19 @@ import java.nio.file.Paths
import java.util.regex.Matcher
import java.util.regex.Pattern

import static org.elasticsearch.gradle.internal.JdkDownloadPlugin.VENDOR_ADOPTIUM
import static org.elasticsearch.gradle.internal.JdkDownloadPlugin.VENDOR_OPENJDK
import static org.elasticsearch.gradle.internal.JdkDownloadPlugin.*

class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {

private static final String OPENJDK_VERSION_OLD = "1+99"
private static final String ADOPT_JDK_VERSION = "12.0.2+10"
private static final String ADOPT_JDK_VERSION_11 = "11.0.10+9"
private static final String ADOPT_JDK_VERSION_15 = "15.0.2+7"
private static final String AZUL_JDK_VERSION_8 = "8u302+b08"
private static final String AZUL_8_DISTRO_VERSION = "8.56.0.23"
private static final String OPEN_JDK_VERSION = "12.0.1+99@123456789123456789123456789abcde"
private static final Pattern JDK_HOME_LOGLINE = Pattern.compile("JDK HOME: (.*)")

def setup() {
configurationCacheCompatible = false
}

@Unroll
def "jdk #jdkVendor for #platform#suffix are downloaded and extracted"() {
given:
Expand All @@ -56,14 +52,16 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
version = '$jdkVersion'
platform = "$platform"
architecture = '$arch'
distributionVersion = '$distributionVersion'
}
}
def theJdks = jdks
// def theJdks = jdks
tasks.register("getJdk") {
dependsOn jdks.myJdk
def jdk = jdks.myJdk
doLast {
println "JDK HOME: " + theJdks.myJdk
println "JDK HOME: " + jdk
}
}
"""
Expand All @@ -78,22 +76,23 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
assertExtraction(result.output, expectedJavaBin);

where:
platform | arch | jdkVendor | jdkVersion | expectedJavaBin | suffix
"linux" | "x64" | VENDOR_ADOPTIUM | ADOPT_JDK_VERSION | "bin/java" | ""
"linux" | "x64" | VENDOR_OPENJDK | OPEN_JDK_VERSION | "bin/java" | ""
"linux" | "x64" | VENDOR_OPENJDK | OPENJDK_VERSION_OLD | "bin/java" | "(old version)"
"windows" | "x64" | VENDOR_ADOPTIUM | ADOPT_JDK_VERSION | "bin/java" | ""
"windows" | "x64" | VENDOR_OPENJDK | OPEN_JDK_VERSION | "bin/java" | ""
"windows" | "x64" | VENDOR_OPENJDK | OPENJDK_VERSION_OLD | "bin/java" | "(old version)"
"darwin" | "x64" | VENDOR_ADOPTIUM | ADOPT_JDK_VERSION | "Contents/Home/bin/java" | ""
"darwin" | "x64" | VENDOR_OPENJDK | OPEN_JDK_VERSION | "Contents/Home/bin/java" | ""
"darwin" | "x64" | VENDOR_OPENJDK | OPENJDK_VERSION_OLD | "Contents/Home/bin/java" | "(old version)"
"mac" | "x64" | VENDOR_OPENJDK | OPEN_JDK_VERSION | "Contents/Home/bin/java" | ""
"mac" | "x64" | VENDOR_OPENJDK | OPENJDK_VERSION_OLD | "Contents/Home/bin/java" | "(old version)"
"darwin" | "aarch64" | VENDOR_ADOPTIUM | ADOPT_JDK_VERSION | "Contents/Home/bin/java" | ""
"linux" | "aarch64" | VENDOR_ADOPTIUM | ADOPT_JDK_VERSION | "bin/java" | ""
"linux" | "aarch64" | VENDOR_ADOPTIUM | ADOPT_JDK_VERSION_11 | "bin/java" | "(jdk 11)"
"linux" | "aarch64" | VENDOR_ADOPTIUM | ADOPT_JDK_VERSION_15 | "bin/java" | "(jdk 15)"
platform | arch | jdkVendor | jdkVersion | distributionVersion | expectedJavaBin | suffix
"linux" | "x64" | VENDOR_ADOPTIUM | ADOPT_JDK_VERSION | null | "bin/java" | ""
"linux" | "x64" | VENDOR_OPENJDK | OPEN_JDK_VERSION | null | "bin/java" | ""
"linux" | "x64" | VENDOR_OPENJDK | OPENJDK_VERSION_OLD | null | "bin/java" | "(old version)"
"windows" | "x64" | VENDOR_ADOPTIUM | ADOPT_JDK_VERSION | null | "bin/java" | ""
"windows" | "x64" | VENDOR_OPENJDK | OPEN_JDK_VERSION | null | "bin/java" | ""
"windows" | "x64" | VENDOR_OPENJDK | OPENJDK_VERSION_OLD | null | "bin/java" | "(old version)"
"darwin" | "x64" | VENDOR_ADOPTIUM | ADOPT_JDK_VERSION | null | "Contents/Home/bin/java" | ""
"darwin" | "x64" | VENDOR_OPENJDK | OPEN_JDK_VERSION | null | "Contents/Home/bin/java" | ""
"darwin" | "x64" | VENDOR_OPENJDK | OPENJDK_VERSION_OLD | null | "Contents/Home/bin/java" | "(old version)"
"mac" | "x64" | VENDOR_OPENJDK | OPEN_JDK_VERSION | null | "Contents/Home/bin/java" | ""
"mac" | "x64" | VENDOR_OPENJDK | OPENJDK_VERSION_OLD | null | "Contents/Home/bin/java" | "(old version)"
"darwin" | "aarch64" | VENDOR_ADOPTIUM | ADOPT_JDK_VERSION | null | "Contents/Home/bin/java" | ""
"linux" | "aarch64" | VENDOR_ADOPTIUM | ADOPT_JDK_VERSION | null | "bin/java" | ""
"linux" | "aarch64" | VENDOR_ADOPTIUM | ADOPT_JDK_VERSION_11 | null | "bin/java" | "(jdk 11)"
"linux" | "aarch64" | VENDOR_ADOPTIUM | ADOPT_JDK_VERSION_15 | null | "bin/java" | "(jdk 15)"
"darwin" | "aarch64" | VENDOR_ZULU | AZUL_JDK_VERSION_8 | AZUL_8_DISTRO_VERSION | "Contents/Home/bin/java" | "(jdk 8)"
}

def "transforms are reused across projects"() {
Expand All @@ -118,9 +117,10 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
}
}
tasks.register("getJdk") {
dependsOn jdks.myJdk
def jdk = jdks.myJdk
dependsOn jdk
doLast {
println "JDK HOME: " + jdks.myJdk
println "JDK HOME: " + jdk
}
}
"""
Expand All @@ -137,7 +137,7 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
result.output.count("Unpacking linux-12.0.2-x64.tar.gz using ${SymbolicLinkPreservingUntarTransform.simpleName}") == 1

where:
platform | jdkVendor | jdkVersion | expectedJavaBin
platform | jdkVendor | jdkVersion | expectedJavaBin
"linux" | VENDOR_ADOPTIUM | ADOPT_JDK_VERSION | "bin/java"
}

Expand All @@ -159,6 +159,7 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
vendor = '$VENDOR_ADOPTIUM'
version = '$ADOPT_JDK_VERSION'
platform = "$platform"
distributionVersion = '$ADOPT_JDK_VERSION'
architecture = "x64"
}
}
Expand Down Expand Up @@ -204,6 +205,8 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
assert matcher.find() == true;
String jdkHome = matcher.group(1);
Path javaPath = Paths.get(jdkHome, javaBin);
println "canonical " + javaPath.toFile().getCanonicalPath()
Paths.get(jdkHome).toFile().listFiles().each { println it }
assert Files.exists(javaPath) == true;
true
}
Expand All @@ -221,15 +224,26 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
final String versionPath = isOld ? "jdk1/99" : "jdk12.0.1/123456789123456789123456789abcde/99";
final String filename = "openjdk-" + (isOld ? "1" : "12.0.1") + "_" + effectivePlatform + "-x64_bin." + extension(platform);
return "/java/GA/" + versionPath + "/GPL/" + filename;
} else if (vendor.equals(VENDOR_ZULU)) {
// we only have a single version of zulu currently in the tests
return "/zulu/bin/zulu8.56.0.23-ca-jdk8.0.302-macosx_aarch64.tar.gz"
}
}

private static byte[] filebytes(final String vendor, final String platform) throws IOException {
final String effectivePlatform = getPlatform(vendor, platform);
if (vendor.equals(VENDOR_ADOPTIUM)) {
return JdkDownloadPluginFuncTest.class.getResourceAsStream("fake_adoptium_" + effectivePlatform + "." + extension(platform)).getBytes()
return JdkDownloadPluginFuncTest.class.getResourceAsStream(
"fake_adoptium_" + effectivePlatform + "." + extension(platform)
).getBytes()
} else if (vendor.equals(VENDOR_OPENJDK)) {
JdkDownloadPluginFuncTest.class.getResourceAsStream("fake_openjdk_" + effectivePlatform + "." + extension(platform)).getBytes()
return JdkDownloadPluginFuncTest.class.getResourceAsStream(
"fake_openjdk_" + effectivePlatform + "." + extension(platform)
).getBytes()
} else {
// zulu
String resourcePath = "fake_zulu_" + effectivePlatform + "." + extension(platform)
return JdkDownloadPluginFuncTest.class.getResourceAsStream(resourcePath).getBytes()
}
}

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ if (providers.systemProperty('idea.active').getOrNull() == 'true') {

doLast {
['main', 'test'].each { sourceSet ->
modifyXml(".idea/modules/libs/native/elasticsearch.libs.${project.project(':libs:native').name}.${sourceSet}.iml") { xml ->
modifyXml(".idea/modules/libs/native/elasticsearch.libs.native.${sourceSet}.iml") { xml ->
xml.component.find { it.'@name' == 'NewModuleRootManager' }?.'@LANGUAGE_LEVEL' = 'JDK_21_PREVIEW'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@ import org.elasticsearch.gradle.internal.test.AntFixture
import org.gradle.api.file.FileSystemOperations
import org.gradle.api.file.ProjectLayout
import org.gradle.api.provider.ProviderFactory
import org.gradle.api.tasks.Internal
import org.gradle.process.ExecOperations

import javax.inject.Inject

abstract class AntFixtureStop extends LoggedExec implements FixtureStop {

@Internal
AntFixture fixture

@Inject
AntFixtureStop(ProjectLayout projectLayout,
ExecOperations execOperations,
Expand All @@ -34,12 +30,12 @@ abstract class AntFixtureStop extends LoggedExec implements FixtureStop {
}

void setFixture(AntFixture fixture) {
assert this.fixture == null
this.fixture = fixture;
final Object pid = "${-> this.fixture.pid}"
onlyIf("pidFile exists") { fixture.pidFile.exists() }
def pidFile = fixture.pidFile
def fixtureName = fixture.name
final Object pid = "${-> Integer.parseInt(pidFile.getText('UTF-8').trim())}"
onlyIf("pidFile exists") { pidFile.exists() }
doFirst {
logger.info("Shutting down ${fixture.name} with pid ${pid}")
logger.info("Shutting down ${fixtureName} with pid ${pid}")
}

if (OS.current() == OS.WINDOWS) {
Expand All @@ -51,9 +47,8 @@ abstract class AntFixtureStop extends LoggedExec implements FixtureStop {
}
doLast {
fileSystemOperations.delete {
it.delete(fixture.pidFile)
it.delete(pidFile)
}
}
this.fixture = fixture
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ import java.nio.charset.Charset
*/
public abstract class AntTask extends DefaultTask {

/**
* A buffer that will contain the output of the ant code run,
* if the output was not already written directly to stdout.
*/
public final ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream()

@Inject
protected FileSystemOperations getFileSystemOperations() {
Expand All @@ -57,6 +52,11 @@ public abstract class AntTask extends DefaultTask {

// otherwise groovy replaces System.out, and you have no chance to debug
// ant.saveStreams = false
/**
* A buffer that will contain the output of the ant code run,
* if the output was not already written directly to stdout.
*/
ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream()

final int outputLevel = logger.isDebugEnabled() ? Project.MSG_DEBUG : Project.MSG_INFO
final PrintStream stream = useStdout() ? System.out : new PrintStream(outputBuffer, true, Charset.defaultCharset().name())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,37 @@
package org.elasticsearch.gradle.internal.test

import org.elasticsearch.gradle.OS

import org.elasticsearch.gradle.internal.AntFixtureStop
import org.elasticsearch.gradle.internal.AntTask
import org.elasticsearch.gradle.testclusters.TestClusterInfo
import org.elasticsearch.gradle.testclusters.TestClusterValueSource
import org.elasticsearch.gradle.testclusters.TestClustersRegistry
import org.gradle.api.GradleException
import org.gradle.api.file.ProjectLayout
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.provider.ProviderFactory
import org.gradle.api.provider.ValueSource
import org.gradle.api.provider.ValueSourceParameters
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskProvider

import javax.inject.Inject

/**
* A fixture for integration tests which runs in a separate process launched by Ant.
*/
class AntFixture extends AntTask implements Fixture {
class AntFixture extends AntTask {

/** The path to the executable that starts the fixture. */
@Internal
String executable

private final List<Object> arguments = new ArrayList<>()
private ProjectLayout projectLayout
private final ProviderFactory providerFactory

void args(Object... args) {
arguments.addAll(args)
Expand Down Expand Up @@ -69,19 +84,14 @@ class AntFixture extends AntTask implements Fixture {
return tmpFile.exists()
}

private final TaskProvider<AntFixtureStop> stopTask

AntFixture() {
stopTask = createStopTask()
@Inject
AntFixture(ProjectLayout projectLayout, ProviderFactory providerFactory) {
this.providerFactory = providerFactory
this.projectLayout = projectLayout;
TaskProvider<AntFixtureStop> stopTask = createStopTask()
finalizedBy(stopTask)
}

@Override
@Internal
TaskProvider<AntFixtureStop> getStopTask() {
return stopTask
}

@Override
protected void runAnt(AntBuilder ant) {
// reset everything
Expand Down Expand Up @@ -231,7 +241,7 @@ class AntFixture extends AntTask implements Fixture {
*/
@Internal
protected File getBaseDir() {
return new File(project.buildDir, "fixtures/${name}")
return new File(projectLayout.getBuildDirectory().getAsFile().get(), "fixtures/${name}")
}

/** Returns the working directory for the process. Defaults to "cwd" inside baseDir. */
Expand All @@ -242,7 +252,7 @@ class AntFixture extends AntTask implements Fixture {

/** Returns the file the process writes its pid to. Defaults to "pid" inside baseDir. */
@Internal
protected File getPidFile() {
File getPidFile() {
return new File(baseDir, 'pid')
}

Expand All @@ -264,6 +274,12 @@ class AntFixture extends AntTask implements Fixture {
return portsFile.readLines("UTF-8").get(0)
}

@Internal
Provider<String> getAddressAndPortProvider() {
File thePortFile = portsFile
return providerFactory.provider(() -> thePortFile.readLines("UTF-8").get(0))
}

/** Returns a file that wraps around the actual command when {@code spawn == true}. */
@Internal
protected File getWrapperScript() {
Expand All @@ -281,4 +297,22 @@ class AntFixture extends AntTask implements Fixture {
protected File getRunLog() {
return new File(cwd, 'run.log')
}

@Internal
Provider<AntFixtureValueSource> getAddressAndPortSource() {
return providerFactory.of(AntFixtureValueSource.class, spec -> {
spec.getParameters().getPortFile().set(portsFile);
});
}

static abstract class AntFixtureValueSource implements ValueSource<String, AntFixtureValueSource.Parameters> {
@Override
String obtain() {
return getParameters().getPortFile().map { it.readLines("UTF-8").get(0) }.get()
}

interface Parameters extends ValueSourceParameters {
Property<File> getPortFile();
}
}
}
Loading

0 comments on commit 6aca8a5

Please sign in to comment.