Skip to content

Commit

Permalink
debug macos
Browse files Browse the repository at this point in the history
  • Loading branch information
oakrizan committed Oct 17, 2024
1 parent 4271ccf commit deef76e
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 101 deletions.
6 changes: 2 additions & 4 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-xpack-packetbeat" && "$BUILDKITE_STEP
fi

if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-xpack-agentbeat" && "$BUILDKITE_STEP_KEY" == *"agentbeat-it"* ]]; then
if [[ "$BUILDKITE_STEP_KEY" == *"macos"* ]]; then
ulimit -Sn 10000
fi
AGENTBEAT_PATH=$(.buildkite/scripts/agentbeat/setup_agentbeat.py)
# .buildkite/scripts/agentbeat/setup_agentbeat.py
AGENTBEAT_PATH=$(.buildkite/scripts/agentbeat/setup_agentbeat.py | tail -n 1)
export AGENTBEAT_PATH
fi

Expand Down
18 changes: 8 additions & 10 deletions .buildkite/scripts/agentbeat/setup_agentbeat.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env python3

import platform
import re
import subprocess
import sys
import tarfile
import re

PATH = 'x-pack/agentbeat/build/distributions'

Expand Down Expand Up @@ -48,21 +47,22 @@ def download_agentbeat(pattern, path) -> str:
try:
subprocess.run(
['buildkite-agent', 'artifact', 'download', pattern, '.',
'--build', '01924d2b-b061-45ae-a106-e885584ff26f',
# '--build', '01928f55-8452-41c6-89ba-fe21f019f53c',
'--step', 'agentbeat-package-linux'],
check=True, stdout=sys.stdout, stderr=sys.stderr, text=True)

except subprocess.CalledProcessError:
exit(1)

return get_filename(path)


def get_filename(path) -> str:
print("--- Getting filename")
try:
out = subprocess.run(
['ls', '-p', path],
check=True, capture_output=True, text=True)
print("--- ls -p: " + out.stdout)
return out.stdout.strip()
except subprocess.CalledProcessError:
exit(1)
Expand All @@ -89,9 +89,10 @@ def unzip_agentbeat(filepath):

def untar_agentbeat(filepath):
try:
with tarfile.open(filepath, 'r:gz') as tar:
tar.extractall()
except Exception as e:
subprocess.run(
['tar', '-xvf', filepath],
check=True, stdout=sys.stdout, stderr=sys.stderr, text=True)
except subprocess.CalledProcessError as e:
log_err(e)
exit(1)

Expand All @@ -106,10 +107,7 @@ def get_path_to_executable(filepath) -> str:
log_err("No agentbeat executable found")
exit(1)


artifact_pattern = get_artifact_pattern()
archive = download_agentbeat(artifact_pattern, PATH)
print("--- Extracting")
extract_agentbeat(archive)
print("--- Getting path to exec")
log(get_path_to_executable(archive))
178 changes: 91 additions & 87 deletions .buildkite/x-pack/pipeline.xpack.agentbeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,57 +15,57 @@ env:
AGENTBEAT_SPEC: "./agentbeat.spec.yml"

steps:
- group: "Check/Update"
key: "x-pack-agentbeat-check-update"

steps:
- label: "agentbeat: Run pre-commit"
command: "pre-commit run --all-files"
agents:
image: "${IMAGE_BEATS_WITH_HOOKS_LATEST}"
memory: "2Gi"
useCustomGlobalHooks: true
notify:
- github_commit_status:
context: "agentbeat: pre-commit"

- wait: ~
# with PRs, we want to run mandatory tests only if check/update step succeed
# for other cases, e.g. merge commits, we want to run mundatory test (and publish) independently of other tests
# this allows building DRA artifacts even if there is flakiness in check/update step
if: build.env("BUILDKITE_PULL_REQUEST") != "false"
depends_on: "x-pack-agentbeat-check-update"
# - group: "Check/Update"
# key: "x-pack-agentbeat-check-update"
#
# steps:
# - label: "agentbeat: Run pre-commit"
# command: "pre-commit run --all-files"
# agents:
# image: "${IMAGE_BEATS_WITH_HOOKS_LATEST}"
# memory: "2Gi"
# useCustomGlobalHooks: true
# notify:
# - github_commit_status:
# context: "agentbeat: pre-commit"
#
# - wait: ~
# # with PRs, we want to run mandatory tests only if check/update step succeed
# # for other cases, e.g. merge commits, we want to run mundatory test (and publish) independently of other tests
# # this allows building DRA artifacts even if there is flakiness in check/update step
# if: build.env("BUILDKITE_PULL_REQUEST") != "false"
# depends_on: "x-pack-agentbeat-check-update"

- group: "Agentbeat tests"
key: "agentbeat-mandatory-tests"

