-
Notifications
You must be signed in to change notification settings - Fork 4
Integration test runner #12
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
92937c8
Buildkite test runner for REST test suite
JoshMock 421e60b
Fix outdated package name references
JoshMock da6887e
Streamline Dockerfile used by CI
JoshMock 1c90489
Allow transport to assume port
JoshMock 8e642ab
Fetch YAML tests from elastic/serverless-clients-tests
JoshMock d4da1b3
Drop unnecessary line break
JoshMock 5afee8d
Put back a misplaced `refresh`
JoshMock c0270d5
More linter surprises
JoshMock 1cfbbe5
Pull zipball from main
JoshMock 1cfc4d4
Push more env vars to the test container
JoshMock a07785e
Pull qaf runs out into a function
JoshMock 63f1911
Ensure each build's project has a unique name
JoshMock 049c0fd
Remove cloud creds as part of cleanup
JoshMock 7e9fdae
Drop unused STACK_VERSION env var
JoshMock 8c8721a
Use pwd for cloud cred removal
JoshMock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
steps: | ||
- label: ":elasticsearch: :python: ES Serverless ({{ matrix.python }}/{{ matrix.connection_class }}) Python Test Suite: {{ matrix.suite }}" | ||
agents: | ||
provider: gcp | ||
env: | ||
PYTHON_VERSION: "{{ matrix.python }}" | ||
TEST_SUITE: "{{ matrix.suite }}" | ||
PYTHON_CONNECTION_CLASS: "{{ matrix.connection_class }}" | ||
# TEMPORARY for 3.11 | ||
# https://github.com/aio-libs/aiohttp/issues/6600 | ||
AIOHTTP_NO_EXTENSIONS: 1 | ||
# https://github.com/aio-libs/frozenlist/issues/285 | ||
FROZENLIST_NO_EXTENSIONS: 1 | ||
# https://github.com/aio-libs/yarl/issues/680 | ||
YARL_NO_EXTENSIONS: 1 | ||
EC_REGISTER_BACKEND: "appex-qa-team-cluster" | ||
EC_ENV: "qa" | ||
EC_REGION: "aws-eu-west-1" | ||
EC_PROJECT_NAME: "esv-client-python-test-{{ matrix.python }}-{{ matrix.suite }}-{{ matrix.connection_class }}-{{ key }}" | ||
matrix: | ||
setup: | ||
suite: | ||
- free | ||
- platinum | ||
python: | ||
- "3.7" | ||
- "3.8" | ||
- "3.9" | ||
- "3.10" | ||
- "3.11" | ||
connection_class: | ||
- urllib3 | ||
- requests | ||
command: ./.buildkite/run-tests | ||
artifact_paths: "junit/*-junit.xml" | ||
- wait: ~ | ||
continue_on_failure: true | ||
- label: ":junit: Test results" | ||
agents: | ||
provider: gcp | ||
image: family/core-ubuntu-2204 | ||
plugins: | ||
- junit-annotate#v2.4.1: | ||
artifacts: "junit/*-junit.xml" | ||
job-uuid-file-pattern: "(.*)-junit.xml" | ||
fail-build-on-error: true | ||
failure-format: file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Default environment variables | ||
export TEST_SUITE="${TEST_SUITE:=platinum}" | ||
export PYTHON_VERSION="${PYTHON_VERSION:=3.9}" | ||
export PYTHON_CONNECTION_CLASS="${PYTHON_CONNECTION_CLASS:=urllib3}" | ||
|
||
set -euo pipefail | ||
|
||
# fetch cloud creds used by qaf | ||
CLOUD_ACCESS_KEY=$(vault read -field="$EC_ENV" secret/ci/elastic-elasticsearch-serverless-python/cloud-access) | ||
echo "{\"api_key\":{\"$EC_ENV\":\"$CLOUD_ACCESS_KEY\"}}" > "$(pwd)/cloud.json" | ||
|
||
run_qaf() { | ||
cmd=$1 | ||
docker run --rm \ | ||
-e EC_REGISTER_BACKEND \ | ||
-e EC_ENV \ | ||
-e EC_REGION \ | ||
-e EC_PROJECT_NAME \ | ||
-e VAULT_TOKEN \ | ||
-v "$(pwd)/cloud.json:/root/.elastic/cloud.json" \ | ||
docker.elastic.co/employees/dolaru/qaf:latest \ | ||
bash -c "$cmd" | ||
} | ||
|
||
# ensure serverless instance is deleted even if script errors | ||
cleanup() { | ||
echo -e "--- :elasticsearch: Tear down serverless instance EC_PROJECT_NAME" | ||
run_qaf 'qaf elastic-cloud projects delete' | ||
rm -rf "$(pwd)/cloud.json" | ||
} | ||
trap cleanup EXIT | ||
|
||
echo -e "--- :elasticsearch: Start serverless instance" | ||
|
||
run_qaf "qaf elastic-cloud projects create --project-type elasticsearch" | ||
deployment=$(run_qaf "qaf elastic-cloud projects describe --as-json --show-credentials") | ||
|
||
ES_API_SECRET_KEY=$(echo "$deployment" | jq -r '.credentials.api_key') | ||
ELASTICSEARCH_URL=$(echo "$deployment" | jq -r '.elasticsearch.url') | ||
export ELASTICSEARCH_URL | ||
|
||
echo -e "--- :computer: Environment variables" | ||
echo -e "ELASTICSEARCH_URL $ELASTICSEARCH_URL" | ||
echo -e "TEST_SUITE $TEST_SUITE" | ||
echo -e "PYTHON_VERSION $PYTHON_VERSION" | ||
echo -e "PYTHON_CONNECTION_CLASS $PYTHON_CONNECTION_CLASS" | ||
|
||
echo -e "--- :docker: Build elasticsearch-serverless-python container" | ||
|
||
docker build \ | ||
--file .ci/Dockerfile \ | ||
--tag elasticsearch-serverless-python \ | ||
--build-arg "PYTHON_VERSION=$PYTHON_VERSION" \ | ||
. | ||
|
||
echo -e "--- :docker: :python: Run integration tests for Python $PYTHON_VERSION" | ||
|
||
GITHUB_TOKEN=$(vault read -field=token secret/ci/elastic-elasticsearch-serverless-python/github-token) | ||
export GITHUB_TOKEN | ||
|
||
docker run \ | ||
-e ELASTICSEARCH_URL \ | ||
-e "ES_API_KEY=$ES_API_SECRET_KEY" \ | ||
-e PYTHON_CONNECTION_CLASS \ | ||
-e TEST_SUITE \ | ||
-e GITHUB_TOKEN \ | ||
-e AIOHTTP_NO_EXTENSIONS \ | ||
-e FROZENLIST_NO_EXTENSIONS \ | ||
-e YARL_NO_EXTENSIONS \ | ||
--name elasticsearch-serverless-python-tests \ | ||
--volume "$(pwd)/junit:/code/elasticsearch-serverless-python/junit" \ | ||
--rm \ | ||
elasticsearch-serverless-python \ | ||
nox -s "test-$PYTHON_VERSION" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,13 @@ | ||
ARG PYTHON_VERSION=3.8 | ||
ARG PYTHON_VERSION=3.9 | ||
FROM python:${PYTHON_VERSION} | ||
|
||
# Default UID/GID to 1000 | ||
# it can be overridden at build time | ||
ARG BUILDER_UID=1000 | ||
ARG BUILDER_GID=1000 | ||
ENV BUILDER_USER elastic | ||
ENV BUILDER_GROUP elastic | ||
|
||
WORKDIR /code/elasticsearch-serverless-python | ||
RUN mkdir -p /code/elasticsearch-serverless-python/build | ||
|
||
# Create user | ||
RUN groupadd --system -g ${BUILDER_GID} ${BUILDER_GROUP} \ | ||
&& useradd --system --shell /bin/bash -u ${BUILDER_UID} -g ${BUILDER_GROUP} -d /var/lib/elastic -m elastic 1>/dev/null 2>/dev/null \ | ||
&& mkdir /code/elasticsearch-serverless-python/build \ | ||
&& chown -R ${BUILDER_USER}:${BUILDER_GROUP} /code/ | ||
USER ${BUILDER_USER}:${BUILDER_GROUP} | ||
COPY --chown=$BUILDER_USER:$BUILDER_GROUP . . | ||
COPY pyproject.toml README.rst . | ||
RUN python -m pip install \ | ||
-U --no-cache-dir \ | ||
--disable-pip-version-check \ | ||
.[dev] | ||
|
||
COPY . . |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
# yaml-language-server: $schema=https://json.schemastore.org/catalog-info.json | ||
apiVersion: backstage.io/v1alpha1 | ||
kind: Component | ||
metadata: | ||
name: elasticsearch-serverless-python | ||
spec: | ||
type: library | ||
owner: group:clients-team | ||
lifecycle: alpha | ||
|
||
--- | ||
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json | ||
apiVersion: backstage.io/v1alpha1 | ||
kind: Resource | ||
metadata: | ||
name: elasticsearch-serverless-python-rest-tests | ||
description: elasticsearch-serverless-python - rest tests | ||
spec: | ||
type: buildkite-pipeline | ||
owner: group:clients-team | ||
system: buildkite | ||
implementation: | ||
apiVersion: buildkite.elastic.dev/v1 | ||
kind: Pipeline | ||
metadata: | ||
name: elasticsearch-serverless-python - rest tests | ||
spec: | ||
repository: elastic/elasticsearch-serverless-python | ||
pipeline_file: .buildkite/rest-tests.yaml | ||
teams: | ||
clients-team: | ||
access_level: MANAGE_BUILD_AND_READ | ||
everyone: | ||
access_level: READ_ONLY | ||
provider_settings: | ||
build_pull_requests: true | ||
build_branches: true | ||
cancel_intermediate_builds: true | ||
cancel_intermediate_builds_branch_filter: '!main' | ||
schedules: | ||
main_semi_daily: | ||
branch: 'main' | ||
cronline: '0 */12 * * *' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another improvement I hope to make soon is to spin up a single serverless project for the whole matrix, ensuring each test run in the matrix uses a unique prefix (probably the Buildkite step ID) on all resources created in Elasticsearch. It's slow, ugly and expensive to set up several serverless instances every time this test suite is run.