|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# |
| 4 | +# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 5 | +# or more contributor license agreements. Licensed under the "Elastic License |
| 6 | +# 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side |
| 7 | +# Public License v 1"; you may not use this file except in compliance with, at |
| 8 | +# your election, the "Elastic License 2.0", the "GNU Affero General Public |
| 9 | +# License v3.0 only", or the "Server Side Public License, v 1". |
| 10 | +# |
| 11 | + |
| 12 | +set -euo pipefail |
| 13 | + |
| 14 | +echo "Selecting the most recent build from branch [$BUILDKITE_BRANCH]." |
| 15 | + |
| 16 | +# Select the most recent build from the current branch. |
| 17 | +# We collect snapshots, order by date, then collect BCs, order by date, and concat them; then we select the last. |
| 18 | +# So if we have one (or more) BC, we will always prefer to use that. Otherwise we will use the latest snapshot. |
| 19 | +MANIFEST_URL="$(curl -s https://artifacts.elastic.co/releases/TfEVhiaBGqR64ie0g0r0uUwNAbEQMu1Z/future-releases/stack.json | |
| 20 | +jq ".releases[] | |
| 21 | +select(.branch == \"$BUILDKITE_BRANCH\") | |
| 22 | +select(.active_release == true) | |
| 23 | +((.snapshots | to_entries | sort_by(.value.completed_at)) + |
| 24 | +(.build_candidates | to_entries | sort_by(.value.completed_at))) | |
| 25 | +last | .value.manifest_url")" |
| 26 | + |
| 27 | +if [[ -z "$MANIFEST_URL" ]]; then |
| 28 | + echo "No snapshots or build candidates for branch [$BUILDKITE_BRANCH]." |
| 29 | + echo "Skipping BC upgrade tests." |
| 30 | + exit 0 |
| 31 | +fi |
| 32 | + |
| 33 | +echo "Getting build manifest from [$MANIFEST_URL]" |
| 34 | + |
| 35 | +MANIFEST="$(eval "curl -s $MANIFEST_URL")" |
| 36 | +if [[ -z "$MANIFEST" ]]; then |
| 37 | + echo "Cannot get the build manifest from [$MANIFEST_URL]" |
| 38 | + exit 1 |
| 39 | +fi |
| 40 | + |
| 41 | +CURRENT_VERSION=$(sed -n 's/^elasticsearch[[:space:]]*=[[:space:]]*\(.*\)/\1/p' build-tools-internal/version.properties) |
| 42 | + |
| 43 | +BC_VERSION=$(echo "$MANIFEST" | jq -r .version) |
| 44 | +BC_BUILD_ID=$(echo "$MANIFEST" | jq -r .build_id) |
| 45 | +BC_COMMIT_HASH=$(echo "$MANIFEST" | jq -r .projects.elasticsearch.commit_hash) |
| 46 | + |
| 47 | +if [ "$CURRENT_VERSION-SNAPSHOT" != "$BC_VERSION" ]; then |
| 48 | + echo "Version [$BC_VERSION] of BC (or snapshot) does not match current version [$CURRENT_VERSION] of branch [$BUILDKITE_BRANCH]." |
| 49 | + echo "Skipping BC upgrade tests." |
| 50 | + exit 0 |
| 51 | +fi |
| 52 | + |
| 53 | +echo "Running BC upgrade tests on $BUILDKITE_BRANCH [$BC_VERSION] using BC (or snapshot) build of commit [$BC_COMMIT_HASH] with build id [$BC_BUILD_ID]." |
| 54 | + |
| 55 | +cat <<EOF | buildkite-agent pipeline upload |
| 56 | +steps: |
| 57 | + - label: bc-upgrade $BC_BUILD_ID -> $BUILDKITE_BRANCH |
| 58 | + command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true -Dorg.elasticsearch.build.cache.push=true -Dignore.tests.seed -Dscan.capture-file-fingerprints -Dtests.bwc.main.version=${BC_VERSION} -Dtests.bwc.refspec.main=${BC_COMMIT_HASH} bcUpgradeTest -Dtests.jvm.argline="-Des.serverless_transport=true" |
| 59 | + timeout_in_minutes: 300 |
| 60 | + agents: |
| 61 | + provider: gcp |
| 62 | + image: family/elasticsearch-ubuntu-2004 |
| 63 | + machineType: n1-standard-32 |
| 64 | + buildDirectory: /dev/shm/bk |
| 65 | + preemptible: true |
| 66 | + retry: |
| 67 | + automatic: |
| 68 | + - exit_status: "-1" |
| 69 | + limit: 3 |
| 70 | + signal_reason: none |
| 71 | + - signal_reason: agent_stop |
| 72 | + limit: 3 |
| 73 | +EOF |
0 commit comments