Skip to content

Commit d34433b

Browse files
authored
Merge branch 'main' into update-gradle-wrapper-910
2 parents 67da695 + e5c91ca commit d34433b

File tree

889 files changed

+32645
-11309
lines changed

Some content is hidden

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

889 files changed

+32645
-11309
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
steps:
2+
- command: .buildkite/scripts/trigger-if-java-ea-new-build.sh
3+
env:
4+
RECENT_TIME_WINDOW: "24" # time window to consider a build as new in hours
5+
agents:
6+
image: "docker.elastic.co/ci-agent-images/eck-region/buildkite-agent:1.5"
7+
memory: "4G"

.buildkite/pipelines/periodic-fwc.template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
steps:
2-
- label: "{{matrix.FWC_VERSION}}" / fwc
2+
- label: "{{matrix.FWC_VERSION}} / fwc"
33
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false
44
timeout_in_minutes: 300
55
agents:

.buildkite/pipelines/periodic-fwc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is auto-generated. See .buildkite/pipelines/periodic-fwc.template.yml
22
steps:
3-
- label: "{{matrix.FWC_VERSION}}" / fwc
3+
- label: "{{matrix.FWC_VERSION}} / fwc"
44
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false
55
timeout_in_minutes: 300
66
agents:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
steps: []

