Skip to content

Commit

Permalink
Merge branch 'main' into vpce_endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiyan-sheng authored Mar 18, 2024
2 parents ac2a021 + 093ab5e commit 6e88789
Show file tree
Hide file tree
Showing 52 changed files with 1,591 additions and 98 deletions.
10 changes: 9 additions & 1 deletion .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -euo pipefail

AWS_SERVICE_ACCOUNT_SECRET_PATH="kv/ci-shared/platform-ingest/aws_account_auth"
PRIVATE_CI_GCS_CREDENTIALS_PATH="kv/ci-shared/platform-ingest/gcp-platform-ingest-ci-service-account"

retry() {
local retries=$1
Expand Down Expand Up @@ -33,7 +34,7 @@ if [[ "$BUILDKITE_PIPELINE_SLUG" == "filebeat" || "$BUILDKITE_PIPELINE_SLUG" ==
fi
fi

if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-metricbeat" || "$BUILDKITE_PIPELINE_SLUG" == "beats-libbeat" || "$BUILDKITE_PIPELINE_SLUG" == "beats-packetbeat" || "$BUILDKITE_PIPELINE_SLUG" == "beats-winlogbeat" || "$BUILDKITE_PIPELINE_SLUG" == "beats-xpack-libbeat" || "$BUILDKITE_PIPELINE_SLUG" == "beats-xpack-metricbeat" ]]; then
if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-metricbeat" || "$BUILDKITE_PIPELINE_SLUG" == "beats-libbeat" || "$BUILDKITE_PIPELINE_SLUG" == "beats-packetbeat" || "$BUILDKITE_PIPELINE_SLUG" == "beats-winlogbeat" || "$BUILDKITE_PIPELINE_SLUG" == "beats-xpack-libbeat" || "$BUILDKITE_PIPELINE_SLUG" == "beats-xpack-metricbeat" || "$BUILDKITE_PIPELINE_SLUG" == "beats-xpack-packetbeat" ]]; then
source .buildkite/scripts/setenv.sh
if [[ "${BUILDKITE_COMMAND}" =~ ^buildkite-agent ]]; then
echo "Skipped pre-command when running the Upload pipeline"
Expand All @@ -47,3 +48,10 @@ if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-xpack-metricbeat" && "$BUILDKITE_STEP
BEATS_AWS_ACCESS_KEY=$(retry 5 vault kv get -field access_key ${AWS_SERVICE_ACCOUNT_SECRET_PATH})
export BEATS_AWS_ACCESS_KEY
fi

if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-xpack-packetbeat" ]]; then
if [[ "$BUILDKITE_STEP_KEY" == "extended-win-10-system-tests" || "$BUILDKITE_STEP_KEY" == "mandatory-win-2022-system-tests" ]]; then
PRIVATE_CI_GCS_CREDENTIALS_SECRET=$(retry 5 vault kv get -field plaintext -format=json ${PRIVATE_CI_GCS_CREDENTIALS_PATH})
export PRIVATE_CI_GCS_CREDENTIALS_SECRET
fi
fi
80 changes: 80 additions & 0 deletions .buildkite/pull-requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,86 @@
"skip_target_branches": [ ],
"skip_ci_on_only_changed": [ ],
"always_require_ci_on_changed": ["^x-pack/metricbeat/.*", "^.buildkite/.*", "^go.mod", "^pytest.ini", "^dev-tools/.*", "^libbeat/.*", "^testing/.*", "^x-pack/libbeat/.*"]
},
{
"enabled": true,
"pipelineSlug": "beats-xpack-auditbeat",
"allow_org_users": true,
"allowed_repo_permissions": ["admin", "write"],
"allowed_list": [ ],
"set_commit_status": true,
"build_on_commit": true,
"build_on_comment": true,
"trigger_comment_regex": "^/test x-pack/auditbeat$",
"always_trigger_comment_regex": "^/test x-pack/auditbeat$",
"skip_ci_labels": [ ],
"skip_target_branches": [ ],
"skip_ci_on_only_changed": [ ],
"always_require_ci_on_changed": ["^x-pack/auditbeat/.*", "^.buildkite/.*", "^go.mod", "^pytest.ini", "^dev-tools/.*", "^libbeat/.*", "^testing/.*", "^x-pack/libbeat/.*"]
},
{
"enabled": true,
"pipelineSlug": "beats-xpack-dockerlogbeat",
"allow_org_users": true,
"allowed_repo_permissions": ["admin", "write"],
"allowed_list": [ ],
"set_commit_status": true,
"build_on_commit": true,
"build_on_comment": true,
"trigger_comment_regex": "^/test x-pack/dockerlogbeat$",
"always_trigger_comment_regex": "^/test x-pack/dockerlogbeat$",
"skip_ci_labels": [ ],
"skip_target_branches": [ ],
"skip_ci_on_only_changed": [ ],
"always_require_ci_on_changed": ["^x-pack/dockerlogbeat/.*", "^.buildkite/.*", "^go.mod", "^pytest.ini", "^dev-tools/.*", "^libbeat/.*", "^testing/.*", "^x-pack/libbeat/.*"]
},
{
"enabled": true,
"pipelineSlug": "beats-xpack-filebeat",
"allow_org_users": true,
"allowed_repo_permissions": ["admin", "write"],
"allowed_list": [ ],
"set_commit_status": true,
"build_on_commit": true,
"build_on_comment": true,
"trigger_comment_regex": "^/test x-pack/filebeat$",
"always_trigger_comment_regex": "^/test x-pack/filebeat$",
"skip_ci_labels": [ ],
"skip_target_branches": [ ],
"skip_ci_on_only_changed": [ ],
"always_require_ci_on_changed": ["^x-pack/filebeat/.*", "^.buildkite/.*", "^go.mod", "^pytest.ini", "^dev-tools/.*", "^libbeat/.*", "^testing/.*", "^x-pack/libbeat/.*"]
},
{
"enabled": true,
"pipelineSlug": "beats-xpack-heartbeat",
"allow_org_users": true,
"allowed_repo_permissions": ["admin", "write"],
"allowed_list": [ ],
"set_commit_status": true,
"build_on_commit": true,
"build_on_comment": true,
"trigger_comment_regex": "^/test x-pack/heartbeat$",
"always_trigger_comment_regex": "^/test x-pack/heartbeat$",
"skip_ci_labels": [ ],
"skip_target_branches": [ ],
"skip_ci_on_only_changed": [ ],
"always_require_ci_on_changed": ["^x-pack/heartbeat/.*", "^.buildkite/.*", "^go.mod", "^pytest.ini", "^dev-tools/.*", "^libbeat/.*", "^testing/.*", "^x-pack/libbeat/.*"]
},
{
"enabled": true,
"pipelineSlug": "beats-xpack-osquerybeat",
"allow_org_users": true,
"allowed_repo_permissions": ["admin", "write"],
"allowed_list": [ ],
"set_commit_status": true,
"build_on_commit": true,
"build_on_comment": true,
"trigger_comment_regex": "^/test x-pack/osquerybeat$",
"always_trigger_comment_regex": "^/test x-pack/osquerybeat$",
"skip_ci_labels": [ ],
"skip_target_branches": [ ],
"skip_ci_on_only_changed": [ ],
"always_require_ci_on_changed": ["^x-pack/osquerybeat/.*", "^.buildkite/.*", "^go.mod", "^pytest.ini", "^dev-tools/.*", "^libbeat/.*", "^testing/.*", "^x-pack/libbeat/.*"]
}
]
}
5 changes: 5 additions & 0 deletions .buildkite/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ XPACK_MODULE_PATTERN="^x-pack\\/[a-z0-9]+beat\\/module\\/([^\\/]+)\\/.*"
[ -z "${run_xpack_libbeat_arm_tests+x}" ] && run_xpack_libbeat_arm_tests="$(buildkite-agent meta-data get run_xpack_libbeat_arm_tests --default "false")"
[ -z "${run_xpack_metricbeat_aws_tests+x}" ] && run_xpack_metricbeat_aws_tests="$(buildkite-agent meta-data get run_xpack_metricbeat_aws_tests --default "false")"
[ -z "${run_xpack_metricbeat_macos_tests+x}" ] && run_xpack_metricbeat_macos_tests="$(buildkite-agent meta-data get run_xpack_metricbeat_macos_tests --default "false")"
[ -z "${run_xpack_packetbeat_arm_tests+x}" ] && run_xpack_packetbeat_arm_tests="$(buildkite-agent meta-data get run_xpack_packetbeat_arm_tests --default "false")"
[ -z "${run_xpack_packetbeat_macos_tests+x}" ] && run_xpack_packetbeat_macos_tests="$(buildkite-agent meta-data get run_xpack_packetbeat_macos_tests --default "false")"

