1+ #! /bin/bash
2+
3+ set -euo pipefail
4+
5+ if [[ " ${BUILDKITE_PULL_REQUEST} " == " false" ]]; then
6+ exit 0
7+ fi
8+
9+ # Fetch active Kibana versions
10+ ACTIVE_KIBANA_VERSIONS=$( curl -sL https://raw.githubusercontent.com/elastic/kibana/main/versions.json | yq ' .versions[].version' | xargs)
11+ echo " Active Kibana versions: $ACTIVE_KIBANA_VERSIONS "
12+
13+ # Extract version spec from the manifest
14+ KIBANA_REQ=$( yq .conditions.kibana.version ./packages/security_detection_engine/manifest.yml)
15+ echo " Kibana requirement from the security_detection_engine manifest: $KIBANA_REQ "
16+
17+ # Dump a trivial Go program to filter by semver constrains
18+ TEMP_DIR=$( mktemp -d)
19+ SEMVER_FILTER_PATH=" $TEMP_DIR /semver.go"
20+
21+ cat << 'GO ' > "$SEMVER_FILTER_PATH"
22+ package main
23+
24+ import (
25+ "strings"
26+ "fmt"
27+ "os"
28+ "github.com/Masterminds/semver/v3"
29+ )
30+
31+ func main() {
32+ c, err := semver.NewConstraint(os.Args[1])
33+ if err != nil {
34+ panic(err)
35+ }
36+
37+ for _, s := range strings.Split(os.Args[2], " ") {
38+ if v, _ := semver.NewVersion(s); c.Check(v) {
39+ fmt.Println(s + "-SNAPSHOT")
40+ }
41+ }
42+ }
43+ GO
44+
45+ # Capture the "returned" array in STACK_VERSIONS
46+ read -r -a STACK_VERSIONS <<< " $(go run " ${SEMVER_FILTER_PATH} " " ${KIBANA_REQ} " " ${ACTIVE_KIBANA_VERSIONS} " | xargs)"
47+
48+ if [[ ! -n " ${STACK_VERSIONS+x} " ]]; then
49+ echo " There are no active versions satisfying the constraint ${KIBANA_REQ} ."
50+ exit 0
51+ fi
52+
53+ # Trigger OOM testing pipeline for each stack version
54+ for STACK_VERSION in " ${STACK_VERSIONS[@]} "
55+ do
56+ echo " --- [security_detection_engine] Trigger OOM testing pipeline against $STACK_VERSION ECH"
57+
58+ cat << YAML | buildkite-agent pipeline upload
59+ steps:
60+ - key: 'run-oom-testing-$( echo " $STACK_VERSION " | sed ' s/\./_/g' ) $BUILDKITE_BUILD_NUMBER '
61+ label: ":elastic-cloud::bar_chart: [security_detection_engine] Test for OOM issues against $STACK_VERSION ECH"
62+ trigger: "appex-qa-stateful-security-prebuilt-rules-ftr-oom-testing"
63+ async: false
64+ build:
65+ message: "Test security_detection_engine package against $STACK_VERSION ($GITHUB_PR_BASE_OWNER /$GITHUB_PR_BASE_REPO , branch: $GITHUB_PR_BRANCH , commit: $BUILDKITE_COMMIT )"
66+ env:
67+ STACK_VERSION: $STACK_VERSION
68+ ELASTIC_INTEGRATIONS_REPO_COMMIT: $BUILDKITE_COMMIT
69+ YAML
70+ done
0 commit comments