-
Notifications
You must be signed in to change notification settings - Fork 66
[ML] Add serverless MKI testing for ml-cpp PR builds #3027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0c5b4ea
0b5d1db
f45bc26
c495528
32db922
500f011
8c50787
651ff54
f8e3f2c
e39fd40
b907a1f
0673125
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #!/bin/bash | ||
| # Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| # or more contributor license agreements. Licensed under the Elastic License | ||
| # 2.0 and the following additional limitation. Functionality enabled by the | ||
| # files subject to the Elastic License 2.0 may only be used in production when | ||
| # invoked by an Elasticsearch process with a license key installed that permits | ||
| # use of machine learning features. You may not use this file except in | ||
| # compliance with the Elastic License 2.0 and the foregoing additional | ||
| # limitation. | ||
|
|
||
| # Pipeline: build a serverless Docker image with custom ml-cpp and deploy it | ||
| # to the QA environment for interactive use. Unlike run_serverless_tests.yml.sh, | ||
| # this does NOT run E2E tests -- it just gets the environment running so the | ||
| # developer can interact with it (deploy models, run queries, kubectl, etc.). | ||
| # | ||
| # The deployment stays up for 1 hour by default. Set KEEP_DEPLOYMENT=true | ||
| # (via the Buildkite UI) to keep it longer. The build annotations will | ||
| # contain the URL and encrypted credentials for accessing the deployment. | ||
|
|
||
| ML_CPP_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" | ||
| # shellcheck source=dev-tools/serverless_buildkite_trigger_prepare.sh | ||
| source "${ML_CPP_ROOT}/dev-tools/serverless_buildkite_trigger_prepare.sh" | ||
|
|
||
| prepareMlCppServerlessTriggerContext "${BASH_SOURCE[0]}" || exit 1 | ||
| assignServerlessQaTriggerEnvYamlEscapes | ||
|
|
||
| echo "Deploying to serverless QA with custom ml-cpp from PR #${PR_NUM}" >&2 | ||
|
|
||
| cat <<EOL | ||
| steps: | ||
| $(emitServerlessUploadMlCppDepsStepYaml) | ||
| - label: ":rocket: Deploy custom ml-cpp to serverless QA" | ||
| depends_on: "upload_ml_cpp_deps" | ||
| async: false | ||
| trigger: elasticsearch-serverless-deploy-qa | ||
| build: | ||
| branch: "${SERVERLESS_BRANCH}" | ||
| message: "ml-cpp PR #${PR_NUM}: ${SAFE_MESSAGE}" | ||
| env: | ||
| ML_CPP_BUILD_ID: "${BUILDKITE_BUILD_ID}" | ||
| ELASTICSEARCH_SUBMODULE_COMMIT: "${ES_COMMIT}" | ||
| KEEP_DEPLOYMENT: "${KEEP_DEPLOYMENT_SAFE}" | ||
| REGION_ID: "${REGION_ID_SAFE}" | ||
| PROJECT_TYPE: "${PROJECT_TYPE_SAFE}" | ||
| EOL |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #!/bin/bash | ||
| # Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| # or more contributor license agreements. Licensed under the Elastic License | ||
| # 2.0 and the following additional limitation. Functionality enabled by the | ||
| # files subject to the Elastic License 2.0 may only be used in production when | ||
| # invoked by an Elasticsearch process with a license key installed that permits | ||
| # use of machine learning features. You may not use this file except in | ||
| # compliance with the Elastic License 2.0 and the foregoing additional | ||
| # limitation. | ||
|
|
||
| # Pipeline: trigger the elasticsearch-serverless validation pipeline to build | ||
| # a Docker image incorporating custom ml-cpp artifacts from this build, then | ||
| # run E2E tests against MKI QA. | ||
| # | ||
| # The triggered pipeline uses $BUILDKITE_TRIGGERED_FROM_BUILD_ID to download | ||
| # ml-cpp artifacts from this build via buildkite-agent, sets up a local Ivy | ||
| # repo, and passes -Dbuild.ml_cpp.repo to the Gradle Docker build. | ||
| # | ||
| # This avoids cloning elasticsearch-serverless or needing AWS credentials | ||
| # in the ml-cpp PR pipeline. | ||
|
|
||
| ML_CPP_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" | ||
| # shellcheck source=dev-tools/serverless_buildkite_trigger_prepare.sh | ||
| source "${ML_CPP_ROOT}/dev-tools/serverless_buildkite_trigger_prepare.sh" | ||
|
|
||
| prepareMlCppServerlessTriggerContext "${BASH_SOURCE[0]}" || exit 1 | ||
|
|
||
| # --- Resolve ES PR number --- | ||
| # The serverless pipeline's PR-specific tests step looks up labels from the | ||
| # ES PR. First tries the ml-cpp PR author's matching ES PR (coordinated | ||
| # changes), then falls back to any recent open ES PR. | ||
| ES_PR_NUM="" | ||
| if [ -z "${ELASTICSEARCH_PR_NUMBER:-}" ]; then | ||
| if [ -n "$PR_AUTHOR_FORK" ] && [ -n "$PR_SOURCE" ]; then | ||
| ES_PR_NUM=$(curl -s "https://api.github.com/repos/elastic/elasticsearch/pulls?head=${PR_AUTHOR_FORK}:${PR_SOURCE}&state=open&per_page=1" 2>/dev/null \ | ||
| | python3 -c "import sys,json; prs=json.load(sys.stdin); print(prs[0]['number'] if prs else '')" 2>/dev/null || true) | ||
| fi | ||
| if [ -z "$ES_PR_NUM" ]; then | ||
| ES_PR_NUM=$(curl -s "https://api.github.com/repos/elastic/elasticsearch/pulls?state=open&per_page=1" 2>/dev/null \ | ||
| | python3 -c "import sys,json; prs=json.load(sys.stdin); print(prs[0]['number'] if prs else '')" 2>/dev/null || true) | ||
| fi | ||
| fi | ||
| ES_PR_NUM="${ELASTICSEARCH_PR_NUMBER:-${ES_PR_NUM}}" | ||
| if [ -z "$ES_PR_NUM" ]; then | ||
| echo "WARNING: Could not resolve an ES PR number. The serverless PR-specific tests step may fail." >&2 | ||
| fi | ||
| echo "Using ES submodule commit: $ES_COMMIT, ES PR number: $ES_PR_NUM" >&2 | ||
|
|
||
| assignServerlessQaTriggerEnvYamlEscapes | ||
|
|
||
| cat <<EOL | ||
| steps: | ||
| $(emitServerlessUploadMlCppDepsStepYaml) | ||
| - label: ":docker: :serverless: Build serverless image with custom ml-cpp" | ||
| depends_on: "upload_ml_cpp_deps" | ||
| async: false | ||
| trigger: elasticsearch-serverless-es-pr-check | ||
| build: | ||
| branch: "${SERVERLESS_BRANCH}" | ||
| message: "ml-cpp PR #${PR_NUM}: ${SAFE_MESSAGE}" | ||
| env: | ||
| UPDATE_SUBMODULE: "false" | ||
| ML_CPP_BUILD_ID: "${BUILDKITE_BUILD_ID}" | ||
| # ml-cpp repo commit at trigger time; serverless folds this into IMAGE_TAG | ||
| # with ML_CPP_BUILD_ID so Docker tags never collide with stock builds. | ||
| ML_CPP_COMMIT: "${BUILDKITE_COMMIT}" | ||
| ELASTICSEARCH_SUBMODULE_COMMIT: "${ES_COMMIT}" | ||
| ELASTICSEARCH_PR_NUMBER: "${ES_PR_NUM}" | ||
|
Comment on lines
+60
to
+68
|
||
| KEEP_DEPLOYMENT: "${KEEP_DEPLOYMENT_SAFE}" | ||
| REGION_ID: "${REGION_ID_SAFE}" | ||
| PROJECT_TYPE: "${PROJECT_TYPE_SAFE}" | ||
| EOL | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| # or more contributor license agreements. Licensed under the Elastic License | ||
| # 2.0 and the following additional limitation. Functionality enabled by the | ||
| # files subject to the Elastic License 2.0 may only be used in production when | ||
| # invoked by an Elasticsearch process with a license key installed that permits | ||
| # use of machine learning features. You may not use this file except in | ||
| # compliance with the Elastic License 2.0 and the foregoing additional | ||
| # limitation. | ||
| # | ||
|
|
||
| # Shared logic to choose which elasticsearch fork/branch to use for ml-cpp CI: | ||
| # integration test clones (run_es_tests_common.sh) and Buildkite pipelines that | ||
| # need ELASTICSEARCH_SUBMODULE_COMMIT without cloning. | ||
| # | ||
| # Source this file, then call pickCloneTarget. It reads (in order of precedence): | ||
| # GITHUB_PR_OWNER / GITHUB_PR_BRANCH — when the job is tied to a GitHub PR | ||
| # PR_AUTHOR / PR_SOURCE_BRANCH — fork and branch for coordinated ml-cpp + ES changes | ||
| # elastic / PR_SOURCE_BRANCH — upstream branch matching the ml-cpp PR branch name | ||
| # elastic / PR_TARGET_BRANCH — target branch of the ml-cpp PR | ||
| # elastic / main — final fallback | ||
| # | ||
| # On success, SELECTED_FORK and SELECTED_BRANCH are set. Optional helper | ||
| # elasticsearch_selected_branch_head_sha prints the remote HEAD commit for that | ||
| # pair (same transport as isCloneTargetValid: git@github.com). | ||
| # | ||
| # This file must be sourced (not executed) so that SELECTED_* remain in the caller's shell. | ||
|
|
||
| function isCloneTargetValid { | ||
| local fork_to_check="$1" | ||
| local branch_to_check="$2" | ||
| if [ -z "$fork_to_check" ] || [ -z "$branch_to_check" ]; then | ||
| return 1 | ||
| fi | ||
| # Diagnostics must go to stderr: callers (e.g. deploy_serverless_qa.yml.sh) | ||
| # pipe stdout to `buildkite-agent pipeline upload` and expect only YAML. | ||
| echo "Checking for '$branch_to_check' branch at $fork_to_check/elasticsearch" >&2 | ||
| if [ -n "$(git ls-remote --heads "git@github.com:${fork_to_check}/elasticsearch.git" "$branch_to_check" 2>/dev/null)" ]; then | ||
| echo "Will use '$branch_to_check' branch at $fork_to_check/elasticsearch for ES integration tests" >&2 | ||
| return 0 | ||
| fi | ||
| return 1 | ||
|
Comment on lines
+30
to
+43
|
||
| } | ||
|
|
||
| SELECTED_FORK=elastic | ||
| SELECTED_BRANCH=main | ||
|
|
||
| function pickCloneTarget { | ||
|
|
||
| if isCloneTargetValid "$GITHUB_PR_OWNER" "$GITHUB_PR_BRANCH" ; then | ||
| SELECTED_FORK="$GITHUB_PR_OWNER" | ||
| SELECTED_BRANCH="$GITHUB_PR_BRANCH" | ||
| return 0 | ||
| fi | ||
|
|
||
| if isCloneTargetValid "$PR_AUTHOR" "$PR_SOURCE_BRANCH" ; then | ||
| SELECTED_FORK="$PR_AUTHOR" | ||
| SELECTED_BRANCH="$PR_SOURCE_BRANCH" | ||
| return 0 | ||
| fi | ||
|
|
||
| if isCloneTargetValid "$SELECTED_FORK" "$PR_SOURCE_BRANCH" ; then | ||
| SELECTED_BRANCH="$PR_SOURCE_BRANCH" | ||
| return 0 | ||
| fi | ||
|
|
||
| if isCloneTargetValid "$SELECTED_FORK" "$PR_TARGET_BRANCH" ; then | ||
| SELECTED_BRANCH="$PR_TARGET_BRANCH" | ||
| return 0 | ||
| fi | ||
|
|
||
| if isCloneTargetValid "$SELECTED_FORK" "$SELECTED_BRANCH" ; then | ||
| return 0 | ||
| fi | ||
|
|
||
| return 1 | ||
| } | ||
|
|
||
| # Prints the commit SHA at the head of SELECTED_BRANCH on SELECTED_FORK, or empty if unavailable. | ||
| function elasticsearch_selected_branch_head_sha { | ||
| git ls-remote --heads "git@github.com:${SELECTED_FORK}/elasticsearch.git" "${SELECTED_BRANCH}" 2>/dev/null | awk '{print $1; exit}' | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.