From 5510f30fb35be7101976c2213644dfff870965ec Mon Sep 17 00:00:00 2001 From: Paulo Vital Date: Wed, 7 May 2025 16:30:40 +0200 Subject: [PATCH 1/3] fix: CI failures with Python 3.14.0 Signed-off-by: Paulo Vital --- .github/workflows/py3140_build.yml | 58 ++++++++++++++++++++++++++++++ Dockerfile-py3140 | 20 +++++++++++ tests/requirements-pre314.txt | 1 + 3 files changed, 79 insertions(+) create mode 100644 .github/workflows/py3140_build.yml create mode 100644 Dockerfile-py3140 diff --git a/.github/workflows/py3140_build.yml b/.github/workflows/py3140_build.yml new file mode 100644 index 00000000..1cff4a73 --- /dev/null +++ b/.github/workflows/py3140_build.yml @@ -0,0 +1,58 @@ +# This workflow builds a container image on top of the Python 3.14.0 RC images +# with all dependencies already compiled and installed to be used in the tests +# CI pipelines. + +name: Build Instana python-sensor-test-py3.14.0 +on: + workflow_dispatch: # Manual trigger. + schedule: + - cron: '1 0 * * 1,3' # Every Monday and Wednesday at midnight and one. +env: + IMAGE_NAME: python-sensor-test-py3.14.0 + IMAGE_TAG: latest + CONTAINER_FILE: ./Dockerfile-py3140 + IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} + REGISTRY_USER: ${{ github.actor }} + REGISTRY_PASSWORD: ${{ github.token }} +jobs: + build-and-push: + name: Build container image. + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + + - name: Build image + id: build_image + uses: redhat-actions/buildah-build@v2 + with: + image: ${{ env.IMAGE_NAME }} + tags: ${{ env.IMAGE_TAG }} + containerfiles: ${{ env.CONTAINER_FILE }} + + - name: Echo Outputs + run: | + echo "Image: ${{ steps.build_image.outputs.image }}" + echo "Tags: ${{ steps.build_image.outputs.tags }}" + echo "Tagged Image: ${{ steps.build_image.outputs.image-with-tag }}" + + - name: Check images created + run: buildah images | grep '${{ env.IMAGE_NAME }}' + + # Push the image to GHCR (Image Registry) + - name: Push To GHCR + uses: redhat-actions/push-to-registry@v2 + id: push-to-ghcr + with: + image: ${{ steps.build_image.outputs.image }} + tags: ${{ steps.build_image.outputs.tags }} + registry: ${{ env.IMAGE_REGISTRY }} + username: ${{ env.REGISTRY_USER }} + password: ${{ env.REGISTRY_PASSWORD }} + extra-args: | + --disable-content-trust + + - name: Print image URL + run: echo "Image pushed to ${{ steps.push-to-ghcr.outputs.registry-paths }}" diff --git a/Dockerfile-py3140 b/Dockerfile-py3140 new file mode 100644 index 00000000..325922f0 --- /dev/null +++ b/Dockerfile-py3140 @@ -0,0 +1,20 @@ +FROM public.ecr.aws/docker/library/python:3.14.0b1 + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + build-essential python3-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +ENV WORKDIR_=/root/base + +WORKDIR $WORKDIR_ +COPY ./tests/requirements-pre314.txt . + +ENV VIRTUAL_ENV="$WORKDIR_/venv" +RUN python -m venv $VIRTUAL_ENV + +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + +RUN python -m pip install --upgrade pip \ + && python -m pip install -r requirements-pre314.txt diff --git a/tests/requirements-pre314.txt b/tests/requirements-pre314.txt index 8c7aed2c..57ecaa2d 100644 --- a/tests/requirements-pre314.txt +++ b/tests/requirements-pre314.txt @@ -40,3 +40,4 @@ tornado>=6.4.1 uvicorn>=0.13.4 urllib3>=1.26.5 httpx>=0.27.0 +protobuf<=6.30.2 From d7d51df9dac4da401ee652aee8aff35cd01c22dc Mon Sep 17 00:00:00 2001 From: Paulo Vital Date: Wed, 7 May 2025 23:32:19 +0200 Subject: [PATCH 2/3] ci: Update CircleCI config file. Signed-off-by: Paulo Vital --- .circleci/config.yml | 312 ++++++++++++------------------------------- 1 file changed, 82 insertions(+), 230 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b936a177..2bcb7eaa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,9 +1,5 @@ version: 2.1 -# More about orbs: https://circleci.com/docs/2.0/using-orbs/ -# orbs: -# ruby: circleci/ruby@1.1.2 - commands: check-if-tests-needed: steps: @@ -29,10 +25,6 @@ commands: } pip-install-deps: - parameters: - requirements: - default: "tests/requirements.txt" - type: string steps: - run: name: Install Python Dependencies @@ -42,6 +34,17 @@ commands: pip install --upgrade pip pip install 'wheel==0.45.1' pip install -r requirements.txt + + pip-install-tests-deps: + parameters: + requirements: + default: "tests/requirements.txt" + type: string + steps: + - run: + name: Install Python Tests Dependencies + command: | + . venv/bin/activate pip install -r <> run-tests-with-coverage-report: @@ -121,37 +124,12 @@ commands: path: htmlcov jobs: - python38: - docker: - - image: public.ecr.aws/docker/library/python:3.8 - - image: public.ecr.aws/docker/library/postgres:16.2-bookworm - environment: - POSTGRES_USER: root - POSTGRES_PASSWORD: passw0rd - POSTGRES_DB: instana_test_db - - image: public.ecr.aws/docker/library/mariadb:11.3.2 - environment: - MYSQL_ROOT_PASSWORD: passw0rd - MYSQL_DATABASE: instana_test_db - - image: public.ecr.aws/docker/library/redis:7.2.4-bookworm - - image: public.ecr.aws/docker/library/rabbitmq:3.13.0 - - image: public.ecr.aws/docker/library/mongo:7.0.6 - - image: quay.io/thekevjames/gcloud-pubsub-emulator:latest - environment: - PUBSUB_EMULATOR_HOST: 0.0.0.0:8681 - PUBSUB_PROJECT1: test-project,test-topic - working_directory: ~/repo - steps: - - checkout - - check-if-tests-needed - - pip-install-deps - - run-tests-with-coverage-report - - store-pytest-results - - store-coverage-report - - python39: + python3x: + parameters: + py-version: + type: string docker: - - image: public.ecr.aws/docker/library/python:3.9 + - image: public.ecr.aws/docker/library/python:<> - image: public.ecr.aws/docker/library/postgres:16.2-bookworm environment: POSTGRES_USER: root @@ -173,13 +151,14 @@ jobs: - checkout - check-if-tests-needed - pip-install-deps + - pip-install-tests-deps - run-tests-with-coverage-report - store-pytest-results - store-coverage-report - python310: + python314: docker: - - image: public.ecr.aws/docker/library/python:3.10 + - image: ghcr.io/pvital/pvital-py3.14.0:latest - image: public.ecr.aws/docker/library/postgres:16.2-bookworm environment: POSTGRES_USER: root @@ -200,67 +179,50 @@ jobs: steps: - checkout - check-if-tests-needed - - pip-install-deps: - requirements: "tests/requirements.txt" + - run: | + cp -a /root/base/venv ./venv + . venv/bin/activate + pip install 'wheel==0.45.1' + pip install -r requirements.txt - run-tests-with-coverage-report - store-pytest-results - store-coverage-report - python311: + py39cassandra: docker: - - image: public.ecr.aws/docker/library/python:3.11 - - image: public.ecr.aws/docker/library/postgres:16.2-bookworm - environment: - POSTGRES_USER: root - POSTGRES_PASSWORD: passw0rd - POSTGRES_DB: instana_test_db - - image: public.ecr.aws/docker/library/mariadb:11.3.2 - environment: - MYSQL_ROOT_PASSWORD: passw0rd - MYSQL_DATABASE: instana_test_db - - image: public.ecr.aws/docker/library/redis:7.2.4-bookworm - - image: public.ecr.aws/docker/library/rabbitmq:3.13.0 - - image: public.ecr.aws/docker/library/mongo:7.0.6 - - image: quay.io/thekevjames/gcloud-pubsub-emulator:latest + - image: public.ecr.aws/docker/library/python:3.9 + - image: public.ecr.aws/docker/library/cassandra:3.11.16-jammy environment: - PUBSUB_EMULATOR_HOST: 0.0.0.0:8681 - PUBSUB_PROJECT1: test-project,test-topic + MAX_HEAP_SIZE: 2048m + HEAP_NEWSIZE: 512m working_directory: ~/repo steps: - checkout - check-if-tests-needed - - pip-install-deps: - requirements: "tests/requirements.txt" - - run-tests-with-coverage-report + - pip-install-deps + - pip-install-tests-deps: + requirements: "tests/requirements-cassandra.txt" + - run-tests-with-coverage-report: + cassandra: "true" + tests: "tests/clients/test_cassandra-driver.py" - store-pytest-results - store-coverage-report - python312: + py39gevent_starlette: docker: - - image: public.ecr.aws/docker/library/python:3.12 - - image: public.ecr.aws/docker/library/postgres:16.2-bookworm - environment: - POSTGRES_USER: root - POSTGRES_PASSWORD: passw0rd - POSTGRES_DB: instana_test_db - - image: public.ecr.aws/docker/library/mariadb:11.3.2 - environment: - MYSQL_ROOT_PASSWORD: passw0rd - MYSQL_DATABASE: instana_test_db - - image: public.ecr.aws/docker/library/redis:7.2.4-bookworm - - image: public.ecr.aws/docker/library/rabbitmq:3.13.0 - - image: public.ecr.aws/docker/library/mongo:7.0.6 - - image: quay.io/thekevjames/gcloud-pubsub-emulator:latest - environment: - PUBSUB_EMULATOR_HOST: 0.0.0.0:8681 - PUBSUB_PROJECT1: test-project,test-topic + - image: public.ecr.aws/docker/library/python:3.9 working_directory: ~/repo steps: - checkout - check-if-tests-needed - - pip-install-deps: - requirements: "tests/requirements.txt" - - run-tests-with-coverage-report + - pip-install-deps + - pip-install-tests-deps: + requirements: "tests/requirements-gevent-starlette.txt" + - run-tests-with-coverage-report: + # TODO: uncomment once gevent instrumentation is done + # gevent: "true" + # tests: "tests/frameworks/test_gevent.py tests/frameworks/test_starlette.py" + tests: "tests/frameworks/test_starlette.py" - store-pytest-results - store-coverage-report @@ -271,122 +233,59 @@ jobs: steps: - checkout - check-if-tests-needed - - pip-install-deps: + - pip-install-deps + - pip-install-tests-deps: requirements: "tests/requirements-aws.txt" - run-tests-with-coverage-report: tests: "tests_aws" - store-pytest-results - store-coverage-report - py312autowrapt: + py312kafka: docker: - image: public.ecr.aws/docker/library/python:3.12 + - image: public.ecr.aws/bitnami/kafka:3.9.0 environment: - AUTOWRAPT_BOOTSTRAP: instana + KAFKA_CFG_NODE_ID: 0 + KAFKA_CFG_PROCESS_ROLES: controller,broker + KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094 + KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT + KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@localhost:9093 + KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER + KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,EXTERNAL://localhost:9094 working_directory: ~/repo steps: - checkout - check-if-tests-needed - - pip-install-deps: - requirements: "tests/requirements-minimal.txt" + - pip-install-deps + - pip-install-tests-deps: + requirements: "tests/requirements-kafka.txt" - run-tests-with-coverage-report: - tests: "tests_autowrapt" + kafka: "true" + tests: "tests/clients/kafka/test*.py" - store-pytest-results - store-coverage-report - py313autowrapt: + autowrapt: + parameters: + py-version: + type: string docker: - - image: public.ecr.aws/docker/library/python:3.13 + - image: public.ecr.aws/docker/library/python:<> environment: AUTOWRAPT_BOOTSTRAP: instana working_directory: ~/repo steps: - checkout - check-if-tests-needed - - pip-install-deps: + - pip-install-deps + - pip-install-tests-deps: requirements: "tests/requirements-minimal.txt" - run-tests-with-coverage-report: tests: "tests_autowrapt" - store-pytest-results - store-coverage-report - python313: - docker: - - image: public.ecr.aws/docker/library/python:3.13 - - image: public.ecr.aws/docker/library/postgres:16.2-bookworm - environment: - POSTGRES_USER: root - POSTGRES_PASSWORD: passw0rd - POSTGRES_DB: instana_test_db - - image: public.ecr.aws/docker/library/mariadb:11.3.2 - environment: - MYSQL_ROOT_PASSWORD: passw0rd - MYSQL_DATABASE: instana_test_db - - image: public.ecr.aws/docker/library/redis:7.2.4-bookworm - - image: public.ecr.aws/docker/library/rabbitmq:3.13.0 - - image: public.ecr.aws/docker/library/mongo:7.0.6 - - image: quay.io/thekevjames/gcloud-pubsub-emulator:latest - environment: - PUBSUB_EMULATOR_HOST: 0.0.0.0:8681 - PUBSUB_PROJECT1: test-project,test-topic - working_directory: ~/repo - steps: - - checkout - - check-if-tests-needed - - pip-install-deps: - requirements: "tests/requirements.txt" - - run-tests-with-coverage-report - - store-pytest-results - - store-coverage-report - - python314: - docker: - - image: public.ecr.aws/docker/library/python:3.14.0a7 - - image: public.ecr.aws/docker/library/postgres:16.2-bookworm - environment: - POSTGRES_USER: root - POSTGRES_PASSWORD: passw0rd - POSTGRES_DB: instana_test_db - - image: public.ecr.aws/docker/library/mariadb:11.3.2 - environment: - MYSQL_ROOT_PASSWORD: passw0rd - MYSQL_DATABASE: instana_test_db - - image: public.ecr.aws/docker/library/redis:7.2.4-bookworm - - image: public.ecr.aws/docker/library/rabbitmq:3.13.0 - - image: public.ecr.aws/docker/library/mongo:7.0.6 - - image: quay.io/thekevjames/gcloud-pubsub-emulator:latest - environment: - PUBSUB_EMULATOR_HOST: 0.0.0.0:8681 - PUBSUB_PROJECT1: test-project,test-topic - working_directory: ~/repo - steps: - - checkout - - check-if-tests-needed - - pip-install-deps: - requirements: "tests/requirements-pre314.txt" - - run-tests-with-coverage-report - - store-pytest-results - - store-coverage-report - - py39cassandra: - docker: - - image: public.ecr.aws/docker/library/python:3.9 - - image: public.ecr.aws/docker/library/cassandra:3.11.16-jammy - environment: - MAX_HEAP_SIZE: 2048m - HEAP_NEWSIZE: 512m - working_directory: ~/repo - steps: - - checkout - - check-if-tests-needed - - pip-install-deps: - requirements: "tests/requirements-cassandra.txt" - - run-tests-with-coverage-report: - cassandra: "true" - tests: "tests/clients/test_cassandra-driver.py" - - store-pytest-results - - store-coverage-report - final_job: docker: - image: public.ecr.aws/docker/library/python:3.9 @@ -394,81 +293,34 @@ jobs: steps: - checkout - check-if-tests-needed - - pip-install-deps: - requirements: "tests/requirements.txt" + - pip-install-deps + - pip-install-tests-deps - store-pytest-results # - run_sonarqube - py39gevent_starlette: - docker: - - image: public.ecr.aws/docker/library/python:3.9 - working_directory: ~/repo - steps: - - checkout - - check-if-tests-needed - - pip-install-deps: - requirements: "tests/requirements-gevent-starlette.txt" - - run-tests-with-coverage-report: - # TODO: uncomment once gevent instrumentation is done - # gevent: "true" - # tests: "tests/frameworks/test_gevent.py tests/frameworks/test_starlette.py" - tests: "tests/frameworks/test_starlette.py" - - store-pytest-results - - store-coverage-report - - py312kafka: - docker: - - image: public.ecr.aws/docker/library/python:3.12 - - image: public.ecr.aws/bitnami/kafka:3.9.0 - environment: - KAFKA_CFG_NODE_ID: 0 - KAFKA_CFG_PROCESS_ROLES: controller,broker - KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094 - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT - KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@localhost:9093 - KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER - KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,EXTERNAL://localhost:9094 - working_directory: ~/repo - steps: - - checkout - - check-if-tests-needed - - pip-install-deps: - requirements: "tests/requirements-kafka.txt" - - run-tests-with-coverage-report: - kafka: "true" - tests: "tests/clients/kafka/test*.py" - - store-pytest-results - - store-coverage-report - workflows: - version: 2 - build: + tests: jobs: - - python38 - - python39 - - python310 - - python311 - - python312 - - python313 + - python3x: + matrix: + parameters: + py-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] - python314 - py39cassandra - py39gevent_starlette - py312aws - py312kafka - - py312autowrapt - - py313autowrapt + - autowrapt: + matrix: + parameters: + py-version: ["3.12", "3.13"] - final_job: requires: - - python38 - - python39 - - python310 - - python311 - - python312 - - python313 + - python3x # Uncomment the following when giving real support to 3.14 # - python314 - py39cassandra - py39gevent_starlette - py312aws - - py312autowrapt - - py313autowrapt + - py312kafka + - autowrapt From 4fbafe8634ebf9bd19d5175aa15403291adbe290 Mon Sep 17 00:00:00 2001 From: Paulo Vital Date: Fri, 9 May 2025 13:03:27 +0200 Subject: [PATCH 3/3] fix (test): SQLAlchemy type annotation error. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Type annotation can’t be interpreted for Annotated Declarative Table form. https://docs.sqlalchemy.org/en/20/errors.html#type-annotation-can-t-be-interpreted-for-annotated-declarative-table-form Signed-off-by: Paulo Vital --- tests/clients/test_sqlalchemy.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/clients/test_sqlalchemy.py b/tests/clients/test_sqlalchemy.py index 6aef6fc9..6cbd8a87 100644 --- a/tests/clients/test_sqlalchemy.py +++ b/tests/clients/test_sqlalchemy.py @@ -22,6 +22,7 @@ class StanUser(Base): __tablename__ = "churchofstan" + __allow_unmapped__ = True id = Column(Integer, primary_key=True) name = Column(String)