.buildkite/pull-requests.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,24 @@
1616
"cancel_intermediate_builds": true,
1717
"cancel_intermediate_builds_on_comment": false
1818
},
19+
{
20+
"enabled": true,
21+
"pipeline_slug": "elasticsearch-pull-request-transport-versions",
22+
"allow_org_users": true,
23+
"allowed_repo_permissions": [
24+
"admin",
25+
"write"
26+
],
27+
"allowed_list": ["elastic-renovate-prod[bot]"],
28+
"set_commit_status": false,
29+
"build_on_commit": true,
30+
"build_on_comment": true,
31+
"trigger_comment_regex": "(run\\W+elasticsearch-ci.+)|(^\\s*((buildkite|@elastic(search)?machine)\\s*)?test\\s+this(\\s+please)?)",
32+
"retrigger_label_regex": "v[0-9]+\\.[0-9]+\\.[0-9]+",
33+
"cancel_intermediate_builds": true,
34+
"cancel_intermediate_builds_on_comment": false,
35+
"skip_duplicate_builds": true
36+
},
1937
{
2038
"enabled": true,
2139
"pipeline_slug": "elasticsearch-pull-request-performance-benchmark",
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#
2+
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
# or more contributor license agreements. Licensed under the "Elastic License
4+
# 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
# Public License v 1"; you may not use this file except in compliance with, at
6+
# your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
# License v3.0 only", or the "Server Side Public License, v 1".
8+
#
9+
10+
#!/bin/bash
11+
12+
# Allow overriding the time window (in hours) to check for new builds, defaults to 24
13+
RECENT_TIME_WINDOW=${RECENT_TIME_WINDOW:-24}
14+
15+
# Extract current JDK major version from bundled_jdk in version.properties
16+
CURRENT_JDK=$(grep "^bundled_jdk =" build-tools-internal/version.properties | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f1)
17+
TARGET_JDK=$((CURRENT_JDK + 1))
18+
19+
echo "Current JDK major version: $CURRENT_JDK"
20+
echo "Target JDK major version: $TARGET_JDK"
21+
22+
# Query Elasticsearch JDK archive for available JDKs
23+
JDK_ARCHIVE_URL="https://builds.es-jdk-archive.com/jdks/openjdk/recent.json"
24+
echo "Querying JDK archive: $JDK_ARCHIVE_URL"
25+
26+
# Fetch JDK info and filter for target major version
27+
JDK_DATA=$(curl -s "$JDK_ARCHIVE_URL")
28+
29+
if [[ -z "$JDK_DATA" ]]; then
30+
echo "Failed to fetch JDK data from archive"
31+
exit 1
32+
fi
33+
34+
# Find the latest build for the target JDK version
35+
LATEST_BUILD=$(echo "$JDK_DATA" | jq -r --arg target "$TARGET_JDK" '
36+
.majors[$target].builds |
37+
sort_by(.archived_at) |
38+
last'
39+
)
40+
41+
if [[ "$LATEST_BUILD" == "null" || -z "$LATEST_BUILD" ]]; then
42+
echo "No builds found for JDK $TARGET_JDK"
43+
exit 1
44+
fi
45+
46+
# Extract timestamp and JDK identifier
47+
TIMESTAMP=$(echo "$LATEST_BUILD" | jq -r '.archived_at')
48+
JDK_IDENTIFIER=$(echo "$LATEST_BUILD" | jq -r '.id')
49+
50+
echo "Latest JDK ${TARGET_JDK} build from ES archive:"
51+
echo " Timestamp: $TIMESTAMP"
52+
echo " JDK Identifier: $JDK_IDENTIFIER"
53+
54+
# Set variables for use in the pipeline trigger
55+
jdkbuild="$JDK_IDENTIFIER"
56+
jdk_timestamp="$TIMESTAMP"
57+
58+
# Check if timestamp is within last 24 hours
59+
CURRENT_TIME=$(date +%s)
60+
BUILD_TIME=$(date -d "$TIMESTAMP" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S" "${TIMESTAMP%Z}" +%s 2>/dev/null || echo "0")
61+
62+
if [[ "$BUILD_TIME" == "0" ]]; then
63+
echo "Failed to parse timestamp: $TIMESTAMP"
64+
SHOULD_TRIGGER="false"
65+
else
66+
TIME_DIFF=$((CURRENT_TIME - BUILD_TIME))
67+
TIME_WINDOW=$((RECENT_TIME_WINDOW * 60 * 60))
68+
69+
if [[ $TIME_DIFF -lt $TIME_WINDOW ]]; then
70+
echo "Build is recent (less than ${RECENT_TIME_WINDOW}h old)"
71+
SHOULD_TRIGGER="true"
72+
else
73+
echo "Build is older than ${RECENT_TIME_WINDOW} hours"
74+
SHOULD_TRIGGER="false"
75+
fi
76+
fi
77+
78+
echo "SHOULD_TRIGGER: $SHOULD_TRIGGER"
79+
80+
81+
if [[ "$SHOULD_TRIGGER" == "true" ]]; then
82+
EFFECTIVE_START_DATE=$(date -u -d "@$BUILD_TIME" +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date -u -r "$BUILD_TIME" +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || echo "")
83+
echo "Triggering performance-esbench-jdk for new jdk build $JDK_IDENTIFIER"
84+
cat << EOF | buildkite-agent pipeline upload
85+
steps:
86+
- trigger: elasticsearch-performance-esbench-jdk
87+
label: Triggering performance-esbench-jdk for new jdk build $JDK_IDENTIFIER
88+
async: true
89+
build:
90+
branch: "$BUILDKITE_BRANCH"
91+
env:
92+
EFFECTIVE_START_DATE: "$EFFECTIVE_START_DATE"
93+
EXECUTION_MODE: "start-run"
94+
EOF
95+
fi

TESTING.asciidoc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -681,12 +681,15 @@ There are multiple base classes for tests:
681681
directly by unit tests.
682682
* **`ESSingleNodeTestCase`**: This test case sets up a cluster that has a
683683
single node.
684-
* **`ESIntegTestCase`**: An integration test case that creates a cluster that
685-
might have multiple nodes.
686-
* **`ESRestTestCase`**: An integration tests that interacts with an external
687-
cluster via the REST API. This is used for Java based REST tests.
688-
* **`ESClientYamlSuiteTestCase` **: A subclass of `ESRestTestCase` used to run
689-
YAML based REST tests.
684+
* **`ESIntegTestCase`**: An internal integration test that starts nodes within the same JVM as the test.
685+
These allow you to test functionality that is not exposed via the REST API, or for verifying a certain internal state.
686+
Additionally, you can easily simulate tricky distributed setups that are difficult to do in REST tests.
687+
If you only need to start one node, use `ESSingleNodeTestCase` instead, which is a much lighter test setup.
688+
* **`ESRestTestCase`**: An integration test that interacts with an external
689+
cluster via the REST API. This is used for Java based REST tests. This should
690+
be the first choice for writing integration tests as these tests run in a much more
691+
realistic setup.
692+
* **`ESClientYamlSuiteTestCase` **: A subclass of `ESRestTestCase` used to run YAML based REST tests.
690693

691694
=== Good practices
692695

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.benchmark.vector;
11+
12+
import org.elasticsearch.common.logging.LogConfigurator;
13+
import org.elasticsearch.index.codec.vectors.cluster.NeighborHood;
14+
import org.openjdk.jmh.annotations.Benchmark;
15+
import org.openjdk.jmh.annotations.BenchmarkMode;
16+
import org.openjdk.jmh.annotations.Fork;
17+
import org.openjdk.jmh.annotations.Measurement;
18+
import org.openjdk.jmh.annotations.Mode;
19+
import org.openjdk.jmh.annotations.OutputTimeUnit;
20+
import org.openjdk.jmh.annotations.Param;
21+
import org.openjdk.jmh.annotations.Scope;
22+
import org.openjdk.jmh.annotations.Setup;
23+
import org.openjdk.jmh.annotations.State;
24+
import org.openjdk.jmh.annotations.Warmup;
25+
import org.openjdk.jmh.infra.Blackhole;
26+
27+
import java.io.IOException;
28+
import java.util.Random;
29+
import java.util.concurrent.TimeUnit;
30+
31+
@BenchmarkMode(Mode.AverageTime)
32+
@OutputTimeUnit(TimeUnit.SECONDS)
33+
@State(Scope.Benchmark)
34+
// first iteration is complete garbage, so make sure we really warmup
35+
@Warmup(iterations = 1, time = 1)
36+
// real iterations. not useful to spend tons of time here, better to fork more
37+
@Measurement(iterations = 3, time = 1)
38+
// engage some noise reduction
39+
@Fork(value = 1)
40+
public class ComputeNeighboursBenchmark {
41+
42+
static {
43+
LogConfigurator.configureESLogging(); // native access requires logging to be initialized
44+
}
45+
46+
@Param({ "1000", "2000", "3000", "5000", "10000", "20000", "50000" })
47+
int numVectors;
48+
49+
@Param({ "384", "782", "1024" })
50+
int dims;
51+
52+
float[][] vectors;
53+
int clusterPerNeighbour = 128;
54+
55+
@Setup
56+
public void setup() throws IOException {
57+
Random random = new Random(123);
58+
vectors = new float[numVectors][dims];
59+
for (float[] vector : vectors) {
60+
for (int i = 0; i < dims; i++) {
61+
vector[i] = random.nextFloat();
62+
}
63+
}
64+
}
65+
66+
@Benchmark
67+
@Fork(jvmArgsPrepend = { "--add-modules=jdk.incubator.vector" })
68+
public void bruteForce(Blackhole bh) {
69+
bh.consume(NeighborHood.computeNeighborhoodsBruteForce(vectors, clusterPerNeighbour));
70+
}
71+
72+
@Benchmark
73+
@Fork(jvmArgsPrepend = { "--add-modules=jdk.incubator.vector" })
74+
public void graph(Blackhole bh) throws IOException {
75+
bh.consume(NeighborHood.computeNeighborhoodsGraph(vectors, clusterPerNeighbour));
76+
}
77+
}

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

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,65 @@ class ElasticsearchTestBasePluginFuncTest extends AbstractGradleFuncTest {
108108
then:
109109
result.task(':test').outcome == TaskOutcome.UP_TO_DATE
110110
}
111+
112+
def "uses new test seed for every invocation"() {
113+
given:
114+
file("src/test/java/acme/SomeTests.java").text = """
115+
116+
public class SomeTests {
117+
@org.junit.Test
118+
public void printTestSeed() {
119+
System.out.println("TESTSEED=[" + System.getProperty("tests.seed") + "]");
120+
}
121+
}
122+
123+
"""
124+
buildFile.text = """
125+
plugins {
126+
id 'java'
127+
id 'elasticsearch.test-base'
128+
}
129+
130+
tasks.named('test').configure {
131+
testLogging {
132+
showStandardStreams = true
133+
}
134+
}
135+
136+
tasks.register('test2', Test) {
137+
classpath = sourceSets.test.runtimeClasspath
138+
testClassesDirs = sourceSets.test.output.classesDirs
139+
testLogging {
140+
showStandardStreams = true
141+
}
142+
}
143+
144+
repositories {
145+
mavenCentral()
146+
}
147+
148+
dependencies {
149+
testImplementation 'junit:junit:4.12'
150+
}
151+
152+
"""
153+
154+
when:
155+
def result1 = gradleRunner("cleanTest", "cleanTest2", "test", "test2").build()
156+
def result2 = gradleRunner("cleanTest", "cleanTest2", "test", "test2").build()
157+
158+
then:
159+
def seeds1 = result1.output.findAll(/(?m)TESTSEED=\[([^\]]+)\]/) { it[1] }
160+
def seeds2 = result2.output.findAll(/(?m)TESTSEED=\[([^\]]+)\]/) { it[1] }
161+
162+
seeds1.unique().size() == 1
163+
seeds2.unique().size() == 1
164+
165+
verifyAll {
166+
seeds1[0] != null
167+
seeds2[0] != null
168+
seeds1[0] != seeds2[0]
169+
}
170+
result2.output.contains("Configuration cache entry reused.")
171+
}
111172
}

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import org.gradle.testkit.runner.BuildResult
1414
import org.gradle.testkit.runner.TaskOutcome
1515

