Skip to content

Commit 9aeacc6

Browse files
authored
Separete branches in ci (#184)
* Use target branch in build CI. Properly name the CI jobs. * Add unit test and integration tests on LS 8.x snapshot ES main branch. * Add the target branch to the E2E tests for LS 8.x * Add a step to E2E to cover LS snapshot vs ES main. * Use multi-jdk BK agent and use JDK version properly in E2E pipeline. * Add explanation comments for each jobs of each CI.
1 parent 95fd1d1 commit 9aeacc6

File tree

5 files changed

+144
-21
lines changed

5 files changed

+144
-21
lines changed

.buildkite/build-pipeline.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,41 @@ agents:
66
image: family/core-ubuntu-2204
77

88
steps:
9-
# ------------- Build with ES released versions ---------------------
10-
# 8.x + (SNAPSHOT=FALSE) -> treeish: v8.11.1 artifact: 8.11.1
11-
- label: ":hammer: Build plugin with released Elasticsearch version :elasticsearch:"
9+
- label: ":hammer: Build plugin with LS & ES 8.x :elasticsearch:"
10+
# Builds with LS and ES last 8.x released version
11+
# Runs integration tests on 8.x released versions
1212
command:
1313
- .buildkite/scripts/run_tests.sh
1414
env:
1515
ELASTIC_STACK_VERSION: "8.x"
1616
SNAPSHOT: false
1717
INTEGRATION: true
1818
SECURE_INTEGRATION: true
19+
TARGET_BRANCH: "8.x"
20+
# temporary definition to cover PR-170
21+
# TODO: remove once 8.16 released
22+
ELASTICSEARCH_TREEISH: 8.16
1923

20-
# ------------- Build with ES snapshot versions and main branch ---------------------
21-
# main + (SNAPSHOT=TRUE) -> treeish: main artifact:8.12.0-SNAPSHOT
22-
- label: ":hammer: Build plugin with Elasticsearch snapshot versions and `main` branch :elasticsearch:"
24+
- label: ":hammer: Build plugin with LS 8.x-SNAPSHOT & ES `main` branch :elasticsearch:"
25+
# Builds with LS last 8.x released version and ES main
26+
# Runs integration tests on 8.x released versions
2327
command:
2428
- .buildkite/scripts/run_tests.sh
2529
env:
2630
ELASTIC_STACK_VERSION: "8.x"
2731
ELASTICSEARCH_TREEISH: "main"
2832
SNAPSHOT: true
2933
INTEGRATION: true
34+
SECURE_INTEGRATION: true
35+
36+
- label: ":hammer: Build plugin with LS & ES `main` branch :elasticsearch:"
37+
# Builds with LS last 8.x released version and ES main
38+
# Runs integration tests on 8.x released versions
39+
command:
40+
- .buildkite/scripts/run_tests.sh
41+
env:
42+
ELASTIC_STACK_VERSION: "main"
43+
ELASTICSEARCH_TREEISH: "main"
44+
SNAPSHOT: true
45+
INTEGRATION: true
3046
SECURE_INTEGRATION: true

.buildkite/e2e-pipeline.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,36 @@
33
agents:
44
provider: gcp
55
imageProject: elastic-images-prod
6-
image: family/platform-ingest-logstash-ubuntu-2204
6+
image: family/platform-ingest-logstash-multi-jdk-ubuntu-2204
77
machineType: "n2-standard-4"
88
diskSizeGb: 120
99

1010
steps:
1111
# ------------- Run E2E tests ---------------------
12-
- label: ":test_tube: Build plugin and run E2E tests :rocket:"
12+
- label: ":test_tube: Run E2E tests with LS 8.x :rocket:"
13+
# uses the LS main & plugin 8.x branch when building the plugin
14+
# Runs integration tests against 8.x release version
1315
command:
1416
- .buildkite/scripts/run_e2e_tests.sh
1517
env:
16-
ELASTIC_STACK_VERSION: "8.x"
18+
ELASTIC_STACK_VERSION: "8.x"
19+
TARGET_BRANCH: "8.x"
20+
21+
- label: ":test_tube: Run E2E tests with LS 8.x-SNAPSHOT :rocket:"
22+
# uses the LS & plugin main branch when building the plugin
23+
# Runs integration tests against 8.x-SNAPSHOT version
24+
command:
25+
- .buildkite/scripts/run_e2e_tests.sh
26+
env:
27+
ELASTIC_STACK_VERSION: "8.x"
28+
SNAPSHOT: true
29+
30+
- label: ":test_tube: Run E2E tests with LS `main` :rocket:"
31+
# uses the LS & plugin main branch when building the plugin
32+
# Runs integration tests against snapshot.main of https://raw.githubusercontent.com/elastic/logstash/main/ci/logstash_releases.json
33+
command:
34+
- .buildkite/scripts/run_e2e_tests.sh
35+
env:
36+
ELASTIC_STACK_VERSION: main
37+
SNAPSHOT: true
38+
ELASTICSEARCH_TREEISH: main

.buildkite/pull-request-pipeline.yml

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,31 @@ agents:
66

77
steps:
88
# ------------- Unit tests ---------------------
9-
- label: ":hammer: CI setup and unit tests run :docker:"
9+
- label: ":hammer: Unit tests with LS & ES 8.x-SNAPSHOT :docker:"
10+
# Builds the plugin (with current changes) against LS 8.x-SNAPSHOT and ES version defined in gradle.properties
11+
# Runs unit tests on LS & ES 8.x-SNAPSHOT docker
1012
command:
1113
- .buildkite/scripts/run_tests.sh
1214
env:
1315
ELASTIC_STACK_VERSION: "8.x"
16+
SNAPSHOT: true
17+
INTEGRATION: false
18+
19+
- label: ":hammer: Unit tests with LS 8.x-SNAPSHOT & ES main :docker:"
20+
# Builds the plugin (with current changes) against LS 8.x-SNAPSHOT and ES main
21+
# Runs unit tests on LS & ES 8.x-SNAPSHOT docker
22+
command:
23+
- .buildkite/scripts/run_tests.sh
24+
env:
25+
ELASTIC_STACK_VERSION: "8.x"
26+
ELASTICSEARCH_TREEISH: main
1427
INTEGRATION: false
1528
SNAPSHOT: true
1629

1730
# ------------- Integration tests ---------------------
18-
- label: ":hammer: CI setup and integration tests with ES 8.x run on :docker:"
31+
- label: ":hammer: Integration tests with LS & ES 8.x :docker:"
32+
# Builds the plugin (with current changes) against LS 8.x and ES version defined in gradle.properties
33+
# Runs integration tests on LS & ES 8.x docker
1934
command:
2035
- .buildkite/scripts/run_tests.sh
2136
env:
@@ -26,12 +41,40 @@ steps:
2641
# TODO: remove once 8.16 released
2742
ELASTICSEARCH_TREEISH: 8.16
2843

29-
- label: ":hammer: CI setup and integration tests with ES 8.x-SNAPSHOT run on :docker:"
44+
- label: ":hammer: Integration tests with LS & ES 8.x-SNAPSHOT :docker:"
45+
# Builds the plugin (with current changes) against LS 8.x-SNAPSHOT and ES version defined in gradle.properties
46+
# Runs integration tests on LS & ES 8.x-SNAPSHOT docker
47+
command:
48+
- .buildkite/scripts/run_tests.sh
49+
env:
50+
ELASTIC_STACK_VERSION: "8.x"
51+
SNAPSHOT: true
52+
INTEGRATION: true
53+
SECURE_INTEGRATION: true
54+
LOG_LEVEL: "info"
55+
56+
- label: ":hammer: Integration tests with LS 8.x-SNAPSHOT & ES main :docker:"
57+
# Builds the plugin (with current changes) against LS 8.x-SNAPSHOT and ES main
58+
# Runs integration tests on LS & ES 8.x-SNAPSHOT docker
3059
command:
3160
- .buildkite/scripts/run_tests.sh
3261
env:
3362
ELASTIC_STACK_VERSION: "8.x"
63+
ELASTICSEARCH_TREEISH: "main"
64+
SNAPSHOT: true
3465
INTEGRATION: true
66+
SECURE_INTEGRATION: true
3567
LOG_LEVEL: "info"
68+
69+
- label: ":hammer: Integration tests with LS & ES main :docker:"
70+
# Builds the plugin (with current changes) against LS and ES main
71+
# Runs integration tests on snapshot.main of https://raw.githubusercontent.com/elastic/logstash/main/ci/logstash_releases.json
72+
command:
73+
- .buildkite/scripts/run_tests.sh
74+
env:
75+
ELASTIC_STACK_VERSION: main
76+
ELASTICSEARCH_TREEISH: main
77+
SNAPSHOT: true
78+
INTEGRATION: true
3679
SECURE_INTEGRATION: true
37-
SNAPSHOT: true
80+
LOG_LEVEL: "info"

.buildkite/scripts/run_e2e_tests.sh

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,58 @@
22

33
set -euo pipefail
44

5-
export PATH="/opt/buildkite-agent/.rbenv/bin:/opt/buildkite-agent/.pyenv/bin:/opt/buildkite-agent/.java/bin:$PATH"
6-
export JAVA_HOME="/opt/buildkite-agent/.java"
5+
export PATH="/opt/buildkite-agent/.rbenv/bin:/opt/buildkite-agent/.pyenv/bin:$PATH"
76
eval "$(rbenv init -)"
87
eval "$(pyenv init -)"
98

10-
VERSION_URL="https://storage.googleapis.com/artifacts-api/releases/current"
9+
VERSION_URL="https://raw.githubusercontent.com/elastic/logstash/main/ci/logstash_releases.json"
1110

1211
###
1312
# Resolve stack version and export
1413
resolve_current_stack_version() {
1514
set +o nounset
15+
echo "Fetching versions from $VERSION_URL"
16+
VERSIONS=$(curl --retry 5 --retry-delay 5 -fsSL $VERSION_URL)
1617

17-
local major_version="${ELASTIC_STACK_VERSION%%.*}"
18-
local version=$(curl --retry 5 --retry-delay 5 -fsSL "$VERSION_URL/$major_version")
18+
if [[ "$SNAPSHOT" == "true" ]]; then
19+
key=$(echo "$VERSIONS" | jq -r '.snapshots."'"$ELASTIC_STACK_VERSION"'"')
20+
echo "resolved key: $key"
21+
else
22+
key=$(echo "$VERSIONS" | jq -r '.releases."'"$ELASTIC_STACK_VERSION"'"')
23+
fi
1924

20-
echo "Resolved version: $version"
21-
export STACK_VERSION="$version"
25+
echo "Resolved version: $key"
26+
export STACK_VERSION="$key"
2227
}
2328

24-
resolve_current_stack_version
29+
###
30+
# Checkout the target branch if defined
31+
checkout_target_branch() {
32+
set +o nounset
33+
if [ -z "$TARGET_BRANCH" ]; then
34+
echo "Target branch is not specified, using default branch: main or BK defined"
35+
else
36+
echo "Changing the branch for ${TARGET_BRANCH}"
37+
git checkout "$TARGET_BRANCH"
38+
fi
39+
}
40+
41+
set_required_jdk() {
42+
set +o nounset
43+
java_version="$(cat .java-version)"
44+
echo "Required JDK version: $java_version"
45+
if [[ "$java_version" == "17.0" ]]; then
46+
jdk_home="/opt/buildkite-agent/.java/adoptiumjdk_17"
47+
elif [[ "$java_version" == "21.0" ]]; then
48+
jdk_home="/opt/buildkite-agent/.java/adoptiumjdk_21"
49+
else
50+
echo "Unsupported JDK."
51+
exit 1
52+
fi
53+
54+
export JAVA_HOME=$jdk_home
55+
export PATH="$jdk_home:$PATH"
56+
}
2557

2658
###
2759
# Build the plugin, to do so we need Logstash source
@@ -41,6 +73,9 @@ build_plugin() {
4173
./gradlew clean vendor localGem
4274
}
4375

76+
resolve_current_stack_version
77+
checkout_target_branch
78+
set_required_jdk
4479
build_logstash
4580
build_plugin
4681

.buildkite/scripts/run_tests.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@ else
55
echo "Using ELASTICSEARCH_TREEISH ${ELASTICSEARCH_TREEISH} defined in the ENV."
66
fi
77

8+
if [ -z "$TARGET_BRANCH" ]; then
9+
echo "Target branch is not specified, using default branch: main or BK defined"
10+
else
11+
echo "Changing the branch for ${TARGET_BRANCH}"
12+
git checkout "$TARGET_BRANCH"
13+
fi
14+
815
mkdir -p .ci && curl -sL --retry 5 --retry-delay 5 https://github.com/logstash-plugins/.ci/archive/buildkite-1.x.tar.gz | tar zxvf - --skip-old-files --strip-components=1 -C .ci --wildcards '*Dockerfile*' '*docker*' '*.sh' && .ci/docker-setup.sh && .ci/docker-run.sh

0 commit comments

Comments
 (0)