Skip to content

Commit c416bf7

Browse files
authored
Merge branch 'main' into nit-empty-incremental-bulk
2 parents 2687ba0 + 8f82f3f commit c416bf7

File tree

400 files changed

+9295
-3108
lines changed

Some content is hidden

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

400 files changed

+9295
-3108
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
steps:
2-
- label: $FWC_VERSION / fwc
3-
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false
2+
- label: "{{matrix.FWC_VERSION}} / fwc"
3+
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:
66
provider: gcp
@@ -11,4 +11,4 @@ steps:
1111
setup:
1212
FWC_VERSION: $FWC_LIST
1313
env:
14-
FWC_VERSION: $FWC_VERSION
14+
FWC_VERSION: "{{matrix.FWC_VERSION}}"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This file is auto-generated. See .buildkite/pipelines/periodic-fwc.template.yml
22
steps:
3-
- label: $FWC_VERSION / fwc
4-
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false
3+
- label: "{{matrix.FWC_VERSION}} / fwc"
4+
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:
77
provider: gcp
@@ -12,4 +12,4 @@ steps:
1212
setup:
1313
FWC_VERSION: []
1414
env:
15-
FWC_VERSION: $FWC_VERSION
15+
FWC_VERSION: "{{matrix.FWC_VERSION}}"

.buildkite/scripts/fwc-branches.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# Configure FwC test branches
4+
# We do not want 7.x branch and only to run for branches that:
5+
# - have released at least one minor version (not main)
6+
# - have previous minor unreleased (not the oldest development branch)
7+
FWC_BRANCHES=()
8+
for branch in "${BRANCHES[@]}"; do
9+
if [[ ! "$branch" =~ ^7\..* ]]; then
10+
FWC_BRANCHES+=("$branch")
11+
fi
12+
done
13+
# Remove first and last element
14+
FWC_BRANCHES=("${FWC_BRANCHES[@]:1:${#FWC_BRANCHES[@]}-2}")
15+
16+
shouldRunFwcFor() {
17+
local branch=$1
18+
for fwc_branch in "${FWC_BRANCHES[@]}"; do
19+
if [[ "$fwc_branch" == "$branch" ]]; then
20+
return 0
21+
fi
22+
done
23+
return 1
24+
}

.buildkite/scripts/generate-pr-performance-benchmark.sh

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,69 @@
22

33
set -euo pipefail
44

5+
# uncomment for tests
6+
#function buildkite-agent {
7+
# local command=$1
8+
# echo "$@"
9+
# if [ "$command" == "annotate" ]; then
10+
# while read -r line; do
11+
# echo " read: $line";
12+
# done
13+
# fi
14+
#}
15+
516
env_id_baseline=$(python3 -c 'import uuid; print(uuid.uuid4())')
617
env_id_contender=$(python3 -c 'import uuid; print(uuid.uuid4())')
718
merge_base=$(git merge-base "${GITHUB_PR_TARGET_BRANCH}" HEAD)
819

