Skip to content

Commit 930590d

Browse files
Periodically run exhaustive tests on artifacts prepared with DRA pipeline (#18803) (#18822)
* Add pipeline for running exhaustive tests against artifact prepared by DRA This commit adds a new pipeline to test builds tracked in logstash-releases.yml. For snapshots it runs daily, for released versions weekly. * TEMP: Add POC artifact acceptance cells to exhaustive tests * rename artifacts to match testing framework and test on x86 cells * handle computing expected logstash version from artifacts * remove POC cells and make codereview updates (cherry picked from commit 5c73a8f) Co-authored-by: Cas Donoghue <cas.donoghue@gmail.com>
1 parent e64185f commit 930590d

File tree

5 files changed

+204
-2
lines changed

5 files changed

+204
-2
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import requests
5+
from requests.adapters import HTTPAdapter, Retry
6+
import yaml
7+
8+
YAML_HEADER = '# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json\n'
9+
VERSIONS_URL = "https://raw.githubusercontent.com/logstash-plugins/.ci/1.x/logstash-versions.yml"
10+
11+
TEST_MATRIX = [
12+
("x86_64", "deb", "ubuntu-2204", "gcp", "n2-standard-4"),
13+
("x86_64", "rpm", "almalinux-8", "gcp", "n2-standard-4"),
14+
("arm64", "deb", "ubuntu-2204-aarch64", "aws", "m6g.4xlarge"),
15+
("arm64", "rpm", "almalinux-8-aarch64", "aws", "m6g.4xlarge"),
16+
]
17+
18+
19+
def fetch_logstash_versions():
20+
session = requests.Session()
21+
retries = Retry(total=5, backoff_factor=1, status_forcelist=[408, 502, 503, 504])
22+
session.mount("https://", HTTPAdapter(max_retries=retries))
23+
response = session.get(VERSIONS_URL, timeout=30)
24+
response.raise_for_status()
25+
return yaml.safe_load(response.text)
26+
27+
28+
def slugify_bk_key(key):
29+
return key.replace(".", "-").replace(" ", "-").replace("/", "-").lower()
30+
31+
32+
def aws_agent(vm_name, instance_type):
33+
return {
34+
"provider": "aws",
35+
"imagePrefix": f"platform-ingest-logstash-{vm_name}",
36+
"instanceType": instance_type,
37+
"diskSizeGb": 200,
38+
}
39+
40+
41+
def gcp_agent(vm_name, instance_type):
42+
return {
43+
"provider": "gcp",
44+
"imageProject": "elastic-images-prod",
45+
"image": f"family/platform-ingest-logstash-multi-jdk-{vm_name}",
46+
"machineType": instance_type,
47+
"diskSizeGb": 200,
48+
"diskType": "pd-ssd",
49+
}
50+
51+
52+
def generate_test_step(version, artifact_type, arch, pkg_type, vm_name, provider, instance_type):
53+
agent = aws_agent(vm_name, instance_type) if provider == "aws" else gcp_agent(vm_name, instance_type)
54+
return {
55+
"label": f"{version} / {arch} / {pkg_type}",
56+
"key": slugify_bk_key(f"test-{version}-{arch}-{pkg_type}"),
57+
"agents": agent,
58+
"env": {
59+
"LS_VERSION": version,
60+
"ARTIFACT_TYPE": artifact_type,
61+
"PKG_TYPE": pkg_type,
62+
"ARCH": arch,
63+
},
64+
"command": ".buildkite/scripts/exhaustive-tests/run-acceptance-from-artifact.sh",
65+
"retry": {"automatic": [{"limit": 3}]},
66+
}
67+
68+
69+
if __name__ == "__main__":
70+
artifact_type = os.getenv("ARTIFACT_TYPE", "snapshot")
71+
versions_data = fetch_logstash_versions()
72+
versions_dict = versions_data.get("snapshots" if artifact_type == "snapshot" else "releases", {})
73+
versions = list(versions_dict.values())
74+
75+
steps = []
76+
for version in versions:
77+
for arch, pkg_type, vm_name, provider, instance_type in TEST_MATRIX:
78+
steps.append(generate_test_step(version, artifact_type, arch, pkg_type, vm_name, provider, instance_type))
79+
80+
pipeline = {
81+
"steps": [{
82+
"group": f"Acceptance Tests ({artifact_type.capitalize()} Artifacts)",
83+
"key": f"acceptance-{artifact_type}",
84+
"steps": steps,
85+
}]
86+
}
87+
88+
print(YAML_HEADER + yaml.dump(pipeline, default_flow_style=False, sort_keys=False))
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# x86 runs on multi-jdk images, ARM runs on regular images
5+
if [[ "${ARCH}" == "x86_64" ]]; then
6+
source .buildkite/scripts/common/vm-agent-multi-jdk.sh
7+
else
8+
source .buildkite/scripts/common/vm-agent.sh
9+
fi
10+
11+
# Get current source version - acceptance tests expect this version in filename
12+
SOURCE_VERSION=$(grep '^logstash:' versions.yml | awk '{print $2}')
13+
echo "Source version: ${SOURCE_VERSION}"
14+
15+
# Map architecture to package-specific naming
16+
# deb uses: amd64/arm64, rpm uses: x86_64/aarch64
17+
case "${PKG_TYPE}" in
18+
deb) [[ "${ARCH}" == "x86_64" ]] && PKG_ARCH="amd64" || PKG_ARCH="arm64" ;;
19+
rpm) [[ "${ARCH}" == "x86_64" ]] && PKG_ARCH="x86_64" || PKG_ARCH="aarch64" ;;
20+
esac
21+
22+
[[ "${ARTIFACT_TYPE}" == "snapshot" ]] && BASE_URL="https://snapshots.elastic.co/downloads/logstash" || BASE_URL="https://artifacts.elastic.co/downloads/logstash"
23+
24+
ARTIFACT_DIR="${PWD}/acceptance-artifacts"
25+
mkdir -p "${ARTIFACT_DIR}"
26+
27+
# Download artifact and rename to what acceptance tests expect
28+
ARTIFACT_URL="${BASE_URL}/logstash-${LS_VERSION}-${PKG_ARCH}.${PKG_TYPE}"
29+
EXPECTED_FILE="${ARTIFACT_DIR}/logstash-${SOURCE_VERSION}-SNAPSHOT-${PKG_ARCH}.${PKG_TYPE}"
30+
31+
echo "--- Downloading Logstash ${LS_VERSION} ${PKG_ARCH} ${PKG_TYPE}"
32+
echo "URL: ${ARTIFACT_URL}"
33+
echo "Saving as: ${EXPECTED_FILE}"
34+
curl -fsSL -o "${EXPECTED_FILE}" "${ARTIFACT_URL}"
35+
36+
echo "--- Downloaded artifacts"
37+
ls -la "${ARTIFACT_DIR}"
38+
39+
echo "--- Running bootstrap"
40+
./gradlew clean bootstrap
41+
42+
echo "--- Running acceptance tests"
43+
export LS_ARTIFACTS_PATH="${ARTIFACT_DIR}"
44+
echo "LS_ARTIFACTS_PATH=${LS_ARTIFACTS_PATH}"
45+
./gradlew runAcceptanceTests
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
2+
3+
steps:
4+
- label: "Generate acceptance test steps"
5+
command: |
6+
set -euo pipefail
7+
python3 -m pip install pyyaml requests
8+
python3 .buildkite/scripts/exhaustive-tests/generate-snapshot-release-steps.py > steps.yml
9+
buildkite-agent pipeline upload < steps.yml

