Skip to content

Commit 1bc6e9b

Browse files
migrate libbeat pipeline (#37725) (#37900)
(cherry picked from commit 625ba40) Co-authored-by: sharbuz <[email protected]>
1 parent c608645 commit 1bc6e9b

10 files changed

+252
-117
lines changed

.buildkite/hooks/pre-command

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if [[ "$BUILDKITE_PIPELINE_SLUG" == "filebeat" ]]; then
1616
fi
1717
fi
1818

19-
if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-metricbeat" ]]; then
19+
if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-metricbeat" || "$BUILDKITE_PIPELINE_SLUG" == "beats-libbeat" ]]; then
2020
source .buildkite/scripts/setenv.sh
2121
if [[ "${BUILDKITE_COMMAND}" =~ ^buildkite-agent ]]; then
2222
echo "Skipped pre-command when running the Upload pipeline"
+42-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
11
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
22

3+
env:
4+
IMAGE_UBUNTU_X86_64: "family/core-ubuntu-2204"
5+
IMAGE_UBUNTU_ARM_64: "core-ubuntu-2004-aarch64"
6+
GCP_DEFAULT_MACHINE_TYPE: "c2d-highcpu-8"
7+
GCP_HI_PERF_MASHINE_TYPE: "c2d-highcpu-16"
8+
GCP_WIN_MACHINE_TYPE: "n2-standard-8"
9+
AWS_ARM_INSTANCE_TYPE: "t4g.xlarge"
10+
BEATS_PROJECT_NAME: "libbeat"
11+
312
steps:
4-
- label: "Example test"
5-
command: echo "Hello!"
13+
14+
- input: "Input Parameters"
15+
key: "input-run-all-stages"
16+
fields:
17+
- select: "Libbeat - runLibbeat"
18+
key: "runLibbeat"
19+
options:
20+
- label: "True"
21+
value: "true"
22+
- label: "False"
23+
value: "false"
24+
default: "false"
25+
- select: "Libbeat - runLibBeatArmTest"
26+
key: "runLibBeatArmTest"
27+
options:
28+
- label: "True"
29+
value: "true"
30+
- label: "False"
31+
value: "false"
32+
default: "false"
33+
if: "build.source == 'ui'"
34+
35+
- wait: ~
36+
if: "build.source == 'ui'"
37+
allow_dependency_failure: false
38+
39+
- label: ":linux: Load dynamic Libbeat pipeline"
40+
key: "libbeat-pipeline"
41+
command: ".buildkite/scripts/generate_libbeat_pipeline.sh"
42+
agents:
43+
provider: "gcp"
44+
image: "${IMAGE_UBUNTU_X86_64}"
45+
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"

.buildkite/metricbeat/pipeline.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,27 @@ env:
1010
IMAGE_MACOS_X86_64: "generic-13-ventura-x64"
1111
GO_AGENT_IMAGE: "golang:${GO_VERSION}"
1212
BEATS_PROJECT_NAME: "metricbeat"
13+
GCP_DEFAULT_MACHINE_TYPE: "c2d-highcpu-8"
14+
GCP_HI_PERF_MASHINE_TYPE: "c2d-highcpu-16"
15+
GCP_WIN_MACHINE_TYPE: "n2-standard-8"
16+
AWS_ARM_INSTANCE_TYPE: "t4g.xlarge"
17+
1318

1419
steps:
1520

1621
- input: "Input Parameters"
17-
key: "input-run-all-stages"
22+
key: "runMetricbeat"
1823
fields:
19-
- select: "Metricbeat - runAllStages"
20-
key: "runAllStages"
24+
- select: "Metricbeat - runMetricbeat"
25+
key: "runMetricbeat"
2126
options:
2227
- label: "True"
2328
value: "true"
2429
- label: "False"
2530
value: "false"
2631
default: "false"
27-
- select: "Metricbeat - runMacOsTests"
28-
key: "UI_MACOS_TESTS"
32+
- select: "Metricbeat - runMetricbeatMacOsTests"
33+
key: "runMetricbeatMacOsTests"
2934
options:
3035
- label: "True"
3136
value: "true"
@@ -44,3 +49,4 @@ steps:
4449
agents:
4550
provider: "gcp"
4651
image: "${IMAGE_UBUNTU_X86_64}"
52+
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"

.buildkite/scripts/common.sh

+37-44
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
set -euo pipefail
33

44
WORKSPACE=${WORKSPACE:-"$(pwd)"}
@@ -8,8 +8,11 @@ platform_type_lowercase=$(echo "$platform_type" | tr '[:upper:]' '[:lower:]')
88
arch_type="$(uname -m)"
99
GITHUB_PR_TRIGGER_COMMENT=${GITHUB_PR_TRIGGER_COMMENT:-""}
1010
ONLY_DOCS=${ONLY_DOCS:-"true"}
11-
UI_MACOS_TESTS="$(buildkite-agent meta-data get UI_MACOS_TESTS --default ${UI_MACOS_TESTS:-"false"})"
12-
runAllStages="$(buildkite-agent meta-data get runAllStages --default ${runAllStages:-"false"})"
11+
runLibbeat="$(buildkite-agent meta-data get runLibbeat --default ${runLibbeat:-"false"})"
12+
runMetricbeat="$(buildkite-agent meta-data get runMetricbeat --default ${runMetricbeat:-"false"})"
13+
runLibBeatArmTest="$(buildkite-agent meta-data get runLibbeat --default ${runLibbeat:-"false"})"
14+
runMetricbeatMacOsTests="$(buildkite-agent meta-data get runMetricbeatMacOsTests --default ${runMetricbeatMacOsTests:-"false"})"
15+
1316
metricbeat_changeset=(
1417
"^metricbeat/.*"
1518
"^go.mod"
@@ -175,64 +178,54 @@ are_changed_only_paths() {
175178
local changed_files=$(git diff --name-only HEAD@{1} HEAD)
176179
if [ -z "$changed_files" ] || grep -qE "$(IFS=\|; echo "${patterns[*]}")" <<< "$changed_files"; then
177180
return 0
178-
else
179-
return 1
180181
fi
182+
return 1
181183
}
182184

183185
are_conditions_met_mandatory_tests() {
184-
if [[ "${BUILDKITE_PULL_REQUEST}" == "" ]] || [[ "${runAllStages}" == "true" ]] || [[ "${ONLY_DOCS}" == "false" && "${BUILDKITE_PULL_REQUEST}" != "" ]]; then # from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L107-L137
185-
if are_paths_changed "${metricbeat_changeset[@]}" || are_paths_changed "${oss_changeset[@]}" || are_paths_changed "${ci_changeset[@]}" || [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test metricbeat" ]] || [[ "${GITHUB_PR_LABELS}" =~ Metricbeat ]]; then # from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/metricbeat/Jenkinsfile.yml#L3-L12
186-
return 0
187-
else
188-
return 1
186+
if are_paths_changed "${metricbeat_changeset[@]}" || are_paths_changed "${oss_changeset[@]}" || are_paths_changed "${ci_changeset[@]}" ]]; then # from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/metricbeat/Jenkinsfile.yml#L3-L12
187+
if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-metricbeat" ]]; then
188+
if [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test metricbeat" || "${GITHUB_PR_LABELS}" =~ Metricbeat || "${runMetricbeat}" == "true" ]]; then
189+
return 0
190+
fi
191+
elif [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-libbeat" ]]; then
192+
if [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test libbeat" || "${GITHUB_PR_LABELS}" =~ libbeat || "${runLibbeat}" == "true" ]]; then
193+
return 0
194+
fi
189195
fi
190-
else
191-
return 1
192196
fi
197+
return 1
193198
}
194199

195-
are_conditions_met_extended_tests() {
200+
are_conditions_met_libbeat_arm_tests() {
196201
if are_conditions_met_mandatory_tests; then #from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L145-L171
197-
return 0
198-
else
199-
return 1
202+
if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-libbeat" ]]; then
203+
if [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test libbeat for arm" || "${GITHUB_PR_LABELS}" =~ arm || "${runLibBeatArmTest}" == "true" ]]; then
204+
return 0
205+
fi
206+
fi
200207
fi
208+
return 1
201209
}
202210

203-
are_conditions_met_macos_tests() {
204-
if are_conditions_met_mandatory_tests; then #from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L145-L171
205-
if [[ "${UI_MACOS_TESTS}" == true ]] || [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test metricbeat for macos" ]] || [[ "${GITHUB_PR_LABELS}" =~ macOS ]]; then # from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/metricbeat/Jenkinsfile.yml#L3-L12
206-
return 0
207-
else
208-
return 1
209-
fi
210-
else
211-
return 1
211+
are_conditions_met_metricbeat_macos_tests() {
212+
if [[ "${runMetricbeatMacOsTests}" == true ]] || [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test metricbeat for macos" ]] || [[ "${GITHUB_PR_LABELS}" =~ macOS ]]; then # from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/metricbeat/Jenkinsfile.yml#L3-L12
213+
return 0
212214
fi
215+
return 1
213216
}
214217

215-
are_conditions_met_extended_windows_tests() {
216-
if [[ "${ONLY_DOCS}" == "false" && "${BUILDKITE_PULL_REQUEST}" != "" ]] || [[ "${runAllStages}" == "true" ]]; then #from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L145-L171
217-
if are_paths_changed "${metricbeat_changeset[@]}" || are_paths_changed "${oss_changeset[@]}" || are_paths_changed "${ci_changeset[@]}" || [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test metricbeat" ]] || [[ "${GITHUB_PR_LABELS}" =~ Metricbeat ]]; then # from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/metricbeat/Jenkinsfile.yml#L3-L12
218-
return 0
219-
else
220-
return 1
221-
fi
222-
else
223-
return 1
218+
are_conditions_met_packaging() {
219+
if are_paths_changed "${metricbeat_changeset[@]}" || are_paths_changed "${oss_changeset[@]}" || [[ "${BUILDKITE_TAG}" == "" ]] || [[ "${BUILDKITE_PULL_REQUEST}" != "" ]]; then # from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/metricbeat/Jenkinsfile.yml#L101-L103
220+
return 0
224221
fi
222+
return 1
225223
}
226224

227-
are_conditions_met_packaging() {
228-
if are_conditions_met_extended_windows_tests; then #from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L145-L171
229-
if are_paths_changed "${metricbeat_changeset[@]}" || are_paths_changed "${oss_changeset[@]}" || [[ "${BUILDKITE_TAG}" == "" ]] || [[ "${BUILDKITE_PULL_REQUEST}" != "" ]]; then # from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/metricbeat/Jenkinsfile.yml#L101-L103
230-
return 0
231-
else
232-
return 1
233-
fi
234-
else
235-
return 1
225+
config_git() {
226+
if [ -z "$(git config --get user.email)" ]; then
227+
git config --global user.email "[email protected]"
228+
git config --global user.name "beatsmachine"
236229
fi
237230
}
238231

@@ -249,4 +242,4 @@ fi
249242

250243
if are_paths_changed "${packaging_changeset[@]}" ; then
251244
PACKAGING_CHANGES="true"
252-
fi
245+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env bash
2+
3+
source .buildkite/scripts/common.sh
4+
5+
set -euo pipefail
6+
7+
pipelineName="pipeline.libbeat-dynamic.yml"
8+
9+
echo "Add the mandatory and extended tests without additional conditions into the pipeline"
10+
if are_conditions_met_mandatory_tests; then
11+
cat > $pipelineName <<- YAML
12+
13+
steps:
14+
15+
- group: "Mandatory Tests"
16+
key: "mandatory-tests"
17+
steps:
18+
- label: ":linux: Ubuntu Unit Tests"
19+
key: "mandatory-linux-unit-test"
20+
command: ".buildkite/scripts/unit_tests.sh"
21+
agents:
22+
provider: "gcp"
23+
image: "${IMAGE_UBUNTU_X86_64}"
24+
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
25+
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.xml"
26+
27+
- label: ":go: Go Integration Tests"
28+
key: "mandatory-int-test"
29+
command: ".buildkite/scripts/go_int_tests.sh"
30+
agents:
31+
provider: "gcp"
32+
image: "${IMAGE_UBUNTU_X86_64}"
33+
machineType: "${GCP_HI_PERF_MASHINE_TYPE}"
34+
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.xml"
35+
36+
- label: ":python: Python Integration Tests"
37+
key: "mandatory-python-int-test"
38+
command: ".buildkite/scripts/py_int_tests.sh"
39+
agents:
40+
provider: "gcp"
41+
image: "${IMAGE_UBUNTU_X86_64}"
42+
machineType: "${GCP_HI_PERF_MASHINE_TYPE}"
43+
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.xml"
44+
45+
- label: ":negative_squared_cross_mark: Cross compile"
46+
key: "mandatory-cross-compile"
47+
command: ".buildkite/scripts/crosscompile.sh"
48+
agents:
49+
provider: "gcp"
50+
image: "${IMAGE_UBUNTU_X86_64}"
51+
machineType: "${GCP_HI_PERF_MASHINE_TYPE}"
52+
artifact_paths: " ${BEATS_PROJECT_NAME}/build/*.xml"
53+
54+
- label: ":testengine: Stress Tests"
55+
key: "mandatory-stress-test"
56+
command: ".buildkite/scripts/stress_tests.sh"
57+
agents:
58+
provider: "gcp"
59+
image: "${IMAGE_UBUNTU_X86_64}"
60+
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
61+
artifact_paths: "${BEATS_PROJECT_NAME}/libbeat-stress-test.xml"
62+
63+
YAML
64+
fi
65+
66+
echo "Check and add the Extended Tests into the pipeline"
67+
if are_conditions_met_libbeat_arm_tests; then
68+
cat >> $pipelineName <<- YAML
69+
70+
- group: "Extended Tests"
71+
key: "extended-tests"
72+
steps:
73+
- label: ":linux: Arm64 Unit Tests"
74+
key: "extended-arm64-unit-tests"
75+
command: ".buildkite/scripts/unit_tests.sh"
76+
agents:
77+
provider: "aws"
78+
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
79+
instanceType: "${AWS_ARM_INSTANCE_TYPE}"
80+
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.xml"
81+
82+
YAML
83+
fi
84+
85+
echo "--- Printing dynamic steps" #TODO: remove if the pipeline is public
86+
cat $pipelineName
87+
88+
echo "--- Loading dynamic steps"
89+
buildkite-agent pipeline upload $pipelineName

0 commit comments

Comments
 (0)