Health api minor followups (#16533)

* Utilize default agent for Health API CI. Call python scripts from directly CI step.

* Change BK agent to support both Java and python. Install pip manually and send env vars to subprocess.
This commit is contained in:
Mashhur 2024-10-10 14:57:41 -07:00 committed by GitHub
parent 7f7af057f0
commit 4037adfc4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 34 additions and 18 deletions

View file

@ -1,17 +1,20 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
agents:
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-logstash-ci"
cpu: "2"
memory: "4Gi"
ephemeralStorage: "64Gi"
provider: gcp
imageProject: elastic-images-prod
image: family/platform-ingest-logstash-ubuntu-2204
machineType: "n2-standard-4"
diskSizeGb: 64
steps:
# todo: add a step for 8.latest when Health Report MVP is landed
- label: ":logstash: Health Report Integration tests on main branch."
command: |
source .buildkite/scripts/common/vm-agent.sh
./.buildkite/scripts/health-report-tests/main.sh
retry:
automatic:
- limit: 3
- group: ":logstash: Health API integration tests"
key: "testing-phase"
steps:
- label: "main branch"
key: "integ-tests-on-main-branch"
command:
- .buildkite/scripts/health-report-tests/main.sh
retry:
automatic:
- limit: 3

View file

@ -63,7 +63,7 @@ class Bootstrap:
f"Failed to install {plugin_path}")
def build_logstash(self):
print(f"Building Logstash.")
print(f"Building Logstash...")
util.run_or_raise_error(
["./gradlew", "clean", "bootstrap", "assemble", "installDefaultGems"],
"Failed to build Logstash")

View file

@ -1,5 +1,17 @@
#!/usr/bin/env bash
set -eo pipefail
#!/bin/bash
set -euo pipefail
export PATH="/opt/buildkite-agent/.rbenv/bin:/opt/buildkite-agent/.pyenv/bin:/opt/buildkite-agent/.java/bin:$PATH"
export JAVA_HOME="/opt/buildkite-agent/.java"
eval "$(rbenv init -)"
eval "$(pyenv init -)"
echo "--- Installing pip"
sudo apt-get install python3-pip -y
echo "--- Installing dependencies"
python3 -mpip install -r .buildkite/scripts/health-report-tests/requirements.txt
python3 .buildkite/scripts/health-report-tests/main.py
echo "--- Running tests"
python3 .buildkite/scripts/health-report-tests/main.py

View file

@ -1,3 +1,4 @@
import os
import requests
import subprocess
from requests.adapters import HTTPAdapter, Retry
@ -27,7 +28,7 @@ def run_or_raise_error(commands: list, error_message):
f"""
Executes the {list} commands and raises an {Exception} if opration fails.
"""
result = subprocess.run(commands, universal_newlines=True, stdout=subprocess.PIPE)
result = subprocess.run(commands, env=os.environ.copy(), universal_newlines=True, stdout=subprocess.PIPE)
if result.returncode != 0:
full_error_message = (error_message + ", output: " + result.stdout.decode('utf-8')) \
if result.stdout else error_message

View file

@ -29,7 +29,7 @@ shared_examples_for 'the container is configured correctly' do |flavor|
it 'should be running an API server on port 9600' do
wait_for_logstash(@container)
expect(get_logstash_status(@container)).to eql 'green'
expect(get_logstash_status(@container)).not_to be_nil
end
end