Skip to content

Commit a944abd

Browse files
authored
Enable integration tests again (#23)
* Enable integration tests again * Fix build broken by hatchling 1.19 * Teardown in a separate job * Fix path * Fix key name * Group run/teardown steps * Stop cancelling intermediate builds to not leak projects
1 parent 6eddfe5 commit a944abd

File tree

6 files changed

+107
-37
lines changed

6 files changed

+107
-37
lines changed

.buildkite/generatesteps.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import os
2+
3+
import yaml
4+
5+
6+
def benchmark_to_steps(python, connection_class):
7+
return [
8+
{
9+
"group": f":elasticsearch: :python: ES Serverless ({python}/{connection_class})",
10+
"steps": [
11+
{
12+
"label": "Run tests",
13+
"agents": {"provider": "gcp"},
14+
"env": {
15+
"PYTHON_VERSION": f"{python}",
16+
"PYTHON_CONNECTION_CLASS": f"{connection_class}",
17+
# TEMPORARY for 3.11
18+
# https://github.com/aio-libs/aiohttp/issues/6600
19+
"AIOHTTP_NO_EXTENSIONS": 1,
20+
# https://github.com/aio-libs/frozenlist/issues/285
21+
"FROZENLIST_NO_EXTENSIONS": 1,
22+
# https://github.com/aio-libs/yarl/issues/680
23+
"YARL_NO_EXTENSIONS": 1,
24+
"EC_REGISTER_BACKEND": "appex-qa-team-cluster",
25+
"EC_ENV": "qa",
26+
"EC_REGION": "aws-eu-west-1",
27+
"EC_PROJECT_PREFIX": f"esv-client-python-test-{python}-{connection_class}",
28+
},
29+
"command": "./.buildkite/run-tests",
30+
"artifact_paths": "junit/*-junit.xml",
31+
"retry": {"manual": False},
32+
"key": f"run_{python.replace('.', '_')}_{connection_class}",
33+
},
34+
{
35+
"label": "Teardown",
36+
"agents": {"provider": "gcp"},
37+
"env": {
38+
"PYTHON_VERSION": f"{python}",
39+
"PYTHON_CONNECTION_CLASS": f"{connection_class}",
40+
"EC_REGISTER_BACKEND": "appex-qa-team-cluster",
41+
"EC_ENV": "qa",
42+
"EC_REGION": "aws-eu-west-1",
43+
"EC_PROJECT_PREFIX": f"esv-client-python-test-{python}-{connection_class}",
44+
},
45+
"command": ".buildkite/teardown-tests",
46+
"depends_on": f"run_{python.replace('.', '_')}_{connection_class}",
47+
"allow_dependency_failure": True,
48+
},
49+
],
50+
}
51+
]
52+
53+
54+
if __name__ == "__main__":
55+
steps = []
56+
for python in ["3.7", "3.8", "3.9", "3.10", "3.11"]:
57+
for connection_class in ["urllib3", "requests"]:
58+
steps.extend(benchmark_to_steps(python, connection_class))
59+
print(yaml.dump({"steps": steps}, Dumper=yaml.Dumper, sort_keys=False))

.buildkite/rest-tests.yaml

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,12 @@
11
---
22
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
33
steps:
4-
- label: ":elasticsearch: :python: ES Serverless ({{ matrix.python }}/{{ matrix.connection_class }}) Python Test Suite: {{ matrix.suite }}"
5-
agents:
6-
provider: gcp
7-
env:
8-
PYTHON_VERSION: "{{ matrix.python }}"
9-
PYTHON_CONNECTION_CLASS: "{{ matrix.connection_class }}"
10-
# TEMPORARY for 3.11
11-
# https://github.com/aio-libs/aiohttp/issues/6600
12-
AIOHTTP_NO_EXTENSIONS: 1
13-
# https://github.com/aio-libs/frozenlist/issues/285
14-
FROZENLIST_NO_EXTENSIONS: 1
15-
# https://github.com/aio-libs/yarl/issues/680
16-
YARL_NO_EXTENSIONS: 1
17-
EC_REGISTER_BACKEND: "appex-qa-team-cluster"
18-
EC_ENV: "qa"
19-
EC_REGION: "aws-eu-west-1"
20-
EC_PROJECT_PREFIX: "esv-client-python-test-{{ matrix.python }}-{{ matrix.connection_class }}"
21-
matrix:
22-
setup:
23-
python:
24-
- "3.7"
25-
- "3.8"
26-
- "3.9"
27-
- "3.10"
28-
- "3.11"
29-
connection_class:
30-
- urllib3
31-
- requests
32-
command: echo "Skipping ./.buildkite/run-tests for now"
33-
artifact_paths: "junit/*-junit.xml"
4+
- label: ":pipeline: Generate steps"
5+
command: |
6+
set -eo pipefail
7+
8+
python3 -m pip install pyyaml
9+
python3 .buildkite/generatesteps.py | buildkite-agent pipeline upload
3410
- wait: ~
3511
continue_on_failure: true
3612
- label: ":junit: Test results"

.buildkite/run-tests

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env bash
2+
set -euo pipefail
23

34
# Default environment variables
45
export PYTHON_VERSION="${PYTHON_VERSION:=3.9}"
56
export PYTHON_CONNECTION_CLASS="${PYTHON_CONNECTION_CLASS:=urllib3}"
67
export EC_PROJECT_NAME="$EC_PROJECT_PREFIX-$BUILDKITE_JOB_ID"
7-
8-
set -euo pipefail
8+
buildkite-agent meta-data set $EC_PROJECT_PREFIX $EC_PROJECT_NAME
99

1010
# fetch cloud creds used by qaf
1111
CLOUD_ACCESS_KEY=$(vault read -field="$EC_ENV" secret/ci/elastic-elasticsearch-serverless-python/cloud-access)
@@ -27,9 +27,13 @@ run_qaf() {
2727

2828
# ensure serverless instance is deleted even if script errors
2929
cleanup() {
30-
echo -e "--- :elasticsearch: Tear down serverless instance $EC_PROJECT_NAME"
31-
run_qaf 'qaf elastic-cloud projects delete'
32-
rm -rf "$(pwd)/cloud.json"
30+
if [ -z "$BUILDKITE" ]; then
31+
echo -e "--- :elasticsearch: Tear down serverless instance $EC_PROJECT_NAME"
32+
run_qaf 'qaf elastic-cloud projects delete'
33+
rm -rf "$(pwd)/cloud.json"
34+
else
35+
echo -e "--- In Buildkite, another job will cleanup"
36+
fi
3337
}
3438
trap cleanup EXIT
3539

.buildkite/teardown-tests

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Default environment variables
5+
export PYTHON_VERSION="${PYTHON_VERSION:=3.9}"
6+
export PYTHON_CONNECTION_CLASS="${PYTHON_CONNECTION_CLASS:=urllib3}"
7+
export EC_PROJECT_NAME=$(buildkite-agent meta-data get $EC_PROJECT_PREFIX)
8+
9+
# fetch cloud creds used by qaf
10+
CLOUD_ACCESS_KEY=$(vault read -field="$EC_ENV" secret/ci/elastic-elasticsearch-serverless-python/cloud-access)
11+
echo "{\"api_key\":{\"$EC_ENV\":\"$CLOUD_ACCESS_KEY\"}}" > "$(pwd)/cloud.json"
12+
13+
run_qaf() {
14+
cmd=$1
15+
docker run --rm \
16+
-e EC_REGISTER_BACKEND \
17+
-e EC_ENV \
18+
-e EC_REGION \
19+
-e EC_PROJECT_NAME \
20+
-e VAULT_TOKEN \
21+
-e BUILDKITE \
22+
-v "$(pwd)/cloud.json:/root/.elastic/cloud.json" \
23+
docker.elastic.co/employees/dolaru/qaf:latest \
24+
bash -c "$cmd"
25+
}
26+
27+
echo -e "--- :elasticsearch: Tear down serverless instance $EC_PROJECT_NAME"
28+
run_qaf 'qaf elastic-cloud projects delete'
29+
rm -rf "$(pwd)/cloud.json"

catalog-info.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ spec:
3636
provider_settings:
3737
build_pull_requests: true
3838
build_branches: true
39-
cancel_intermediate_builds: true
40-
cancel_intermediate_builds_branch_filter: '!main'
39+
cancel_intermediate_builds: false
4140
schedules:
4241
main_semi_daily:
4342
branch: 'main'

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ include = [
9595
"/docs/sphinx",
9696
]
9797

98+
[tool.hatch.build.targets.wheel]
99+
packages = ["elasticsearch_serverless"]
100+
98101
[tool.pytest]
99102
junit_family = "legacy"
100103
addopts = "-vvv -p no:logging --cov-report=term-missing --cov=elasticsearch_serverless --cov-config=.pyproject.toml"

0 commit comments

Comments
 (0)