steps:
# - label: ":linux: Agentbeat packaging Linux"
# key: "agentbeat-package-linux"
# env:
# PLATFORMS: "+all linux/amd64 linux/arm64 windows/amd64 darwin/amd64 darwin/arm64"
# SNAPSHOT: true
# command: |
# set -euo pipefail
# cd x-pack/agentbeat
# mage package
# artifact_paths:
# - x-pack/agentbeat/build/distributions/**/*
# - "x-pack/agentbeat/build/*.xml"
# - "x-pack/agentbeat/build/*.json"
# retry:
# automatic:
# - limit: 2
# timeout_in_minutes: 60
# agents:
# provider: "gcp"
# image: "${IMAGE_UBUNTU_X86_64}"
# machineType: "${GCP_HI_PERF_MACHINE_TYPE}"
# disk_size: 100
# disk_type: "pd-ssd"
# notify:
# - github_commit_status:
# context: "agentbeat: Packaging"
- label: ":linux: Agentbeat packaging Linux"
key: "agentbeat-package-linux"
env:
PLATFORMS: "+all linux/amd64 linux/arm64 windows/amd64 darwin/amd64 darwin/arm64"
SNAPSHOT: true
command: |
set -euo pipefail
cd x-pack/agentbeat
mage package
artifact_paths:
- x-pack/agentbeat/build/distributions/**/*
- "x-pack/agentbeat/build/*.xml"
- "x-pack/agentbeat/build/*.json"
retry:
automatic:
- limit: 2
timeout_in_minutes: 60
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_HI_PERF_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
notify:
- github_commit_status:
context: "agentbeat: Packaging"

# - label: ":linux: Agentbeat/Integration tests Linux"
# key: "agentbeat-it-linux"
Expand Down Expand Up @@ -109,56 +109,60 @@ steps:
# - github_commit_status:
# context: "agentbeat: Integration tests"

# - label: ":linux: x-pack/agentbeat: Ubuntu x86_64 Spec tests"
# key: "agentbeat-it-linux"
# env:
# PLATFORM: "linux/amd64"
# depends_on:
# - agentbeat-package-linux
# command: |
# cd x-pack/agentbeat
# mage -v testWithSpec
# agents:
# provider: "gcp"
# image: "${IMAGE_UBUNTU_X86_64}"
# machineType: "${GCP_HI_PERF_MACHINE_TYPE}"
# disk_size: 100
# disk_type: "pd-ssd"
#
# - label: ":windows: x-pack/agentbeat: Windows x86_64 Spec tests"
# key: "agentbeat-it-windows"
# env:
# PLATFORM: "windows/amd64"
# depends_on:
# - agentbeat-package-linux
# command: |
# Set-Location -Path x-pack/agentbeat
# mage -v testWithSpec
# agents:
# provider: "gcp"
# image: "${IMAGE_WIN_2022}"
# machine_type: "${GCP_WIN_MACHINE_TYPE}"
# disk_size: 200
# disk_type: "pd-ssd"
- label: ":linux: x-pack/agentbeat: Ubuntu x86_64 Spec tests"
key: "agentbeat-it-linux"
env:
PLATFORM: "linux/amd64"
depends_on:
- agentbeat-package-linux
command: |
cd x-pack/agentbeat
mage -v testWithSpec
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_HI_PERF_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"

- label: ":windows: x-pack/agentbeat: Windows x86_64 Spec tests"
key: "agentbeat-it-windows"
env:
PLATFORM: "windows/amd64"
depends_on:
- agentbeat-package-linux
command: |
Set-Location -Path x-pack/agentbeat
mage -v testWithSpec
agents:
provider: "gcp"
image: "${IMAGE_WIN_2022}"
machine_type: "${GCP_WIN_MACHINE_TYPE}"
disk_size: 200
disk_type: "pd-ssd"

- label: ":macos: x-pack/agentbeat: macOS x86_64 Spec tests"
key: "agentbeat-it-macos"
# depends_on:
# - agentbeat-package-linux
env:
PLATFORM: "darwin/amd64"
depends_on:
- agentbeat-package-linux
command: |
set -euo pipefail
source .buildkite/scripts/install_macos_tools.sh
cd x-pack/agentbeat
mage -v testWithSpec
agents:
provider: "orka"
imagePrefix: "${IMAGE_MACOS_X86_64}"

- label: ":linux: Agentbeat/Integration tests macOS arm64"
key: "agentbeat-it-macos-arm"
# - label: ":linux: Agentbeat/Integration tests macOS arm64"
# key: "agentbeat-it-macos-arm"
# depends_on:
# - agentbeat-package-linux
command: |
cd x-pack/agentbeat
mage -v testWithSpec
agents:
provider: "orka"
imagePrefix: "${IMAGE_MACOS_ARM}"
# command: |
# cd x-pack/agentbeat
# mage -v testWithSpec
# agents:
# provider: "orka"
# imagePrefix: "${IMAGE_MACOS_ARM}"
1 change: 1 addition & 0 deletions dev-tools/mage/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package mage

import (
"gopkg.in/yaml.v2"

"log"
"os"
"strings"
Expand Down

0 comments on commit deef76e

Please sign in to comment.