-
Notifications
You must be signed in to change notification settings - Fork 4
Enable integration tests again #23
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
Changes from all commits
86adf51
31e6d62
3b12e41
2ac87c0
8eed08f
1b56708
c2a1ed1
4e7092a
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,59 @@ | ||
import os | ||
|
||
import yaml | ||
|
||
|
||
def benchmark_to_steps(python, connection_class): | ||
return [ | ||
{ | ||
"group": f":elasticsearch: :python: ES Serverless ({python}/{connection_class})", | ||
"steps": [ | ||
{ | ||
"label": "Run tests", | ||
"agents": {"provider": "gcp"}, | ||
"env": { | ||
"PYTHON_VERSION": f"{python}", | ||
"PYTHON_CONNECTION_CLASS": f"{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_PREFIX": f"esv-client-python-test-{python}-{connection_class}", | ||
}, | ||
"command": "./.buildkite/run-tests", | ||
"artifact_paths": "junit/*-junit.xml", | ||
"retry": {"manual": False}, | ||
"key": f"run_{python.replace('.', '_')}_{connection_class}", | ||
}, | ||
{ | ||
"label": "Teardown", | ||
"agents": {"provider": "gcp"}, | ||
"env": { | ||
"PYTHON_VERSION": f"{python}", | ||
"PYTHON_CONNECTION_CLASS": f"{connection_class}", | ||
"EC_REGISTER_BACKEND": "appex-qa-team-cluster", | ||
"EC_ENV": "qa", | ||
"EC_REGION": "aws-eu-west-1", | ||
"EC_PROJECT_PREFIX": f"esv-client-python-test-{python}-{connection_class}", | ||
}, | ||
"command": ".buildkite/teardown-tests", | ||
"depends_on": f"run_{python.replace('.', '_')}_{connection_class}", | ||
"allow_dependency_failure": True, | ||
}, | ||
], | ||
} | ||
] | ||
|
||
|
||
if __name__ == "__main__": | ||
steps = [] | ||
for python in ["3.7", "3.8", "3.9", "3.10", "3.11"]: | ||
for connection_class in ["urllib3", "requests"]: | ||
Comment on lines
+56
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be in rest-tests.yaml! |
||
steps.extend(benchmark_to_steps(python, connection_class)) | ||
print(yaml.dump({"steps": steps}, Dumper=yaml.Dumper, sort_keys=False)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,12 @@ | ||
--- | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json | ||
steps: | ||
- label: ":elasticsearch: :python: ES Serverless ({{ matrix.python }}/{{ matrix.connection_class }}) Python Test Suite: {{ matrix.suite }}" | ||
agents: | ||
provider: gcp | ||
env: | ||
PYTHON_VERSION: "{{ matrix.python }}" | ||
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_PREFIX: "esv-client-python-test-{{ matrix.python }}-{{ matrix.connection_class }}" | ||
matrix: | ||
setup: | ||
python: | ||
- "3.7" | ||
- "3.8" | ||
- "3.9" | ||
- "3.10" | ||
- "3.11" | ||
connection_class: | ||
- urllib3 | ||
- requests | ||
command: echo "Skipping ./.buildkite/run-tests for now" | ||
artifact_paths: "junit/*-junit.xml" | ||
- label: ":pipeline: Generate steps" | ||
command: | | ||
set -eo pipefail | ||
|
||
python3 -m pip install pyyaml | ||
python3 .buildkite/generatesteps.py | buildkite-agent pipeline upload | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we need two builds per combination (run-tests and teardown), the matrix functionality does not work and we need to generate the steps. |
||
- wait: ~ | ||
continue_on_failure: true | ||
- label: ":junit: Test results" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
# Default environment variables | ||
export PYTHON_VERSION="${PYTHON_VERSION:=3.9}" | ||
export PYTHON_CONNECTION_CLASS="${PYTHON_CONNECTION_CLASS:=urllib3}" | ||
export EC_PROJECT_NAME="$EC_PROJECT_PREFIX-$BUILDKITE_JOB_ID" | ||
|
||
set -euo pipefail | ||
buildkite-agent meta-data set $EC_PROJECT_PREFIX $EC_PROJECT_NAME | ||
|
||
# fetch cloud creds used by qaf | ||
CLOUD_ACCESS_KEY=$(vault read -field="$EC_ENV" secret/ci/elastic-elasticsearch-serverless-python/cloud-access) | ||
|
@@ -27,9 +27,13 @@ run_qaf() { | |
|
||
# 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" | ||
if [ -z "$BUILDKITE" ]; then | ||
echo -e "--- :elasticsearch: Tear down serverless instance $EC_PROJECT_NAME" | ||
run_qaf 'qaf elastic-cloud projects delete' | ||
rm -rf "$(pwd)/cloud.json" | ||
Comment on lines
+31
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we want to use |
||
else | ||
echo -e "--- In Buildkite, another job will cleanup" | ||
fi | ||
} | ||
trap cleanup EXIT | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
# Default environment variables | ||
export PYTHON_VERSION="${PYTHON_VERSION:=3.9}" | ||
export PYTHON_CONNECTION_CLASS="${PYTHON_CONNECTION_CLASS:=urllib3}" | ||
export EC_PROJECT_NAME=$(buildkite-agent meta-data get $EC_PROJECT_PREFIX) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We retrieve the full project name to be able to tear it down. |
||
|
||
# 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 \ | ||
-e BUILDKITE \ | ||
-v "$(pwd)/cloud.json:/root/.elastic/cloud.json" \ | ||
docker.elastic.co/employees/dolaru/qaf:latest \ | ||
bash -c "$cmd" | ||
} | ||
|
||
echo -e "--- :elasticsearch: Tear down serverless instance $EC_PROJECT_NAME" | ||
run_qaf 'qaf elastic-cloud projects delete' | ||
rm -rf "$(pwd)/cloud.json" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,8 +36,7 @@ spec: | |
provider_settings: | ||
build_pull_requests: true | ||
build_branches: true | ||
cancel_intermediate_builds: true | ||
cancel_intermediate_builds_branch_filter: '!main' | ||
cancel_intermediate_builds: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want to cancel intermediate builds to make sure we always tear down all serverless projects. |
||
schedules: | ||
main_semi_daily: | ||
branch: 'main' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,6 +95,9 @@ include = [ | |
"/docs/sphinx", | ||
] | ||
|
||
[tool.hatch.build.targets.wheel] | ||
packages = ["elasticsearch_serverless"] | ||
|
||
Comment on lines
+98
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is required by a recent Hatch change: pypa/hatch#1113 |
||
[tool.pytest] | ||
junit_family = "legacy" | ||
addopts = "-vvv -p no:logging --cov-report=term-missing --cov=elasticsearch_serverless --cov-config=.pyproject.toml" | ||
|
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.
A group isn't strictly necessary, but it allows for a nicer summary.