metricbeat_changeset=(
"^metricbeat/.*"
Expand Down Expand Up @@ -105,6 +107,9 @@ case "${BUILDKITE_PIPELINE_SLUG}" in
"beats-xpack-metricbeat")
BEAT_CHANGESET_REFERENCE=${xpack_metricbeat_changeset[@]}
;;
"beats-xpack-packetbeat")
BEAT_CHANGESET_REFERENCE=${xpack_packetbeat_changeset[@]}
;;
*)
echo "The changeset for the ${BUILDKITE_PIPELINE_SLUG} pipeline hasn't been defined yet."
;;
Expand Down
11 changes: 3 additions & 8 deletions .buildkite/scripts/generate_xpack_metricbeat_pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ steps:
provider: "gcp"
image: "${DEFAULT_UBUNTU_X86_64_IMAGE}"
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.xml"
- label: ":python: Python Integration Tests"
Expand All @@ -42,8 +40,6 @@ steps:
provider: "gcp"
image: "${DEFAULT_UBUNTU_X86_64_IMAGE}"
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.xml"
- label: ":windows: Windows Unit Tests - {{matrix.image}}"
Expand Down Expand Up @@ -106,8 +102,7 @@ else
fi

#TODO: replace by commented-out below condition when issues mentioned in the PR https://github.com/elastic/beats/pull/38081 are resolved
if [[ are_conditions_met_aws_tests || are_conditions_met_macos_tests ]]; then
# if [[ are_conditions_met_macos_tests ]]; then
if are_conditions_met_aws_tests || are_conditions_met_macos_tests ; then
cat >> $pipelineName <<- YAML
- group: "Extended Tests"
Expand Down Expand Up @@ -140,8 +135,6 @@ if are_conditions_met_aws_tests; then
provider: "gcp"
image: "${DEFAULT_UBUNTU_X86_64_IMAGE}"
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*"
YAML
Expand All @@ -166,6 +159,8 @@ if are_conditions_met_packaging; then
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_HI_PERF_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
env:
PLATFORMS: "${PACKAGING_PLATFORMS}"
Expand Down
195 changes: 195 additions & 0 deletions .buildkite/scripts/generate_xpack_packetbeat_pipeline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
#!/usr/bin/env bash