catalog-info.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ spec:
2828
- resource:buildkite-logstash-serverless-integration-testing
2929
- resource:logstash-snyk-report
3030
- resource:logstash-artifact-snyk-scan
31+
- resource:logstash-artifacts-acceptance
3132
- resource:logstash-dra-snapshot-pipeline
3233
- resource:logstash-dra-staging-pipeline
3334
- resource:logstash-linux-jdk-matrix-pipeline
@@ -171,6 +172,56 @@ spec:
171172
cronline: "@daily"
172173
message: "Run the Logstash Artifacts Snyk report every day."
173174

175+
# ***********************************
176+
# Declare artifacts acceptance test pipeline
177+
# ***********************************
178+
---
179+
apiVersion: backstage.io/v1alpha1
180+
kind: Resource
181+
metadata:
182+
name: logstash-artifacts-acceptance
183+
description: 'Acceptance tests for published snapshot and release artifacts'
184+
spec:
185+
type: buildkite-pipeline
186+
owner: group:logstash
187+
system: platform-ingest
188+
implementation:
189+
apiVersion: buildkite.elastic.dev/v1
190+
kind: Pipeline
191+
metadata:
192+
name: logstash-artifacts-acceptance
193+
spec:
194+
repository: elastic/logstash
195+
pipeline_file: ".buildkite/snapshot_release_acceptance_pipeline.yml"
196+
maximum_timeout_in_minutes: 120
197+
provider_settings:
198+
trigger_mode: none
199+
env:
200+
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: 'true'
201+
SLACK_NOTIFICATIONS_CHANNEL: '#logstash-build'
202+
SLACK_NOTIFICATIONS_ON_SUCCESS: 'false'
203+
SLACK_NOTIFICATIONS_SKIP_FOR_RETRIES: 'true'
204+
teams:
205+
logstash:
206+
access_level: MANAGE_BUILD_AND_READ
207+
ingest-eng-prod:
208+
access_level: MANAGE_BUILD_AND_READ
209+
everyone:
210+
access_level: READ_ONLY
211+
schedules:
212+
Daily snapshot acceptance tests:
213+
branch: main
214+
cronline: "@daily"
215+
message: "Test published snapshot artifacts"
216+
env:
217+
ARTIFACT_TYPE: "snapshot"
218+
Weekly release acceptance tests:
219+
branch: main
220+
cronline: "@weekly"
221+
message: "Test published release artifacts"
222+
env:
223+
ARTIFACT_TYPE: "release"
224+
174225
# ***********************************
175226
# SECTION START: DRA pipelines
176227
# ***********************************

