diff --git a/.circleci/config.yml b/.circleci/config.yml index 1008d827..2b8029dc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -56,7 +56,7 @@ commands: INSTANA_TEST: "true" CASSANDRA_TEST: "<>" COUCHBASE_TEST: "<>" - GEVENT_TEST: "<>" + GEVENT_STARLETTE_TEST: "<>" command: | . venv/bin/activate coverage run --source=instana -m pytest -v --junitxml=test-results <> @@ -329,17 +329,17 @@ jobs: - store-pytest-results - run_sonarqube - py39gevent: + py39gevent_starlette: docker: - image: cimg/python:3.9.17 working_directory: ~/repo steps: - checkout - pip-install-deps: - requirements: "tests/requirements-gevent.txt" + requirements: "tests/requirements-gevent-starlette.txt" - run-tests-with-coverage-report: gevent: "true" - tests: "tests/frameworks/test_gevent.py" + tests: "tests/frameworks/test_gevent.py tests/frameworks/test_starlette.py" - store-pytest-results - store-coverage-report @@ -355,7 +355,7 @@ workflows: - python312 - py39cassandra - py39couchbase - - py39gevent + - py39gevent_starlette - final_job: requires: - python37 @@ -366,4 +366,4 @@ workflows: - python312 - py39cassandra - py39couchbase - - py39gevent + - py39gevent_starlette diff --git a/.tekton/github-pr-pipeline.yaml.part b/.tekton/github-pr-pipeline.yaml.part index 45569b1e..5d57e536 100644 --- a/.tekton/github-pr-pipeline.yaml.part +++ b/.tekton/github-pr-pipeline.yaml.part @@ -26,7 +26,7 @@ spec: - unittest-default - unittest-cassandra - unittest-couchbase - - unittest-gevent + - unittest-gevent-starlette taskRef: kind: Task name: github-set-status diff --git a/.tekton/pipeline.yaml b/.tekton/pipeline.yaml index 64748bdb..74ddf9e5 100644 --- a/.tekton/pipeline.yaml +++ b/.tekton/pipeline.yaml @@ -70,7 +70,7 @@ spec: workspaces: - name: task-pvc workspace: python-tracer-ci-pipeline-pvc - - name: unittest-gevent + - name: unittest-gevent-starlette runAfter: - clone matrix: @@ -80,7 +80,7 @@ spec: # 3.9.18-bookworm - "sha256:530d4ba717be787c0e2d011aa107edac6d721f8c06fe6d44708d4aa5e9bc5ec9" taskRef: - name: python-tracer-unittest-gevent-task + name: python-tracer-unittest-gevent-starlette-task workspaces: - name: task-pvc workspace: python-tracer-ci-pipeline-pvc diff --git a/.tekton/run_unittests.sh b/.tekton/run_unittests.sh index cd63a9ba..b70162f8 100755 --- a/.tekton/run_unittests.sh +++ b/.tekton/run_unittests.sh @@ -27,22 +27,22 @@ default) *) export REQUIREMENTS='requirements.txt' ;; esac - export TESTS='tests' ;; + export TESTS=('tests') ;; cassandra) export REQUIREMENTS='requirements-cassandra.txt' - export TESTS='tests/clients/test_cassandra-driver.py' + export TESTS=('tests/clients/test_cassandra-driver.py') export CASSANDRA_TEST='true' ;; couchbase) export REQUIREMENTS='requirements-couchbase.txt' - export TESTS='tests/clients/test_couchbase.py' + export TESTS=('tests/clients/test_couchbase.py') export COUCHBASE_TEST='true' ;; -gevent) - export REQUIREMENTS='requirements-gevent.txt' - export TESTS='tests/frameworks/test_gevent.py' - export GEVENT_TEST='true' ;; +gevent_starlette) + export REQUIREMENTS='requirements-gevent-starlette.txt' + export TESTS=('tests/frameworks/test_gevent.py' 'tests/frameworks/test_starlette.py') + export GEVENT_STARLETTE_TEST='true' ;; *) echo "ERROR \$TEST_CONFIGURATION='${TEST_CONFIGURATION}' is unsupported " \ - "not in (default|cassandra|couchbase|gevent)" >&2 + "not in (default|cassandra|couchbase|gevent_starlette)" >&2 exit 3 ;; esac @@ -73,4 +73,4 @@ coverage run \ --data-file=".coverage-${PYTHON_VERSION}-${TEST_CONFIGURATION}" \ --module \ pytest \ - --verbose --junitxml=test-results "${TESTS}" # pytest options (not coverage options anymore) + --verbose --junitxml=test-results "${TESTS[@]}" # pytest options (not coverage options anymore) diff --git a/.tekton/task.yaml b/.tekton/task.yaml index 03970fb0..af77020d 100644 --- a/.tekton/task.yaml +++ b/.tekton/task.yaml @@ -94,7 +94,7 @@ spec: apiVersion: tekton.dev/v1 kind: Task metadata: - name: python-tracer-unittest-gevent-task + name: python-tracer-unittest-gevent-starlette-task spec: params: - name: imageDigest @@ -107,7 +107,7 @@ spec: image: python@$(params.imageDigest) env: - name: TEST_CONFIGURATION - value: gevent + value: gevent_starlette workingDir: /workspace/python-sensor/ command: - /workspace/python-sensor/.tekton/run_unittests.sh diff --git a/tests/__init__.py b/tests/__init__.py index 7aad59cd..81660d27 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -5,7 +5,7 @@ os.environ["INSTANA_TEST"] = "true" -if os.environ.get('GEVENT_TEST'): +if os.environ.get('GEVENT_STARLETTE_TEST'): from gevent import monkey monkey.patch_all() diff --git a/tests/apps/aiohttp_app/__init__.py b/tests/apps/aiohttp_app/__init__.py index b9cf68a2..7429a949 100644 --- a/tests/apps/aiohttp_app/__init__.py +++ b/tests/apps/aiohttp_app/__init__.py @@ -8,7 +8,7 @@ APP_THREAD = None -if not any((os.environ.get('GEVENT_TEST'), +if not any((os.environ.get('GEVENT_STARLETTE_TEST'), os.environ.get('CASSANDRA_TEST'), sys.version_info < (3, 5, 3))): APP_THREAD = launch_background_thread(server, "AIOHTTP") diff --git a/tests/apps/grpc_server/__init__.py b/tests/apps/grpc_server/__init__.py index 78439e5e..5a222deb 100644 --- a/tests/apps/grpc_server/__init__.py +++ b/tests/apps/grpc_server/__init__.py @@ -6,7 +6,7 @@ import time import threading -if not any((os.environ.get('GEVENT_TEST'), +if not any((os.environ.get('GEVENT_STARLETTE_TEST'), os.environ.get('CASSANDRA_TEST'), sys.version_info < (3, 5, 3))): # Background RPC application diff --git a/tests/apps/tornado_server/__init__.py b/tests/apps/tornado_server/__init__.py index 7b0d6c76..20a27361 100644 --- a/tests/apps/tornado_server/__init__.py +++ b/tests/apps/tornado_server/__init__.py @@ -8,7 +8,7 @@ app_thread = None -if not any((app_thread, os.environ.get('GEVENT_TEST'), os.environ.get('CASSANDRA_TEST'))): +if not any((app_thread, os.environ.get('GEVENT_STARLETTE_TEST'), os.environ.get('CASSANDRA_TEST'))): testenv["tornado_port"] = 10813 testenv["tornado_server"] = ("http://127.0.0.1:" + str(testenv["tornado_port"])) diff --git a/tests/conftest.py b/tests/conftest.py index 4269493c..98dee44e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -22,8 +22,9 @@ if not os.environ.get("COUCHBASE_TEST"): collect_ignore_glob.append("*test_couchbase*") -if not os.environ.get("GEVENT_TEST"): +if not os.environ.get("GEVENT_STARLETTE_TEST"): collect_ignore_glob.append("*test_gevent*") + collect_ignore_glob.append("*test_starlette*") # Python 3.10 support is incomplete yet # TODO: Remove this once we start supporting Tornado >= 6.0 diff --git a/tests/frameworks/test_gevent.py b/tests/frameworks/test_gevent.py index 022309ce..71a724ad 100644 --- a/tests/frameworks/test_gevent.py +++ b/tests/frameworks/test_gevent.py @@ -15,7 +15,7 @@ from ..helpers import testenv, get_spans_by_filter -@unittest.skipIf(not os.environ.get("GEVENT_TEST"), reason="") +@unittest.skipIf(not os.environ.get("GEVENT_STARLETTE_TEST"), reason="") class TestGEvent(unittest.TestCase): def setUp(self): self.http = urllib3.HTTPConnectionPool('127.0.0.1', port=testenv["wsgi_port"], maxsize=20) diff --git a/tests/requirements-gevent.txt b/tests/requirements-gevent-starlette.txt similarity index 73% rename from tests/requirements-gevent.txt rename to tests/requirements-gevent-starlette.txt index 36c23632..1333f76c 100644 --- a/tests/requirements-gevent.txt +++ b/tests/requirements-gevent-starlette.txt @@ -4,4 +4,6 @@ gevent>=1.4.0 mock>=2.0.0 pyramid>=2.0.1 pytest>=4.6 +starlette>=0.12.13 urllib3>=1.26.5 +uvicorn>=0.13.4