20+
# PR comment
21+
buildkite-agent meta-data set pr_comment:early_comment_job_id "$BUILDKITE_JOB_ID"
922
buildkite-agent meta-data set pr_comment:custom-body:body \
10-
"This build attempted two ${GITHUB_PR_COMMENT_VAR_BENCHMARK} benchmarks to evaluate performance impact of this PR."
23+
"This build attempts two ${GITHUB_PR_COMMENT_VAR_BENCHMARK} benchmarks to evaluate performance impact of this PR. \
24+
To estimate benchmark completion time inspect previous nightly runs [here](https://buildkite.com/elastic/elasticsearch-performance-esbench-nightly/builds?branch=master)."
1125
buildkite-agent meta-data set pr_comment:custom-baseline:head \
1226
"* Baseline: ${merge_base} (env ID ${env_id_baseline})"
1327
buildkite-agent meta-data set pr_comment:custom-contender:head \
1428
"* Contender: ${GITHUB_PR_TRIGGERED_SHA} (env ID ${env_id_contender})"
1529

16-
cat << _EOF_
30+
# Buildkite annotation
31+
cat << _EOF1_ | buildkite-agent annotate --context "pr-benchmark-notification"
32+
This build attempts two ${GITHUB_PR_COMMENT_VAR_BENCHMARK} benchmarks to evaluate performance impact of PR [${GITHUB_PR_NUMBER}](https://github.com/elastic/elasticsearch/pull/${GITHUB_PR_NUMBER}).
33+
To estimate benchmark completion time inspect previous nightly runs [here](https://buildkite.com/elastic/elasticsearch-performance-esbench-nightly/builds?branch=master).
34+
* Baseline: [${merge_base:0:7}](https://github.com/elastic/elasticsearch/commit/${merge_base}) (env ID ${env_id_baseline})
35+
* Contender: [${GITHUB_PR_TRIGGERED_SHA:0:7}](https://github.com/elastic/elasticsearch/commit/${GITHUB_PR_TRIGGERED_SHA}) (env ID ${env_id_contender})
36+
_EOF1_
37+
38+
cat << _EOF2_
1739
steps:
18-
- label: Trigger baseline benchmark
40+
- label: Trigger baseline benchmark with ${merge_base:0:7}
1941
trigger: elasticsearch-performance-esbench-pr
2042
build:
21-
message: Baseline benchmark for PR${GITHUB_PR_NUMBER}
43+
message: Baseline benchmark for PR ${GITHUB_PR_NUMBER} with ${merge_base:0:7}
2244
branch: master
2345
env:
2446
CONFIGURATION_NAME: ${GITHUB_PR_COMMENT_VAR_BENCHMARK}
2547
ENV_ID: ${env_id_baseline}
2648
REVISION: ${merge_base}
27-
- label: Trigger contender benchmark
49+
- label: Trigger contender benchmark with ${GITHUB_PR_TRIGGERED_SHA:0:7}
2850
trigger: elasticsearch-performance-esbench-pr
2951
build:
30-
message: Contender benchmark for PR${GITHUB_PR_NUMBER}
52+
message: Contender benchmark for PR ${GITHUB_PR_NUMBER} with ${GITHUB_PR_TRIGGERED_SHA:0:7}
3153
branch: master
3254
env:
3355
CONFIGURATION_NAME: ${GITHUB_PR_COMMENT_VAR_BENCHMARK}
3456
ENV_ID: ${env_id_contender}
3557
ES_REPO_URL: https://github.com/${GITHUB_PR_OWNER}/${GITHUB_PR_REPO}.git
3658
REVISION: ${GITHUB_PR_TRIGGERED_SHA}
3759
- wait: ~
38-
- label: Modify PR comment
39-
command: buildkite-agent meta-data set pr_comment:custom-comparison:head "* [Benchmark results](<https://esbench-metrics.kb.us-east-2.aws.elastic-cloud.com:9243/app/dashboards#/view/d9079962-5866-49ef-b9f5-145f2141cd31?_a=(query:(language:kuery,query:'user-tags.env-id:${env_id_baseline} or user-tags.env-id:${env_id_contender}'))>)"
40-
_EOF_
60+
- label: Update PR comment and Buildkite annotation
61+
command: |
62+
buildkite-agent meta-data set pr_comment:custom-body:body "This build ran two ${GITHUB_PR_COMMENT_VAR_BENCHMARK} benchmarks to evaluate performance impact of this PR."
63+
buildkite-agent meta-data set pr_comment:custom-comparison:head "* [Benchmark results](<https://esbench-metrics.kb.us-east-2.aws.elastic-cloud.com:9243/app/dashboards#/view/d9079962-5866-49ef-b9f5-145f2141cd31?_a=(query:(language:kuery,query:'user-tags.env-id:${env_id_baseline} or user-tags.env-id:${env_id_contender}'))>)"
64+
cat << _EOF3_ | buildkite-agent annotate --context "pr-benchmark-notification"
65+
This build ran two ${GITHUB_PR_COMMENT_VAR_BENCHMARK} benchmarks to evaluate performance impact of PR [${GITHUB_PR_NUMBER}](https://github.com/elastic/elasticsearch/pull/${GITHUB_PR_NUMBER}).
66+
* Baseline: [${merge_base:0:7}](https://github.com/elastic/elasticsearch/commit/${merge_base}) (env ID ${env_id_baseline})
67+
* Contender: [${GITHUB_PR_TRIGGERED_SHA:0:7}](https://github.com/elastic/elasticsearch/commit/${GITHUB_PR_TRIGGERED_SHA}) (env ID ${env_id_contender})
68+
* [Benchmark results](<https://esbench-metrics.kb.us-east-2.aws.elastic-cloud.com:9243/app/dashboards#/view/d9079962-5866-49ef-b9f5-145f2141cd31?_a=(query:(language:kuery,query:'user-tags.env-id:${env_id_baseline} or user-tags.env-id:${env_id_contender}'))>)
69+
_EOF3_
70+
_EOF2_

.buildkite/scripts/periodic.trigger.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -euo pipefail
55
echo "steps:"
66

77
source .buildkite/scripts/branches.sh
8+
source .buildkite/scripts/fwc-branches.sh
89

910
IS_FIRST=true
1011
SKIP_DELAY="${SKIP_DELAY:-false}"
@@ -46,8 +47,7 @@ EOF
4647
branch: "$BRANCH"
4748
commit: "$LAST_GOOD_COMMIT"
4849
EOF
49-
# Include forward compatibility tests only for the bugfix branch
50-
if [[ "${BRANCH}" == "${BRANCHES[2]}" ]]; then
50+
if shouldRunFwcFor "$BRANCH"; then
5151
cat <<EOF
5252
- trigger: elasticsearch-periodic-fwc
5353
label: Trigger periodic-fwc pipeline for $BRANCH

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

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/main/groovy/elasticsearch.fwc-test.gradle

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,23 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
import org.elasticsearch.gradle.VersionProperties
10+
import org.elasticsearch.gradle.Version
1111
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
1212

13-
def fwcVersions = buildParams.bwcVersions.released.findAll { it.major == VersionProperties.elasticsearchVersion.major && it.minor == VersionProperties.elasticsearchVersion.minor }
14-
def previousMinorSnapshot = buildParams.bwcVersions.unreleased.find { it.major == VersionProperties.elasticsearchVersion.major && it.minor == VersionProperties.elasticsearchVersion.minor - 1 }
15-
16-
fwcVersions.each { fwcVersion ->
17-
tasks.register("v${fwcVersion}#fwcTest", StandaloneRestIntegTestTask) {
18-
usesBwcDistribution(previousMinorSnapshot)
19-
usesBwcDistribution(fwcVersion)
20-
systemProperty("tests.old_cluster_version", previousMinorSnapshot)
21-
systemProperty("tests.new_cluster_version", fwcVersion)
22-
nonInputProperties.systemProperty 'tests.fwc', 'true'
13+
Version elasticsearchVersion = Version.fromString(versions.get("elasticsearch"))
14+
def fwcVersions = buildParams.bwcVersions.released.findAll { it.major == elasticsearchVersion.major && it.minor == elasticsearchVersion.minor }
15+
def targetMajor = elasticsearchVersion.minor > 0 ? elasticsearchVersion.major : elasticsearchVersion.major - 1
16+
def targetMinor = elasticsearchVersion.minor > 0 ? elasticsearchVersion.minor - 1 : buildParams.bwcVersions.unreleased.findAll { it.major == targetMajor }*.minor.max()
17+
def previousMinorSnapshot = buildParams.bwcVersions.unreleased.find { it.major == targetMajor && it.minor == targetMinor }
18+
if (previousMinorSnapshot != null) {
19+
fwcVersions.each { fwcVersion ->
20+
tasks.register("v${fwcVersion}#fwcTest", StandaloneRestIntegTestTask) {
21+
usesBwcDistribution(previousMinorSnapshot)
22+
usesBwcDistribution(fwcVersion)
23+
systemProperty("tests.old_cluster_version", previousMinorSnapshot)
24+
systemProperty("tests.new_cluster_version", fwcVersion)
25+
nonInputProperties.systemProperty 'tests.fwc', 'true'
26+
}
2327
}
2428
}
2529

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.gradle.api.Project;
2525
import org.gradle.api.Task;
2626
import org.gradle.api.artifacts.Configuration;
27+
import org.gradle.api.configuration.BuildFeatures;
2728
import org.gradle.api.file.FileCollection;
2829
import org.gradle.api.plugins.JavaPlugin;
2930
import org.gradle.api.provider.ProviderFactory;
@@ -56,6 +57,9 @@ public abstract class ElasticsearchTestBasePlugin implements Plugin<Project> {
5657
@Inject
5758
protected abstract ProviderFactory getProviderFactory();
5859

60+
@Inject
61+
protected abstract BuildFeatures getBuildFeatures();
62+
5963
@Override
6064
public void apply(Project project) {
6165
project.getRootProject().getPlugins().apply(GlobalBuildInfoPlugin.class);
@@ -164,9 +168,11 @@ public void execute(Task t) {
164168
);
165169
test.systemProperties(sysprops);
166170

167-
// ignore changing test seed when build is passed -Dignore.tests.seed for cacheability experimentation
168-
if (System.getProperty("ignore.tests.seed") != null) {
169-
nonInputProperties.systemProperty("tests.seed", buildParams.get().getTestSeed());
171+
// ignore changing test seed when build is passed -Dignore.tests.seed for cacheability
172+
// also ignore when configuration cache is on since the test seed as task input would break
173+
// configuration cache reuse.
174+
if (System.getProperty("ignore.tests.seed") != null || getBuildFeatures().getConfigurationCache().getActive().get()) {
175+
nonInputProperties.systemProperty("tests.seed", buildParams.get().getTestSeedProvider());
170176
} else {
171177
test.systemProperty("tests.seed", buildParams.get().getTestSeed());
172178
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public interface BuildParameterExtension {
5656

5757
String getTestSeed();
5858

59+
Provider<String> getTestSeedProvider();
60+
5961
Boolean getCi();
6062

6163
Integer getDefaultParallel();
@@ -66,7 +68,7 @@ public interface BuildParameterExtension {
6668

6769
Provider<BwcVersions> getBwcVersionsProvider();
6870

69-
Random getRandom();
71+
Provider<Random> getRandom();
7072

7173
Boolean getGraalVmRuntime();
7274
}

0 commit comments

Comments
 (0)