1616
class AbstractTransportVersionFuncTest extends AbstractGradleFuncTest {
17+
1718
def javaResource(String project, String path, String content) {
1819
file("${project}/src/main/resources/${path}").withWriter { writer ->
1920
writer << content
@@ -45,10 +46,18 @@ class AbstractTransportVersionFuncTest extends AbstractGradleFuncTest {
4546
return referableAndReferencedTransportVersion(name, ids, "Test${name.capitalize()}")
4647
}
4748

48-
def referableAndReferencedTransportVersion(String name, String ids, String classname) {
49+
def referencedTransportVersion(String name) {
50+
referencedTransportVersion(name, "Test${name.capitalize()}")
51+
}
52+
53+
def referencedTransportVersion(String name, String classname) {
4954
javaSource("myserver", "org.elasticsearch", classname, "", """
5055
static final TransportVersion usage = TransportVersion.fromName("${name}");
5156
""")
57+
}
58+
59+
def referableAndReferencedTransportVersion(String name, String ids, String classname) {
60+
referencedTransportVersion(name, classname)
5261
referableTransportVersion(name, ids)
5362
}
5463

@@ -74,6 +83,20 @@ class AbstractTransportVersionFuncTest extends AbstractGradleFuncTest {
7483
assertOutputContains(result.output, expectedOutput)
7584
}
7685

86+
void assertReferableDefinition(String name, String content) {
87+
File definitionFile = file("myserver/src/main/resources/transport/definitions/referable/${name}.csv")
88+
assert definitionFile.exists()
89+
assert definitionFile.text.strip() == content
90+
}
91+
92+
void assertReferableDefinitionDoesNotExist(String name) {
93+
assert file("myserver/src/main/resources/transport/definitions/referable/${name}.csv").exists() == false
94+
}
95+
96+
void assertUpperBound(String name, String content) {
97+
assert file("myserver/src/main/resources/transport/upper_bounds/${name}.csv").text.strip() == content
98+
}
99+
77100
def setup() {
78101
configurationCacheCompatible = false
79102
internalBuild()
@@ -86,12 +109,17 @@ class AbstractTransportVersionFuncTest extends AbstractGradleFuncTest {
86109
apply plugin: 'java-library'
87110
apply plugin: 'elasticsearch.transport-version-references'
88111
apply plugin: 'elasticsearch.transport-version-resources'
112+
113+
tasks.named('generateTransportVersionDefinition') {
114+
currentUpperBoundName = '9.2'
115+
}
89116
"""
90117
referableTransportVersion("existing_91", "8012000")
91118
referableTransportVersion("existing_92", "8123000,8012001")
92119
unreferableTransportVersion("initial_9_0_0", "8000000")
93120
transportVersionUpperBound("9.2", "existing_92", "8123000")
94121
transportVersionUpperBound("9.1", "existing_92", "8012001")
122+
transportVersionUpperBound("9.0", "initial_9_0_0", "8000000")
95123
// a mock version of TransportVersion, just here so we can compile Dummy.java et al
96124
javaSource("myserver", "org.elasticsearch", "TransportVersion", "", """
97125
public static TransportVersion fromName(String name) {

0 commit comments

Comments
 (0)