Skip to content

Commit

Permalink
debug macos
Browse files Browse the repository at this point in the history
  • Loading branch information
oakrizan committed Oct 16, 2024
1 parent 4271ccf commit bda37e7
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 42 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
29 changes: 19 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 @@ -71,6 +71,8 @@ def get_filename(path) -> str:
def extract_agentbeat(filename):
filepath = PATH + '/' + filename

print("--- Filepath: " + filepath)

if filepath.endswith('.zip'):
unzip_agentbeat(filepath)
else:
Expand All @@ -88,10 +90,18 @@ def unzip_agentbeat(filepath):


def untar_agentbeat(filepath):
# try:
# with tarfile.open(filepath) as tar:
# tar.extractall()
# tar.close()
# except Exception as e:
# log_err(e)
# exit(1)
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 +116,9 @@ def get_path_to_executable(filepath) -> str:
log_err("No agentbeat executable found")
exit(1)


print("--- Setting up agentbeat")
artifact_pattern = get_artifact_pattern()
print("--- Artifact pattern: " + artifact_pattern)
archive = download_agentbeat(artifact_pattern, PATH)
print("--- Extracting")
extract_agentbeat(archive)
print("--- Getting path to exec")
log(get_path_to_executable(archive))
56 changes: 28 additions & 28 deletions .buildkite/x-pack/pipeline.xpack.agentbeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ 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"
Expand Down Expand Up @@ -152,13 +152,13 @@ steps:
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 bda37e7

Please sign in to comment.