-
Notifications
You must be signed in to change notification settings - Fork 17
Add smoke tests, update releasing doc #730
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
4 commits
Select commit
Hold shift + click to select a range
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
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,72 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Smoke test for the splunk-otel-instrumentation-python Docker image. | ||
| # Run this after a release to validate the published image at quay.io. | ||
| # | ||
| # Simulates what the Kubernetes OTel Operator does: runs the init container to | ||
| # populate /autoinstrumentation into a shared volume, then runs a Python container | ||
| # with that volume on PYTHONPATH and sends sqlite3 spans to Splunk O11y. | ||
| # | ||
| # Usage: | ||
| # SPLUNK_ACCESS_TOKEN=<token> ./tests/smoke/smoke-test-docker-image.sh | ||
| # SPLUNK_ACCESS_TOKEN=<token> SPLUNK_REALM=eu0 ./tests/smoke/smoke-test-docker-image.sh | ||
| # SPLUNK_ACCESS_TOKEN=<token> ./tests/smoke/smoke-test-docker-image.sh --image <image:tag> | ||
|
|
||
| : "${SPLUNK_ACCESS_TOKEN:?must be set}" | ||
|
|
||
| DEFAULT_IMAGE="quay.io/signalfx/splunk-otel-instrumentation-python:latest" | ||
| IMAGE="${DEFAULT_IMAGE}" | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| --image=*) IMAGE="${1#--image=}"; shift ;; | ||
| --image) IMAGE="$2"; shift 2 ;; | ||
| *) shift ;; | ||
| esac | ||
| done | ||
|
|
||
| REALM="${SPLUNK_REALM:-us1}" | ||
| SERVICE_NAME="sop-smoke-docker-image-$(date +%Y%m%d%H%M%S)" | ||
| VOLUME="smoke-autoinstrumentation-$$" | ||
|
|
||
| cleanup() { | ||
| docker volume rm "$VOLUME" >/dev/null 2>&1 || true | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| echo "==> Image: ${IMAGE}" | ||
| echo "==> Pulling image..." | ||
| docker pull --platform linux/amd64 "$IMAGE" | ||
|
|
||
| echo "" | ||
| echo "==> Running init container to populate /autoinstrumentation..." | ||
| docker run --rm --platform linux/amd64 \ | ||
| -v "${VOLUME}:/dest" \ | ||
| --entrypoint cp \ | ||
| "$IMAGE" \ | ||
| -r /autoinstrumentation/. /dest/ | ||
|
|
||
| echo "" | ||
| echo "==> Sending spans to Splunk O11y (realm=${REALM}, service=${SERVICE_NAME})..." | ||
| docker run --rm --platform linux/amd64 \ | ||
| -v "${VOLUME}:/autoinstrumentation:ro" \ | ||
| -e PYTHONPATH=/autoinstrumentation \ | ||
| -e OTEL_SERVICE_NAME="${SERVICE_NAME}" \ | ||
| -e SPLUNK_ACCESS_TOKEN="${SPLUNK_ACCESS_TOKEN}" \ | ||
| -e SPLUNK_REALM="${REALM}" \ | ||
| -e OTEL_BSP_SCHEDULE_DELAY=200 \ | ||
| python:3.11-slim \ | ||
| /autoinstrumentation/bin/opentelemetry-instrument \ | ||
| python -c " | ||
| import sqlite3 | ||
| conn = sqlite3.connect(':memory:') | ||
| cur = conn.cursor() | ||
| for i in range(12): | ||
| cur.execute('SELECT ' + str(i)) | ||
| from opentelemetry import trace | ||
| trace.get_tracer_provider().force_flush() | ||
| " | ||
|
|
||
| echo "" | ||
| echo "Done. Check APM on ${REALM} for service '${SERVICE_NAME}'." |
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,47 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Smoke test for the splunk-opentelemetry Python package. | ||
| # Installs the package (local checkout or PyPI) and sends spans to Splunk O11y to | ||
| # verify end-to-end instrumentation works. Run this before a release (local) or | ||
| # after a release (--pypi) to validate the published package. | ||
| # | ||
| # Usage: | ||
| # SPLUNK_ACCESS_TOKEN=<token> ./tests/smoke/smoke-test-package.sh # local checkout | ||
| # SPLUNK_ACCESS_TOKEN=<token> ./tests/smoke/smoke-test-package.sh --pypi # PyPI package | ||
|
|
||
| : "${SPLUNK_ACCESS_TOKEN:?must be set}" | ||
|
|
||
| USE_PYPI=false | ||
| for arg in "$@"; do | ||
| [ "$arg" = "--pypi" ] && USE_PYPI=true | ||
| done | ||
|
|
||
| SMOKE_VENV=/tmp/smoke-venv | ||
|
|
||
| if [ "$USE_PYPI" = "true" ]; then | ||
| echo "==> Installing from PyPI..." | ||
| else | ||
| echo "==> Installing from local checkout..." | ||
| fi | ||
|
|
||
| rm -rf "$SMOKE_VENV" | ||
| python -m venv "$SMOKE_VENV" | ||
| if [ "$USE_PYPI" = "true" ]; then | ||
| "$SMOKE_VENV/bin/pip" install --quiet splunk-opentelemetry | ||
|
pmcollins marked this conversation as resolved.
|
||
| else | ||
| "$SMOKE_VENV/bin/pip" install --quiet . | ||
| fi | ||
|
|
||
| if [ "$USE_PYPI" = "true" ]; then | ||
| echo "splunk-opentelemetry $("$SMOKE_VENV/bin/pip" show splunk-opentelemetry | grep ^Version | cut -d' ' -f2)" | ||
| fi | ||
|
|
||
| export SPLUNK_ACCESS_TOKEN | ||
| export SPLUNK_REALM="${SPLUNK_REALM:-us1}" | ||
| export OTEL_SERVICE_NAME="sop-smoke-package-$(date +%Y%m%d%H%M%S)" | ||
|
|
||
| "$SMOKE_VENV/bin/opentelemetry-instrument" \ | ||
| "$SMOKE_VENV/bin/python" tests/integration/trace_loop.py | ||
|
|
||
| echo "Done. Check APM on ${SPLUNK_REALM} for service '${OTEL_SERVICE_NAME}'." | ||
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.
Uh oh!
There was an error while loading. Please reload this page.