qa/acceptance/spec/shared_examples/cli/logstash/version.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
require_relative "../../../spec_helper"
1919
require "logstash/version"
2020

21+
# When testing pre-built artifacts via the snapshot/release acceptance pipeline,
22+
# ARTIFACT_TYPE is set and LS_VERSION holds the artifact's version.
23+
# Derive the expected version from the artifact (stripping -SNAPSHOT suffix).
24+
EXPECTED_VERSION = if ENV['ARTIFACT_TYPE'] && ENV['LS_VERSION']
25+
ENV['LS_VERSION'].sub(/-SNAPSHOT$/, '')
26+
else
27+
LOGSTASH_VERSION
28+
end
29+
2130
shared_examples "logstash version" do |logstash|
2231
describe "logstash --version" do
2332
before :all do
@@ -32,12 +41,12 @@
3241
context "on [#{logstash.human_name}]" do
3342
it "returns the right logstash version" do
3443
result = logstash.run_command_in_path("bin/logstash --version")
35-
expect(result).to run_successfully_and_output(/#{LOGSTASH_VERSION}/)
44+
expect(result).to run_successfully_and_output(/#{EXPECTED_VERSION}/)
3645
end
3746
context "when also using the --path.settings argument" do
3847
it "returns the right logstash version" do
3948
result = logstash.run_command_in_path("bin/logstash --path.settings=/etc/logstash --version")
40-
expect(result).to run_successfully_and_output(/#{LOGSTASH_VERSION}/)
49+
expect(result).to run_successfully_and_output(/#{EXPECTED_VERSION}/)
4150
end
4251
end
4352
end

0 commit comments

Comments
 (0)