source .buildkite/scripts/common.sh

set -euo pipefail

pipelineName="pipeline.xpack-packetbeat-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: "cd $BEATS_PROJECT_NAME && mage build unitTest"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.xml"
- label: ":linux: Ubuntu System Tests"
key: "mandatory-linux-system-test"
command: "cd $BEATS_PROJECT_NAME && mage systemTest"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.xml"
- label: ":rhel: RHEL-9 Unit Tests"
key: "mandatory-rhel9-unit-test"
command: ".buildkite/scripts/unit_tests.sh"
agents:
provider: "gcp"
image: "${IMAGE_RHEL9_X86_64}"
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*"
- label: ":windows: Windows Unit Tests - {{matrix.image}}"
command: ".buildkite/scripts/win_unit_tests.ps1"
key: "mandatory-win-unit-tests"
agents:
provider: "gcp"
image: "{{matrix.image}}"
machineType: "${GCP_WIN_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
matrix:
setup:
image:
- "${IMAGE_WIN_2016}"
- "${IMAGE_WIN_2022}"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*"
## TODO: uncomment when the issue https://github.com/elastic/beats/issues/38142 is solved
# - label: ":windows: Windows 2022 System Tests"
# key: "mandatory-win-2022-system-tests"
# command: ".buildkite/scripts/win_unit_tests.ps1 systemtest"
# agents:
# provider: "gcp"
# image: "${IMAGE_WIN_2022}"
# machineType: "${GCP_WIN_MACHINE_TYPE}"
# disk_size: 100
# disk_type: "pd-ssd"
# artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*"
## TODO: this condition will be changed in the Phase 3 of the Migration Plan https://docs.google.com/document/d/1IPNprVtcnHlem-uyGZM0zGzhfUuFAh4LeSl9JFHMSZQ/edit#heading=h.sltz78yy249h
- group: "Extended Windows Tests"
key: "extended-win-tests"
steps:
- label: ":windows: Windows Unit Tests - {{matrix.image}}"
command: ".buildkite/scripts/win_unit_tests.ps1"
key: "extended-win-unit-tests"
agents:
provider: "gcp"
image: "{{matrix.image}}"
machineType: "${GCP_WIN_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
matrix:
setup:
image:
- "${IMAGE_WIN_10}"
- "${IMAGE_WIN_11}"
- "${IMAGE_WIN_2019}"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*"
## TODO: uncomment when the issue https://github.com/elastic/beats/issues/38142 is solved
# - label: ":windows: Windows 10 System Tests"
# key: "extended-win-10-system-tests"
# command: ".buildkite/scripts/win_unit_tests.ps1 systemtest"
# agents:
# provider: "gcp"
# image: "${IMAGE_WIN_10}"
# machineType: "${GCP_WIN_MACHINE_TYPE}"
# disk_size: 100
# disk_type: "pd-ssd"
# artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*"
YAML
else
echo "The conditions don't match to requirements for generating pipeline steps."
exit 0
fi

