Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate libbeat pipeline #37725

Merged
merged 62 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
d85e193
migrate libbeat pipeline
Jan 24, 2024
35fa203
migrate libbeat pipeline
Jan 24, 2024
ac9ac7b
add hooks
Jan 24, 2024
8efb4f0
fix go-int tests
Jan 24, 2024
70bfa4e
fix go-int tests
Jan 25, 2024
9f5fd0d
revert mage dumpVariables
Jan 25, 2024
e76a97a
debug
Jan 25, 2024
bbe62dc
debug
Jan 25, 2024
4b9b801
debug
Jan 25, 2024
857f48d
debug
Jan 25, 2024
36ffb33
debug
Jan 25, 2024
22f4455
debug
Jan 25, 2024
e64c72c
debug Go Int Tests
Jan 25, 2024
6c1747f
debug Go Int Tests
Jan 25, 2024
6180a26
debug Go Int Tests
Jan 25, 2024
8282de0
debug Go Int Tests
Jan 25, 2024
01a3e61
debug Go Int Tests
Jan 25, 2024
383320e
full test
Jan 25, 2024
d95c25f
debug Python Int Tests
Jan 25, 2024
c1b2b35
debug Crosscompile
Jan 25, 2024
d688a5c
debug Crosscompile
Jan 25, 2024
7ab9718
debug Crosscompile
Jan 25, 2024
b23fc85
debug Crosscompile
Jan 25, 2024
dec018c
debug Crosscompile
Jan 25, 2024
3ffa0e7
full test
Jan 26, 2024
dff6341
Merge branch 'main' of github.com:sharbuz/beats into migrate-libbeat-…
Jan 26, 2024
0d5c9f8
debug stress tests
Jan 26, 2024
1fe6f20
debug stress tests
Jan 26, 2024
4af8233
debug stress tests
Jan 26, 2024
d1e5d55
full test
Jan 26, 2024
87ce234
full test
Jan 26, 2024
d684936
full test
Jan 26, 2024
da7b08a
full test - changed crosscompile options
Jan 26, 2024
0cf08cd
updates artifacts paths
Jan 29, 2024
ae8c545
Merge branch 'main' of github.com:sharbuz/beats into migrate-libbeat-…
Feb 3, 2024
9aa7c6c
conflict solving
Feb 3, 2024
411d9d4
change pre-command
Feb 3, 2024
708000d
add BEATS_PROJECT_NAME
Feb 3, 2024
af0b962
refactor libbeat
Feb 5, 2024
a562733
refactor libbeat/metricbeat conditions
Feb 5, 2024
b4efe61
fix dinamyc libbeat pipeline
Feb 5, 2024
6cd9880
change metricbeat dunamyc pipeline
Feb 5, 2024
a2c8826
full test
Feb 5, 2024
e03d2b3
full test
Feb 5, 2024
823a27c
full test
Feb 5, 2024
b1155e8
update catalog-info.yaml
Feb 5, 2024
0c4becf
change the instance type and fix typos
Feb 5, 2024
ca6c241
change instance types to c2d-highcpu-16
Feb 5, 2024
82ebbfa
Merge branch 'main' of github.com:sharbuz/beats into migrate-libbeat-…
Feb 5, 2024
3774483
change instance type for packaging
Feb 5, 2024
d5194bf
Update catalog-info.yaml
sharbuz Feb 6, 2024
f3317c6
fix remarks
Feb 6, 2024
b96a16c
Merge branch 'migrate-libbeat-pipeline' of github.com:sharbuz/beats i…
Feb 6, 2024
f151f98
revert makifile changes
Feb 6, 2024
6e57804
Merge branch 'main' into migrate-libbeat-pipeline
sharbuz Feb 6, 2024
6ee43ff
Update catalog-info.yaml
sharbuz Feb 6, 2024
5aaf276
Merge branch 'main' into migrate-libbeat-pipeline
sharbuz Feb 6, 2024
e2a2afb
windows 10 test
Feb 6, 2024
5d5ceb8
Merge branch 'migrate-libbeat-pipeline' of github.com:sharbuz/beats i…
Feb 6, 2024
adf168a
Merge branch 'main' into migrate-libbeat-pipeline
sharbuz Feb 6, 2024
5bfd917
Merge branch 'main' into migrate-libbeat-pipeline
sharbuz Feb 6, 2024
b272833
Merge branch 'main' into migrate-libbeat-pipeline
sharbuz Feb 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [[ "$BUILDKITE_PIPELINE_SLUG" == "filebeat" || "$BUILDKITE_PIPELINE_SLUG" ==
fi
fi

if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-metricbeat" ]]; then
if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-metricbeat" || "$BUILDKITE_PIPELINE_SLUG" == "beats-libbeat" ]]; then
source .buildkite/scripts/setenv.sh
if [[ "${BUILDKITE_COMMAND}" =~ ^buildkite-agent ]]; then
echo "Skipped pre-command when running the Upload pipeline"
Expand Down
44 changes: 42 additions & 2 deletions .buildkite/libbeat/pipeline.libbeat.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json

env:
IMAGE_UBUNTU_X86_64: "family/core-ubuntu-2204"
IMAGE_UBUNTU_ARM_64: "core-ubuntu-2004-aarch64"
GCP_DEFAULT_MACHINE_TYPE: "c2d-highcpu-8"
GCP_HI_PERF_MASHINE_TYPE: "c2d-highcpu-16"
GCP_WIN_MACHINE_TYPE: "n2-standard-8"
AWS_ARM_INSTANCE_TYPE: "t4g.xlarge"
BEATS_PROJECT_NAME: "libbeat"

steps:
- label: "Example test"
command: echo "Hello!"

- input: "Input Parameters"
key: "input-run-all-stages"
fields:
- select: "Libbeat - runLibbeat"
key: "runLibbeat"
options:
- label: "True"
value: "true"
- label: "False"
value: "false"
default: "false"
- select: "Libbeat - runLibBeatArmTest"
key: "runLibBeatArmTest"
options:
- label: "True"
value: "true"
- label: "False"
value: "false"
default: "false"
if: "build.source == 'ui'"

- wait: ~
if: "build.source == 'ui'"
allow_dependency_failure: false

- label: ":linux: Load dynamic Libbeat pipeline"
key: "libbeat-pipeline"
command: ".buildkite/scripts/generate_libbeat_pipeline.sh"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
16 changes: 11 additions & 5 deletions .buildkite/metricbeat/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,27 @@ env:
IMAGE_MACOS_X86_64: "generic-13-ventura-x64"
GO_AGENT_IMAGE: "golang:${GO_VERSION}"
BEATS_PROJECT_NAME: "metricbeat"
GCP_DEFAULT_MACHINE_TYPE: "c2d-highcpu-8"
GCP_HI_PERF_MASHINE_TYPE: "c2d-highcpu-16"
GCP_WIN_MACHINE_TYPE: "n2-standard-8"
AWS_ARM_INSTANCE_TYPE: "t4g.xlarge"


steps:

- input: "Input Parameters"
key: "input-run-all-stages"
key: "runMetricbeat"
fields:
- select: "Metricbeat - runAllStages"
key: "runAllStages"
- select: "Metricbeat - runMetricbeat"
key: "runMetricbeat"
options:
- label: "True"
value: "true"
- label: "False"
value: "false"
default: "false"
- select: "Metricbeat - runMacOsTests"
key: "UI_MACOS_TESTS"
- select: "Metricbeat - runMetricbeatMacOsTests"
key: "runMetricbeatMacOsTests"
options:
- label: "True"
value: "true"
Expand All @@ -44,3 +49,4 @@ steps:
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
81 changes: 37 additions & 44 deletions .buildkite/scripts/common.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

WORKSPACE=${WORKSPACE:-"$(pwd)"}
Expand All @@ -8,8 +8,11 @@ platform_type_lowercase=$(echo "$platform_type" | tr '[:upper:]' '[:lower:]')
arch_type="$(uname -m)"
GITHUB_PR_TRIGGER_COMMENT=${GITHUB_PR_TRIGGER_COMMENT:-""}
ONLY_DOCS=${ONLY_DOCS:-"true"}
UI_MACOS_TESTS="$(buildkite-agent meta-data get UI_MACOS_TESTS --default ${UI_MACOS_TESTS:-"false"})"
runAllStages="$(buildkite-agent meta-data get runAllStages --default ${runAllStages:-"false"})"
runLibbeat="$(buildkite-agent meta-data get runLibbeat --default ${runLibbeat:-"false"})"
runMetricbeat="$(buildkite-agent meta-data get runMetricbeat --default ${runMetricbeat:-"false"})"
runLibBeatArmTest="$(buildkite-agent meta-data get runLibbeat --default ${runLibbeat:-"false"})"
runMetricbeatMacOsTests="$(buildkite-agent meta-data get runMetricbeatMacOsTests --default ${runMetricbeatMacOsTests:-"false"})"

metricbeat_changeset=(
"^metricbeat/.*"
"^go.mod"
Expand Down Expand Up @@ -175,64 +178,54 @@ are_changed_only_paths() {
local changed_files=$(git diff --name-only HEAD@{1} HEAD)
if [ -z "$changed_files" ] || grep -qE "$(IFS=\|; echo "${patterns[*]}")" <<< "$changed_files"; then
return 0
else
return 1
fi
return 1
}

are_conditions_met_mandatory_tests() {
if [[ "${BUILDKITE_PULL_REQUEST}" == "" ]] || [[ "${runAllStages}" == "true" ]] || [[ "${ONLY_DOCS}" == "false" && "${BUILDKITE_PULL_REQUEST}" != "" ]]; then # from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L107-L137
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
return 0
else
return 1
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
if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-metricbeat" ]]; then
if [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test metricbeat" || "${GITHUB_PR_LABELS}" =~ Metricbeat || "${runMetricbeat}" == "true" ]]; then
return 0
fi
elif [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-libbeat" ]]; then
if [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test libbeat" || "${GITHUB_PR_LABELS}" =~ libbeat || "${runLibbeat}" == "true" ]]; then
return 0
fi
fi
else
return 1
fi
return 1
}

are_conditions_met_extended_tests() {
are_conditions_met_libbeat_arm_tests() {
if are_conditions_met_mandatory_tests; then #from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L145-L171
return 0
else
return 1
if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-libbeat" ]]; then
if [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test libbeat for arm" || "${GITHUB_PR_LABELS}" =~ arm || "${runLibBeatArmTest}" == "true" ]]; then
return 0
fi
fi
fi
return 1
}

are_conditions_met_macos_tests() {
if are_conditions_met_mandatory_tests; then #from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L145-L171
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
return 0
else
return 1
fi
else
return 1
are_conditions_met_metricbeat_macos_tests() {
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
return 0
fi
return 1
}

are_conditions_met_extended_windows_tests() {
if [[ "${ONLY_DOCS}" == "false" && "${BUILDKITE_PULL_REQUEST}" != "" ]] || [[ "${runAllStages}" == "true" ]]; then #from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L145-L171
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
return 0
else
return 1
fi
else
return 1
are_conditions_met_packaging() {
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
return 0
fi
return 1
}

are_conditions_met_packaging() {
if are_conditions_met_extended_windows_tests; then #from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L145-L171
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
return 0
else
return 1
fi
else
return 1
config_git() {
if [ -z "$(git config --get user.email)" ]; then
git config --global user.email "beatsmachine@users.noreply.github.com"
git config --global user.name "beatsmachine"
fi
}

Expand All @@ -249,4 +242,4 @@ fi

if are_paths_changed "${packaging_changeset[@]}" ; then
PACKAGING_CHANGES="true"
fi
fi
89 changes: 89 additions & 0 deletions .buildkite/scripts/generate_libbeat_pipeline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env bash

source .buildkite/scripts/common.sh

set -euo pipefail

pipelineName="pipeline.libbeat-dynamic.yml"

echo "Add the mandatory and extended tests without additional conditions into the pipeline"
if are_conditions_met_mandatory_tests; then
cat > $pipelineName <<- YAML
steps:
- group: "Mandatory Tests"
key: "mandatory-tests"
steps:
- label: ":linux: Ubuntu Unit Tests"
key: "mandatory-linux-unit-test"
command: ".buildkite/scripts/unit_tests.sh"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
sharbuz marked this conversation as resolved.
Show resolved Hide resolved
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.xml"
- label: ":go: Go Integration Tests"
key: "mandatory-int-test"
command: ".buildkite/scripts/go_int_tests.sh"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_HI_PERF_MASHINE_TYPE}"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.xml"
- label: ":python: Python Integration Tests"
key: "mandatory-python-int-test"
command: ".buildkite/scripts/py_int_tests.sh"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_HI_PERF_MASHINE_TYPE}"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.xml"
- label: ":negative_squared_cross_mark: Cross compile"
key: "mandatory-cross-compile"
command: ".buildkite/scripts/crosscompile.sh"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_HI_PERF_MASHINE_TYPE}"
artifact_paths: " ${BEATS_PROJECT_NAME}/build/*.xml"
- label: ":testengine: Stress Tests"
key: "mandatory-stress-test"
command: ".buildkite/scripts/stress_tests.sh"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
artifact_paths: "${BEATS_PROJECT_NAME}/libbeat-stress-test.xml"
YAML
fi

echo "Check and add the Extended Tests into the pipeline"
if are_conditions_met_libbeat_arm_tests; then
cat >> $pipelineName <<- YAML
- group: "Extended Tests"
key: "extended-tests"
steps:
- label: ":linux: Arm64 Unit Tests"
key: "extended-arm64-unit-tests"
command: ".buildkite/scripts/unit_tests.sh"
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "${AWS_ARM_INSTANCE_TYPE}"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.xml"
YAML
fi

echo "--- Printing dynamic steps" #TODO: remove if the pipeline is public
cat $pipelineName

echo "--- Loading dynamic steps"
buildkite-agent pipeline upload $pipelineName
Loading
Loading