Skip to content

Run OpenTelemetry integration test separately #2479

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 5 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
steps:
- label: ":elasticsearch: :python: ES Python ({{ matrix.python }})"
- label: ":elasticsearch: :python: ES Python ({{ matrix.python }}) {{ matrix.nox_session }} "
agents:
provider: "gcp"
env:
PYTHON_VERSION: "{{ matrix.python }}"
TEST_SUITE: "platinum"
STACK_VERSION: "8.11.0-SNAPSHOT"
PYTHON_CONNECTION_CLASS: "{{ matrix.connection }}"
NOX_SESSION: "{{ matrix.nox_session }}"
matrix:
setup:
python:
Expand All @@ -19,4 +20,15 @@ steps:
connection:
- "urllib3"
- "requests"
nox_session:
- "test"
adjustments:
- with:
python: "3.7"
connection: "urllib3"
nox_session: "test_otel"
- with:
python: "3.12"
connection: "urllib3"
nox_session: "test_otel"
command: ./.buildkite/run-tests
3 changes: 2 additions & 1 deletion .buildkite/run-repository.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ echo -e "\033[34;1mINFO:\033[0m URL ${ELASTICSEARCH_URL}\033[0m"
echo -e "\033[34;1mINFO:\033[0m VERSION ${ELASTICSEARCH_VERSION}\033[0m"
echo -e "\033[34;1mINFO:\033[0m CONTAINER ${ELASTICSEARCH_CONTAINER}\033[0m"
echo -e "\033[34;1mINFO:\033[0m TEST_SUITE ${TEST_SUITE}\033[0m"
echo -e "\033[34;1mINFO:\033[0m NOX_SESSION ${NOX_SESSION}\033[0m"
echo -e "\033[34;1mINFO:\033[0m PYTHON_VERSION ${PYTHON_VERSION}\033[0m"
echo -e "\033[34;1mINFO:\033[0m PYTHON_CONNECTION_CLASS ${PYTHON_CONNECTION_CLASS}\033[0m"

Expand Down Expand Up @@ -45,4 +46,4 @@ docker run \
--name elasticsearch-py \
--rm \
elastic/elasticsearch-py \
nox -s test-${PYTHON_VERSION}
nox -s ${NOX_SESSION}-${PYTHON_VERSION}
3 changes: 0 additions & 3 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ nox
numpy
pandas

opentelemetry-api
opentelemetry-sdk

# Testing the 'search_mvt' API response
mapbox-vector-tile
# Python 3.7 gets an old version of mapbox-vector-tile, requiring an
Expand Down
32 changes: 25 additions & 7 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@
INSTALL_ENV = {"AIOHTTP_NO_EXTENSIONS": "1"}


@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"])
def test(session):
session.install(".[async,requests]", env=INSTALL_ENV, silent=False)
session.install("-r", "dev-requirements.txt", silent=False)

def pytest_argv():
junit_xml = os.path.join(SOURCE_DIR, "junit", "elasticsearch-py-junit.xml")
pytest_argv = [
return [
"pytest",
"--cov-report=term-missing",
"--cov=elasticsearch",
Expand All @@ -48,7 +44,29 @@ def test(session):
"--cache-clear",
"-vv",
]
session.run(*pytest_argv)


@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"])
def test(session):
session.install(".[async,requests]", env=INSTALL_ENV, silent=False)
session.install("-r", "dev-requirements.txt", silent=False)

session.run(*pytest_argv())


@nox.session(python=["3.7", "3.12"])
def test_otel(session):
session.install(".[async,requests]", env=INSTALL_ENV, silent=False)
session.install(
"opentelemetry-api",
"opentelemetry-sdk",
"-r",
"dev-requirements.txt",
silent=False,
)

argv = pytest_argv() + ["-m", "otel"]
session.run(*argv, env={"TEST_WITH_OTEL": "1"})


@nox.session()
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ignore = E203, E266, E501, W503
[tool:pytest]
junit_family=legacy
addopts = -vvv --cov-report=term-missing --cov=elasticsearch --cov-config=.coveragerc
markers = otel

[tool:isort]
profile=black
Expand Down
22 changes: 19 additions & 3 deletions test_elasticsearch/test_server/test_otel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,29 @@
# specific language governing permissions and limitations
# under the License.

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider, export
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
import os

import pytest

import elasticsearch
from test_elasticsearch.utils import CA_CERTS

try:
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider, export
from opentelemetry.sdk.trace.export.in_memory_span_exporter import (
InMemorySpanExporter,
)
except ModuleNotFoundError:
pass

pytestmark = [
pytest.mark.skipif(
"TEST_WITH_OTEL" not in os.environ, reason="TEST_WITH_OTEL is not set"
),
pytest.mark.otel,
]


def test_otel_end_to_end(monkeypatch, elasticsearch_url: str):
# Sets the global default tracer provider
Expand Down