if are_conditions_met_arm_tests || are_conditions_met_macos_tests ; then
cat >> $pipelineName <<- YAML
- group: "Extended Tests"
key: "extended-tests"
steps:
YAML
fi

if are_conditions_met_macos_tests; then
cat >> $pipelineName <<- YAML
- label: ":mac: MacOS Unit Tests"
key: "extended-macos-unit-tests"
command: ".buildkite/scripts/unit_tests.sh"
agents:
provider: "orka"
imagePrefix: "${IMAGE_MACOS_X86_64}"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*"
YAML
fi

if are_conditions_met_arm_tests; then
cat >> $pipelineName <<- YAML
- label: ":linux: ARM Ubuntu Unit Tests"
key: "extended-arm64-unit-test"
command: "cd $BEATS_PROJECT_NAME && mage build unitTest"
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "${AWS_ARM_INSTANCE_TYPE}"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*"
YAML
fi

echo "Check and add the Packaging into the pipeline"
if are_conditions_met_packaging; then
cat >> $pipelineName <<- YAML
- wait: ~
depends_on:
- step: "mandatory-tests"
allow_failure: false
- group: "Packaging" # TODO: check conditions for future the main pipeline migration: https://github.com/elastic/beats/pull/28589
key: "packaging"
steps:
- label: ":linux: Packaging Linux"
key: "packaging-linux"
command: "cd $BEATS_PROJECT_NAME && mage package"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_HI_PERF_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
env:
PLATFORMS: "${PACKAGING_PLATFORMS}"
- label: ":linux: Packaging ARM"
key: "packaging-arm"
command: "cd $BEATS_PROJECT_NAME && mage package"
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "${AWS_ARM_INSTANCE_TYPE}"
env:
PLATFORMS: "${PACKAGING_ARM_PLATFORMS}"
PACKAGES: "docker"
YAML
fi

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

echo "--- Loading dynamic steps"
buildkite-agent pipeline upload $pipelineName
2 changes: 1 addition & 1 deletion .buildkite/scripts/setenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ SETUP_WIN_PYTHON_VERSION="3.11.0"
NMAP_WIN_VERSION="7.12" # Earlier versions of NMap provide WinPcap (the winpcap packages don't install nicely because they pop-up a UI)
GO_VERSION=$(cat .go-version)
ASDF_MAGE_VERSION="1.15.0"
ASDF_TERRAFORM_VERSION="1.0.2"
PACKAGING_PLATFORMS="+all linux/amd64 linux/arm64 windows/amd64 darwin/amd64 darwin/arm64"
PACKAGING_ARM_PLATFORMS="linux/arm64"
ASDF_TERRAFORM_VERSION="1.0.2"
AWS_REGION="eu-central-1"

export SETUP_GVM_VERSION
Expand Down
Loading

0 comments on commit 6e88789

Please sign in to comment.