From ded1ac27f0ad26184b5e4cbe3192431251e255fb Mon Sep 17 00:00:00 2001 From: Cagri Yonca Date: Wed, 23 Oct 2024 13:28:46 +0200 Subject: [PATCH] combined requirement files into one file and updated pipelines Signed-off-by: Cagri Yonca --- .circleci/config.yml | 40 +--------------------------- .tekton/github-pr-pipeline.yaml.part | 3 +-- .tekton/pipeline.yaml | 22 +++------------ .tekton/run_unittests.sh | 6 +---- .tekton/task.yaml | 31 --------------------- tests/conftest.py | 39 +++++++++------------------ tests/requirements-googlecloud.txt | 7 ----- tests/requirements.txt | 16 +++++------ 8 files changed, 25 insertions(+), 139 deletions(-) delete mode 100644 tests/requirements-googlecloud.txt diff --git a/.circleci/config.yml b/.circleci/config.yml index 3b10e8280..9cc2bc7ba 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,9 +37,6 @@ commands: run-tests-with-coverage-report: parameters: - googlecloud: - default: "" - type: string cassandra: default: "" type: string @@ -59,7 +56,6 @@ commands: CASSANDRA_TEST: "<>" COUCHBASE_TEST: "<>" GEVENT_STARLETTE_TEST: "<>" - GOOGLE_CLOUD_TEST: "<>" command: | . venv/bin/activate coverage run --source=instana -m pytest -v --junitxml=test-results <> @@ -214,21 +210,6 @@ jobs: - store-pytest-results - store-coverage-report - py311googlecloud: - docker: - - image: cimg/python:3.11.10 - - image: vanmoof/pubsub-emulator - working_directory: ~/repo - steps: - - checkout - - pip-install-deps: - requirements: "tests/requirements-googlecloud.txt" - - run-tests-with-coverage-report: - googlecloud: "true" - tests: "tests/clients/test_google-cloud-*.py" - - store-pytest-results - - store-coverage-report - python312: docker: - image: cimg/python:3.12 @@ -254,21 +235,6 @@ jobs: - store-pytest-results - store-coverage-report - py312googlecloud: - docker: - - image: cimg/python:3.12.6 - - image: vanmoof/pubsub-emulator - working_directory: ~/repo - steps: - - checkout - - pip-install-deps: - requirements: "tests/requirements-googlecloud.txt" - - run-tests-with-coverage-report: - googlecloud: "true" - tests: "tests/clients/test_google-cloud-*.py" - - store-pytest-results - - store-coverage-report - py312aws: docker: - image: cimg/python:3.12 @@ -284,7 +250,7 @@ jobs: python313: docker: - - image: python:3.13.0rc2-bookworm + - image: cimg/python:3.13 - image: cimg/postgres:14.12 environment: POSTGRES_USER: root @@ -379,8 +345,6 @@ workflows: - py39cassandra - py39couchbase # - py39gevent_starlette - - py311googlecloud - - py312googlecloud - py312aws - final_job: requires: @@ -393,6 +357,4 @@ workflows: - py39cassandra - py39couchbase # - py39gevent_starlette - - py311googlecloud - - py312googlecloud - py312aws diff --git a/.tekton/github-pr-pipeline.yaml.part b/.tekton/github-pr-pipeline.yaml.part index 1b4d5313c..e032be920 100644 --- a/.tekton/github-pr-pipeline.yaml.part +++ b/.tekton/github-pr-pipeline.yaml.part @@ -28,8 +28,7 @@ spec: - unittest-default - unittest-cassandra - unittest-couchbase - - unittest-gevent-starlette - - unittest-googlecloud + #- unittest-gevent-starlette taskRef: kind: Task name: github-set-status diff --git a/.tekton/pipeline.yaml b/.tekton/pipeline.yaml index 53492d8a5..e359babf6 100644 --- a/.tekton/pipeline.yaml +++ b/.tekton/pipeline.yaml @@ -35,8 +35,8 @@ spec: - "sha256:3cd9b520be95c671135ea1318f32be6912876024ee16d0f472669d3878801651" # 3.12.6-bookworm - "sha256:af6fa5c329d6bd6dec52855ccb8bb37c30fb8f00819953a035d49499e43b2c9b" - # 3.13.0rc2-bookworm - - "sha256:3aed70fd4585395e47c6005f0082b966151561f3c4070a3ed9d2fb594bbf44b8" + # 3.13.0-bookworm + - "sha256:feee4734fdc44cc09a3c9cdb72e05bb8ff7e964f64766bc1a68638b2c667cf35" taskRef: name: python-tracer-unittest-default-task workspaces: @@ -85,22 +85,6 @@ spec: # workspaces: # - name: task-pvc # workspace: python-tracer-ci-pipeline-pvc - - name: unittest-googlecloud - runAfter: - - clone - matrix: - params: - - name: imageDigest - value: - # 3.11.10-bookworm - - "sha256:3cd9b520be95c671135ea1318f32be6912876024ee16d0f472669d3878801651" - # 3.12.6-bookworm - - "sha256:af6fa5c329d6bd6dec52855ccb8bb37c30fb8f00819953a035d49499e43b2c9b" - taskRef: - name: python-tracer-unittest-googlecloud-task - workspaces: - - name: task-pvc - workspace: python-tracer-ci-pipeline-pvc - name: unittest-aws runAfter: - clone @@ -111,7 +95,7 @@ spec: # 3.12.6-bookworm - "sha256:af6fa5c329d6bd6dec52855ccb8bb37c30fb8f00819953a035d49499e43b2c9b" taskRef: - name: python-tracer-unittest-googlecloud-task + name: python-tracer-unittest-aws-task workspaces: - name: task-pvc workspace: python-tracer-ci-pipeline-pvc diff --git a/.tekton/run_unittests.sh b/.tekton/run_unittests.sh index 003435a29..fd03ac13b 100755 --- a/.tekton/run_unittests.sh +++ b/.tekton/run_unittests.sh @@ -31,16 +31,12 @@ 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' ;; -googlecloud) - export REQUIREMENTS='requirements-googlecloud.txt' - export TESTS=('tests/clients/test_google-cloud-storage.py' 'tests/clients/test_google-cloud-pubsub.py') - export GOOGLE_CLOUD_TEST='true' ;; aws) export REQUIREMENTS='requirements.txt' export TESTS=('tests_aws') ;; *) echo "ERROR \$TEST_CONFIGURATION='${TEST_CONFIGURATION}' is unsupported " \ - "not in (default|cassandra|couchbase|gevent_starlette|googlecloud)" >&2 + "not in (default|cassandra|couchbase|gevent_starlette)" >&2 exit 3 ;; esac diff --git a/.tekton/task.yaml b/.tekton/task.yaml index 253296ba5..768df631f 100644 --- a/.tekton/task.yaml +++ b/.tekton/task.yaml @@ -114,37 +114,6 @@ spec: --- apiVersion: tekton.dev/v1 kind: Task -metadata: - name: python-tracer-unittest-googlecloud-task -spec: - sidecars: - - name: google-cloud-pubsub - # vanmoof/pubsub-emulator:latest - image: vanmoof/pubsub-emulator@sha256:ff71206d65589b58a8b6928c35349a58dbfd7f20eb2dc7822e0f32e5c40791c8 - env: - - name: PUBSUB_EMULATOR_HOST - value: 0.0.0.0:8085 - ports: - - containerPort: 8085 - hostPort: 8085 - params: - - name: imageDigest - type: string - workspaces: - - name: task-pvc - mountPath: /workspace - steps: - - name: unittest - image: python@$(params.imageDigest) - env: - - name: TEST_CONFIGURATION - value: googlecloud - workingDir: /workspace/python-sensor/ - command: - - /workspace/python-sensor/.tekton/run_unittests.sh ---- -apiVersion: tekton.dev/v1 -kind: Task metadata: name: python-tracer-unittest-default-task spec: diff --git a/tests/conftest.py b/tests/conftest.py index 00231691c..400683508 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -42,31 +42,9 @@ # collect_ignore_glob.append("*test_gevent*") # collect_ignore_glob.append("*test_starlette*") -if sys.version_info >= (3, 11): - if not os.environ.get("GOOGLE_CLOUD_TEST"): - collect_ignore_glob.append("*test_google-cloud*") if sys.version_info >= (3, 13): - # TODO: Test Case failures for unknown reason: - collect_ignore_glob.append("*test_aiohttp_server*") - collect_ignore_glob.append("*test_celery*") - collect_ignore_glob.append("*frameworks/test_tornado_server*") - - # Currently there is a runtime incompatibility caused by the library: - # `undefined symbol: _PyErr_WriteUnraisableMsg` - collect_ignore_glob.append("*boto3*") - - # Currently there is a runtime incompatibility caused by the library: - # `undefined symbol: _PyInterpreterState_Get` - collect_ignore_glob.append("*test_psycopg2*") - collect_ignore_glob.append("*test_pep0249*") - collect_ignore_glob.append("*test_sqlalchemy*") - # Currently not installable dependencies because of 3.13 incompatibilities - collect_ignore_glob.append("*test_fastapi*") - collect_ignore_glob.append("*test_google-cloud-pubsub*") - collect_ignore_glob.append("*test_google-cloud-storage*") - collect_ignore_glob.append("*test_grpcio*") collect_ignore_glob.append("*test_sanic*") @@ -98,9 +76,10 @@ def trace_id() -> int: def span_id() -> int: return 6895521157646639861 + @pytest.fixture -def hex_trace_id(trace_id:int) -> str: - # Using format_span_id() to return a 16-byte hexadecimal string, instead of +def hex_trace_id(trace_id: int) -> str: + # Using format_span_id() to return a 16-byte hexadecimal string, instead of # the 32-byte hexadecimal string from format_trace_id(). return format_span_id(trace_id) @@ -109,6 +88,7 @@ def hex_trace_id(trace_id:int) -> str: def hex_span_id(span_id: int) -> str: return format_span_id(span_id) + @pytest.fixture def span_processor() -> StanRecorder: rec = StanRecorder(HostAgent()) @@ -198,6 +178,7 @@ def prepare_and_report_data(monkeypatch, request): else: monkeypatch.setattr(BaseCollector, "prepare_and_report_data", always_true) + # Mocking HostAgent.is_agent_listening() @pytest.fixture(autouse=True) def is_agent_listening(monkeypatch, request) -> None: @@ -205,20 +186,26 @@ def is_agent_listening(monkeypatch, request) -> None: if "original" in request.keywords: # If using the `@pytest.mark.original` marker before the test function, # uses the original HostAgent.is_agent_listening() - monkeypatch.setattr(HostAgent, "is_agent_listening", HostAgent.is_agent_listening) + monkeypatch.setattr( + HostAgent, "is_agent_listening", HostAgent.is_agent_listening + ) else: monkeypatch.setattr(HostAgent, "is_agent_listening", always_true) + @pytest.fixture(autouse=True) def lookup_agent_host(monkeypatch, request) -> None: """Always return `True` for `TheMachine.lookup_agent_host()`""" if "original" in request.keywords: # If using the `@pytest.mark.original` marker before the test function, # uses the original TheMachine.lookup_agent_host() - monkeypatch.setattr(TheMachine, "lookup_agent_host", TheMachine.lookup_agent_host) + monkeypatch.setattr( + TheMachine, "lookup_agent_host", TheMachine.lookup_agent_host + ) else: monkeypatch.setattr(TheMachine, "lookup_agent_host", always_true) + @pytest.fixture(autouse=True) def announce_sensor(monkeypatch, request) -> None: """Always return `True` for `TheMachine.announce_sensor()`""" diff --git a/tests/requirements-googlecloud.txt b/tests/requirements-googlecloud.txt deleted file mode 100644 index 0ee17b7bc..000000000 --- a/tests/requirements-googlecloud.txt +++ /dev/null @@ -1,7 +0,0 @@ -google-cloud-pubsub>=2.0.0 -google-cloud-storage>=2.15.0 -google-api-core>=2.15.0 -coverage>=5.5 -pytest>=6.2.4 -mock>=4.0.3 -celery>=5.2.7 diff --git a/tests/requirements.txt b/tests/requirements.txt index bd0a4cb56..37cabca85 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -7,20 +7,16 @@ coverage>=5.5 Django>=4.2.4; python_version < "3.10" Django>=5.0; python_version >= "3.10" and python_version < "3.12" Django>=5.0a1; python_version >= "3.12" --pre -# Dependency orjson has no 3.13 support yet: -# https://github.com/matyasrichter/fastapi-injector/pull/31 fastapi>=0.92.0; python_version < "3.13" +fastapi>=0.115.0; python_version >= "3.13" flask>=2.3.2 -# grpc is not supported on 3.13 yet: -# https://github.com/grpc/grpc/issues/34922 -grpcio>=1.37.1; python_version < "3.13" -# depends grpcio on 3.13 -google-cloud-pubsub>=2.0.0; python_version < "3.12" -# depends grpcio on 3.13 -google-cloud-storage>=1.24.0; python_version < "3.12" +gevent>=1.4.0 +grpcio<1.67.0; python_version < "3.13" +grpcio>=1.67.0; python_version >= "3.13" +google-cloud-pubsub>=2.0.0 +google-cloud-storage>=1.24.0 legacy-cgi>=2.6.1; python_version == "3.13" lxml>=4.9.2 -markupsafe>=2.1.0;python_version >= "3.10" mock>=4.0.3 moto>=4.1.2 mysqlclient>=2.0.3